跳至主要内容

接口: HTMLParser2Options

htmlparser2 接受的选项,它是 XML 的默认解析器。

参见

https://github.com/fb55/htmlparser2/wiki/Parser-options

扩展

属性

Tokenizer?

optional Tokenizer: typeof default

允许覆盖默认的标记器。

继承自

HTMLParser2ParserOptions.Tokenizer

定义在

node_modules/htmlparser2/lib/esm/Parser.d.ts:47


decodeEntities?

optional decodeEntities: boolean

解码文档中的实体。

默认值

true

继承自

HTMLParser2ParserOptions.decodeEntities

定义在

node_modules/htmlparser2/lib/esm/Parser.d.ts:17


lowerCaseAttributeNames?

optional lowerCaseAttributeNames: boolean

如果设置为 true,所有属性名称将转换为小写。这会对速度产生显著影响。

默认值

!xmlMode

继承自

HTMLParser2ParserOptions.lowerCaseAttributeNames

定义在

node_modules/htmlparser2/lib/esm/Parser.d.ts:29


lowerCaseTags?

optional lowerCaseTags: boolean

如果设置为 true,所有标签将转换为小写。

默认值

!xmlMode

继承自

HTMLParser2ParserOptions.lowerCaseTags

定义在

node_modules/htmlparser2/lib/esm/Parser.d.ts:23


recognizeCDATA?

optional recognizeCDATA: boolean

如果设置为 true,CDATA 部分将被识别为文本,即使 xmlMode 选项未启用。注意:如果 xmlMode 设置为 true,则 CDATA 部分将始终被识别为文本。

默认值

xmlMode

继承自

HTMLParser2ParserOptions.recognizeCDATA

定义在

node_modules/htmlparser2/lib/esm/Parser.d.ts:36


recognizeSelfClosing?

optional recognizeSelfClosing: boolean

如果设置为 true,自闭合标签将触发 onclosetag 事件,即使 xmlMode 未设置为 true。注意:如果 xmlMode 设置为 true,则自闭合标签将始终被识别。

默认值

xmlMode

继承自

HTMLParser2ParserOptions.recognizeSelfClosing

定义在

node_modules/htmlparser2/lib/esm/Parser.d.ts:43


withEndIndices?

optional withEndIndices: boolean

向节点添加 endIndex 属性。当解析器以非流式方式使用时,endIndex 是一个整数,表示文档中节点末尾的位置。

默认值

false

继承自

DomHandlerOptions.withEndIndices

定义在

node_modules/domhandler/lib/esm/index.d.ts:19


withStartIndices?

optional withStartIndices: boolean

向节点添加 startIndex 属性。当解析器以非流式方式使用时,startIndex 是一个整数,表示文档中节点开始的位置。

默认值

false

继承自

DomHandlerOptions.withStartIndices

定义在

node_modules/domhandler/lib/esm/index.d.ts:11


xmlMode?

optional xmlMode: boolean

将标记视为 XML。

默认值

false

继承自

DomHandlerOptions.xmlMode

定义在

node_modules/domhandler/lib/esm/index.d.ts:25