xml-tokenizer 0.0.46 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/config.js +1 -1
- package/dist/cjs/html-to-md.js +4 -4
- package/dist/cjs/tokenizer/XmlStream.js +1 -1
- package/dist/cjs/tokenizer/tokenize.js +1 -1
- package/dist/esm/config.js +1 -1
- package/dist/esm/html-to-md.js +6 -6
- package/dist/esm/tokenizer/XmlStream.js +1 -1
- package/dist/esm/tokenizer/tokenize.js +1 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/types/tokenizer/XmlStream.d.ts +10 -3
- package/package.json +9 -9
package/dist/cjs/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e={strictDocument:!0,lowercaseNames:!1,allowDtd:!0,rawTextElements:null,implicitSelfClosingElements:null,contextSliceSize:30},t={strictDocument:!1,lowercaseNames:!0,allowDtd:!0,rawTextElements:["script","style","title","textarea"],implicitSelfClosingElements:["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],contextSliceSize:30},l={strictDocument:!1,lowercaseNames:!1,allowDtd:!0,rawTextElements:["style"],implicitSelfClosingElements:[],contextSliceSize:30};exports.htmlConfig=t,exports.svgConfig=l,exports.xmlConfig=e;
|
package/dist/cjs/html-to-md.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var b=require("./config.js"),
|
|
2
|
-
`},blockquote:(r,t)=>{const n=
|
|
3
|
-
`,code:r=>{const t=
|
|
1
|
+
"use strict";var b=require("./config.js"),c=require("./xml-to-string.js"),C=Object.defineProperty,a=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,l,o)=>l in e?C(e,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[l]=o,$=(e,l)=>{for(var o in l||(l={}))m.call(l,o)&&f(e,o,l[o]);if(a)for(var o of a(l))d.call(l,o)&&f(e,o,l[o]);return e},X=(e,l)=>{var o={};for(var i in e)m.call(e,i)&&l.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&a)for(var i of a(e))l.indexOf(i)<0&&d.call(e,i)&&(o[i]=e[i]);return o};function v(e,l={}){const o=l,{xmlOptions:i=b.htmlConfig,transformers:h,skipNodes:p=y}=o,S=X(o,["xmlOptions","transformers","skipNodes"]);return c.xmlToString(e,$({xmlOptions:i,skipNodes:p,transformers:$({h1:(r,t)=>{const n=u(c.getXmlStringNodeContent(r));return n===""?"":`${s(t)}# ${n}`},h2:(r,t)=>{const n=u(c.getXmlStringNodeContent(r));return n===""?"":`${s(t)}## ${n}`},h3:(r,t)=>{const n=u(c.getXmlStringNodeContent(r));return n===""?"":`${s(t)}### ${n}`},h4:(r,t)=>{const n=u(c.getXmlStringNodeContent(r));return n===""?"":`${s(t)}#### ${n}`},h5:(r,t)=>{const n=u(c.getXmlStringNodeContent(r));return n===""?"":`${s(t)}##### ${n}`},h6:(r,t)=>{const n=u(c.getXmlStringNodeContent(r));return n===""?"":`${s(t)}###### ${n}`},p:(r,t)=>{const n=u(c.getXmlStringNodeContent(r));return n===""?"":`${s(t)}${n}`},strong:r=>{const t=u(c.getXmlStringNodeContent(r));return t===""?"":`**${t}**`},b:r=>{const t=u(c.getXmlStringNodeContent(r));return t===""?"":`**${t}**`},em:r=>{const t=u(c.getXmlStringNodeContent(r));return t===""?"":`*${t}*`},i:r=>{const t=u(c.getXmlStringNodeContent(r));return t===""?"":`*${t}*`},a:r=>{var t;const n=(t=r.attributes.find(N=>N.local==="href"))==null?void 0:t.value,g=u(c.getXmlStringNodeContent(r));return g===""?"":n!=null?`[${g}](${n})`:g},ul:(r,t)=>{const n=c.getXmlStringNodeContent(r);return n===""?"":`${s(t)}${n}`},ol:(r,t)=>{const n=c.getXmlStringNodeContent(r);return n===""?"":`${s(t)}${n}`},li:(r,t)=>{const n=u(c.getXmlStringNodeContent(r));if(n==="")return"";const g=O(t);return`${" ".repeat(Math.max(0,g-1))}- ${n}
|
|
2
|
+
`},blockquote:(r,t)=>{const n=u(c.getXmlStringNodeContent(r));return n===""?"":`${s(t)}> ${n}`},hr:(r,t)=>`${s(t)}---`,br:()=>`
|
|
3
|
+
`,code:r=>{const t=u(c.getXmlStringNodeContent(r));return t===""?"":`\`${t}\``},pre:(r,t)=>{const n=c.getXmlStringNodeContent(r);return n===""?"":`${s(t)}\`\`\`
|
|
4
4
|
${n}
|
|
5
|
-
\`\`\``}},h)},S))}function
|
|
5
|
+
\`\`\``}},h)},S))}function u(e){return e.replace(/\s+/g," ").trim()}function s(e){if(e.length===0)return"";const l=e[e.length-1];if(l==null||l.content.length===0)return"";for(let o=l.content.length-1;o>=0;o--){const i=l.content[o];if(typeof i=="object"&&i.string!=null&&i.string!==""){if(k.has(i.local))return`
|
|
6
6
|
|
|
7
7
|
`;if(x.has(i.local))return`
|
|
8
8
|
`}}return""}function O(e){let l=0;for(let o=e.length-1;o>=0;o--){const i=e[o];i&&(i.local==="ul"||i.local==="ol")&&l++}return l}const k=new Set(["h1","h2","h3","h4","h5","h6","p","div","blockquote","hr","pre","ul","ol","li"]),x=new Set(["strong","b","em","i","a","code","br"]),y=["script","style","meta","link","noscript","iframe","object","embed","param","base","title","head"];exports.htmlToMarkdown=v;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=require("./ascii-constants.js"),l=require("./utils.js"),n=require("./XmlError.js"),g=Object.defineProperty,d=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,u=(a,t,e)=>t in a?g(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,_=(a,t)=>{for(var e in t||(t={}))x.call(t,e)&&u(a,e,t[e]);if(d)for(var e of d(t))E.call(t,e)&&u(a,e,t[e]);return a},p=(a,t,e)=>u(a,typeof t!="symbol"?t+"":t,e);class m{constructor(t,e={}){p(this,"_text"),p(this,"_pos"),p(this,"_end"),p(this,"config");const{pos:s=0,strictDocument:r=!0,lowercaseNames:i=!1,allowDtd:h=!0,rawTextElements:c=null,implicitSelfClosingElements:C=null,contextSliceSize:f=!1}=e;this._text=t,this._pos=s,this._end=this._text.length,this.config={strictDocument:r,lowercaseNames:i,allowDtd:h,rawTextElements:c,implicitSelfClosingElements:C,contextSliceSize:f}}clone(){return new m(this._text,_({pos:this._pos},this.config))}getPos(){return this._pos}atEnd(){return this._pos>=this._end}currCodeUnit(){if(this._pos>=this._end)throw new n.XmlError({type:"UnexpectedEndOfStream"});return this._text.charCodeAt(this._pos)}currCodeUnitUnchecked(){return this._text.charCodeAt(this._pos)}nextCodeUnit(){if(this._pos+1>=this._end)throw new n.XmlError({type:"UnexpectedEndOfStream"});return this._text.charCodeAt(this._pos+1)}consumeCodeUnit(t){const e=this.currCodeUnit();if(e!==t)throw new n.XmlError({type:"InvalidChar",expected:t,actual:e},this.genTextPos());this._pos+=1}tryConsumeCodeUnit(t){return this.currCodeUnit()===t?(this._pos+=1,!0):!1}consumeCodeUnitsWhile(t){const e=this._pos;return this.skipCodeUnitsWhile(t),this.sliceBack(e)}skipCodeUnitsWhile(t){for(;this._pos<this._end&&t(this.currCodeUnitUnchecked(),this);){if(!l.isXmlChar(this.currCodeUnitUnchecked()))throw new n.XmlError({type:"NonXmlChar",char:String.fromCodePoint(this.currCodeUnitUnchecked())},this.genTextPos());this._pos+=1}}advance(t){this._pos+=t}goTo(t){this._pos=t}goToEnd(){this._pos=this._end}startsWith(t){return this._text.startsWith(t,this._pos)}startsWithIgnoreCase(t){if(this._pos+t.length>this._end)return!1;for(let e=0;e<t.length;e++){const s=this._text.charCodeAt(this._pos+e),r=t.charCodeAt(e),i=s>=97&&s<=122?s-32:s,h=r>=97&&r<=122?r-32:r;if(i!==h)return!1}return!0}skipString(t){if(!this.startsWith(t))throw new n.XmlError({type:"InvalidString",expected:t},this.genTextPos());this._pos+=t.length}sliceBack(t){return this._text.slice(t,this._pos)}rangeFrom(t){return{start:t,end:this._pos}}skipSpaces(){for(;this.startsWithSpace();)this._pos+=1}startsWithSpace(){return this._pos<this._end&&l.isXmlSpaceByte(this.currCodeUnitUnchecked())}consumeSpaces(){if(this._pos>=this._end)throw new n.XmlError({type:"UnexpectedEndOfStream"},this.genTextPos());if(!this.startsWithSpace())throw new n.XmlError({type:"InvalidChar",expected:"a whitespace",actual:this.currCodeUnitUnchecked()},this.genTextPos());this.skipSpaces()}tryConsumeReference(){const t=this._pos,e=this.clone(),s=e.consumeReference();return s!=null?(this._pos+=e.getPos()-t,s):null}consumeReference(){if(!this.tryConsumeCodeUnit(o.AMPERSAND))return null;let t;if(this.tryConsumeCodeUnit(o.HASH)){let e,s;this.tryConsumeCodeUnit(o.LOWERCASE_X)?(e=this.consumeCodeUnitsWhile(i=>i>=o.ZERO&&i<=o.NINE||i>=o.UPPERCASE_A&&i<=o.UPPERCASE_F||i>=o.LOWERCASE_A&&i<=o.LOWERCASE_F),s=16):(e=this.consumeCodeUnitsWhile(i=>l.isAsciiDigit(i)),s=10);const r=parseInt(e,s);isNaN(r)||!l.isXmlChar(r)?t=null:t={type:"Char",value:String.fromCodePoint(r)}}else{const e=this.consumeName();switch(e){case"quot":t={type:"Char",value:'"'};break;case"amp":t={type:"Char",value:"&"};break;case"apos":t={type:"Char",value:"'"};break;case"lt":t={type:"Char",value:"<"};break;case"gt":t={type:"Char",value:">"};break;default:t={type:"Entity",value:e}}}return this.tryConsumeCodeUnit(o.SEMICOLON)?t:null}consumeName(){const t=this._pos;this.skipName();const e=this.sliceBack(t);if(e.length===0)throw new n.XmlError({type:"InvalidName"},this.genTextPosFrom(t));return e}skipName(){const t=this._pos;for(;this._pos<this._end;){const e=this.currCodeUnitUnchecked();if(this._pos===t){if(!l.isXmlNameStart(e))throw new n.XmlError({type:"InvalidName"},this.genTextPosFrom(t))}else if(!l.isXmlName(e))break;this._pos+=1}}consumeQName(){var t,e;const s=this._pos;let r=null;for(;this._pos<this._end;){const c=this.currCodeUnitUnchecked();if(c===o.COLON)if(r==null)r=this._pos,this._pos+=1;else throw new n.XmlError({type:"InvalidName"},this.genTextPosFrom(s));else if(l.isXmlName(c))this._pos+=1;else break}let i,h;if(r!=null?(i=this._text.slice(s,r),h=this.sliceBack(r+1)):(i="",h=this.sliceBack(s)),i.length>0&&!l.isXmlNameStart((t=i[0])==null?void 0:t.codePointAt(0)))throw new n.XmlError({type:"InvalidName"},this.genTextPosFrom(s));if(h.length>0){if(!l.isXmlNameStart((e=h[0])==null?void 0:e.codePointAt(0)))throw new n.XmlError({type:"InvalidName"},this.genTextPosFrom(s))}else throw new n.XmlError({type:"InvalidName"},this.genTextPosFrom(s));return this.config.lowercaseNames&&(i=i.replace(/[A-Z]/g,c=>c.toLowerCase()),h=h.replace(/[A-Z]/g,c=>c.toLowerCase())),[i,h]}consumeQuote(){const t=this.currCodeUnit();if(t===o.SINGLE_QUOTE||t===o.DOUBLE_QUOTE)return this._pos+=1,t;throw new n.XmlError({type:"InvalidChar",expected:"a quote",actual:t},this.genTextPos())}getTextAround(t,e){const s=Math.floor(e/2),r=Math.max(0,t-s),i=Math.min(this._end,t+s+e%2);return this._text.slice(r,i)}genTextPos(){return this.genTextPosFrom(this._pos)}genTextPosFrom(t){const e=Math.min(t,this._end);let s=1,r=1;for(let i=0;i<e;i++)this._text.charCodeAt(i)===o.LINE_FEED?(s++,r=1):r++;return _({row:s,col:r},this.config.contextSliceSize?{contextSlice:this.getTextAround(t,this.config.contextSliceSize)}:{})}}exports.XmlStream=m;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var U=require("../get-q-name.js"),s=require("./ascii-constants.js"),
|
|
1
|
+
"use strict";var U=require("../get-q-name.js"),s=require("./ascii-constants.js"),H=require("./utils.js"),c=require("./XmlError.js"),Q=require("./XmlStream.js");const D="\uFEFF",A="<?xml ",k="?>",F="<!ENTITY",O="<!ELEMENT",G="<!ATTLIST",b="<!NOTATION",p="<!DOCTYPE",w="<?",W="?>",E="<!--",y="-->",B="<![CDATA[",f="]]>",M="NDATA",N="PUBLIC",q="SYSTEM",K="version",Y="encoding",z="standalone";function $(t,n,e={}){P(new Q.XmlStream(t,e),n)}function P(t,n){if(t.startsWith(D)&&t.advance(1),t.startsWith(A)&&j(t),m(t,n),t.config.strictDocument){if(t.skipSpaces(),t.startsWithIgnoreCase(p)&&(S(t,n),m(t,n)),t.skipSpaces(),!t.atEnd()&&t.currCodeUnit()===s.LESS_THAN&&T(t,n),m(t,n),!t.atEnd())throw new c.XmlError({type:"UnknownToken",message:"Not at end"},t.genTextPos())}else for(;!t.atEnd();)t.currCodeUnit()===s.LESS_THAN?T(t,n):R(t,n),m(t,n)}function m(t,n){for(;!t.atEnd();)if(t.skipSpaces(),t.startsWith(E))g(t,n);else if(!t.config.strictDocument&&t.startsWithIgnoreCase(p))S(t,n);else if(t.startsWith(w))h(t,n);else break}function j(t){function n(e){if(e.startsWithSpace())e.skipSpaces();else if(!e.startsWith(k)&&!e.atEnd())throw new c.XmlError({type:"InvalidChar",expected:"a whitespace",actual:e.currCodeUnitUnchecked()},e.genTextPos())}if(t.advance(5),n(t),!t.startsWith(K))throw new c.XmlError({type:"InvalidString",expected:"version"},t.genTextPos());d(t),n(t),t.startsWith(Y)&&(d(t),n(t)),t.startsWith(z)&&d(t),t.skipSpaces(),t.skipString(k)}function g(t,n){const e=t.getPos();t.advance(4);const o=t.consumeCodeUnitsWhile((r,i)=>!(r===s.HYPHEN&&i.startsWith(y)));if(t.skipString(y),o.includes("--")||o.endsWith("-"))throw new c.XmlError({type:"InvalidComment"},t.genTextPosFrom(e));n({type:"Comment",text:o,range:t.rangeFrom(e)},t)}function h(t,n){if(t.startsWith(A))throw new c.XmlError({type:"UnexpectedDeclaration"},t.genTextPos());const e=t.getPos();t.advance(2);const o=t.consumeName();t.skipSpaces();const r=t.consumeCodeUnitsWhile((i,a)=>!(i===s.QUESTION_MARK&&a.startsWith(W)));t.skipString(W),n({type:"ProcessingInstruction",target:o,content:r.length===0?void 0:r,range:t.rangeFrom(e)},t)}function S(t,n){if(!t.config.allowDtd)throw new c.XmlError({type:"DtdDetected"});const e=t.getPos();if(J(t),t.skipSpaces(),t.currCodeUnit()===s.GREATER_THAN){t.advance(1);return}for(t.advance(1);!t.atEnd();)if(t.skipSpaces(),t.startsWith(F))Z(t,n);else if(t.startsWith(E))g(t,n);else if(t.startsWith(w))h(t,n);else if(t.startsWith("]"))if(t.advance(1),t.skipSpaces(),t.currCodeUnit()===s.GREATER_THAN){t.advance(1);break}else throw new c.XmlError({type:"InvalidChar",expected:"'>'",actual:t.currCodeUnitUnchecked()},t.genTextPos());else if(t.startsWith(O)||t.startsWith(G)||t.startsWith(b))try{tt(t)}catch(o){throw new c.XmlError({type:"UnknownToken",message:"Failed to consume declaration"},t.genTextPosFrom(e))}else throw new c.XmlError({type:"UnknownToken",message:"Failed to parse doctype"},t.genTextPos())}function J(t){t.advance(9),t.consumeSpaces(),t.skipName(),t.skipSpaces(),x(t),t.skipSpaces();const n=t.currCodeUnit();if(n!==s.OPEN_SQUARE_BRACKET&&n!==s.GREATER_THAN)throw new c.XmlError({type:"InvalidChar",expected:"'[' or '>'",actual:n},t.genTextPos())}function x(t){if(t.startsWith(q)||t.startsWith(N)){const n=t.getPos();t.advance(6);const e=t.sliceBack(n);t.consumeSpaces();const o=t.consumeQuote();if(t.consumeCodeUnitsWhile(r=>r!==o),t.consumeCodeUnit(o),e===N){t.consumeSpaces();const r=t.consumeQuote();t.consumeCodeUnitsWhile(i=>i!==r),t.consumeCodeUnit(r)}return!0}return!1}function Z(t,n){t.advance(8),t.consumeSpaces();const e=!t.tryConsumeCodeUnit(s.PERCENT);e||t.consumeSpaces();const o=t.consumeName();t.consumeSpaces();const r=V(t,e);r!==null&&n({type:"EntityDeclaration",name:o,definition:r},t),t.skipSpaces(),t.consumeCodeUnit(s.GREATER_THAN)}function V(t,n){const e=t.currCodeUnit();if(e===s.DOUBLE_QUOTE||e===s.SINGLE_QUOTE){const o=t.consumeQuote(),r=t.getPos();t.skipCodeUnitsWhile(a=>a!==o);const i=t.sliceBack(r);return t.consumeCodeUnit(o),i}else if(e===s.UPPERCASE_S||e===s.UPPERCASE_P){if(x(t))return n&&(t.skipSpaces(),t.startsWith(M)&&(t.advance(5),t.consumeSpaces(),t.skipName())),null;throw new c.XmlError({type:"InvalidExternalID"},t.genTextPos())}else throw new c.XmlError({type:"InvalidChar",expected:"a quote, SYSTEM or PUBLIC",actual:e},t.genTextPos())}function tt(t){t.skipCodeUnitsWhile(n=>n!==s.GREATER_THAN),t.consumeCodeUnit(s.GREATER_THAN)}function T(t,n){const e=t.getPos();t.advance(1);const[o,r]=t.consumeQName();n({type:"ElementStart",prefix:o,local:r,start:e},t);let i=!1;for(;!t.atEnd();){const a=t.startsWithSpace();t.skipSpaces();const l=t.getPos(),C=t.currCodeUnit();if(C===s.SLASH){t.advance(1),t.consumeCodeUnit(s.GREATER_THAN);const u=t.rangeFrom(l);n({type:"ElementEnd",end:{type:"Empty"},range:u},t);break}else if(C===s.GREATER_THAN){t.advance(1);const u=t.rangeFrom(l);if(t.config.implicitSelfClosingElements!=null&&t.config.implicitSelfClosingElements.includes(U.getQName(r,o))){n({type:"ElementEnd",end:{type:"Empty"},range:u},t);break}else{n({type:"ElementEnd",end:{type:"Open"},range:u},t),i=!0;break}}else{if(!a)throw new c.XmlError({type:"InvalidChar",expected:"a whitespace",actual:t.currCodeUnitUnchecked()},t.genTextPos());const[u,I,X]=d(t),L=t.getPos();n({type:"Attribute",range:{start:l,end:L},prefix:u,local:I,value:X},t)}}if(i){if(t.config.rawTextElements!=null){const a=U.getQName(r,o);if(t.config.rawTextElements.includes(a)){v(t,n,`</${a}>`);return}}v(t,n)}}function d(t){const[n,e]=t.consumeQName();let o;const r=t.getPos();if(t.skipSpaces(),t.tryConsumeCodeUnit(s.EQUALS)){t.skipSpaces();const i=t.currCodeUnit();if(i===s.SINGLE_QUOTE||i===s.DOUBLE_QUOTE){const a=t.consumeQuote();o=t.consumeCodeUnitsWhile(l=>l!==a&&l!==s.LESS_THAN),t.consumeCodeUnit(a)}else if(!t.config.strictDocument)o=t.consumeCodeUnitsWhile(a=>!H.isXmlSpaceByte(a)&&a!==s.GREATER_THAN&&a!==s.SLASH&&a!==s.LESS_THAN);else throw new c.XmlError({type:"InvalidChar",expected:"a quote",actual:i},t.genTextPos())}else if(!t.config.strictDocument)t.goTo(r),o="true";else throw new c.XmlError({type:"InvalidChar",expected:s.EQUALS,actual:t.currCodeUnit()},t.genTextPos());return[n,e,o]}function v(t,n,e=s.LESS_THAN){for(;!t.atEnd();)if(_(t,e)){const o=t.nextCodeUnit();if(o===s.EXCLAMATION_MARK)if(t.startsWith(E))g(t,n);else if(t.startsWith(B))nt(t,n);else if(!t.config.strictDocument&&t.startsWithIgnoreCase(p))S(t,n);else throw new c.XmlError({type:"UnknownToken",message:"Failed to parse content"},t.genTextPos());else if(o===s.QUESTION_MARK)h(t,n);else if(o===s.SLASH){et(t,n);break}else T(t,n)}else R(t,n,e)}function nt(t,n){const e=t.getPos();t.advance(9);const o=t.consumeCodeUnitsWhile((i,a)=>!(i===s.CLOSE_SQUARE_BRACKET&&a.startsWith(f)));t.skipString(f);const r=t.rangeFrom(e);n({type:"Cdata",text:o,range:r},t)}function et(t,n){const e=t.getPos();t.advance(2);const[o,r]=t.consumeQName();t.skipSpaces(),t.consumeCodeUnit(s.GREATER_THAN);const i=t.rangeFrom(e);n({type:"ElementEnd",end:{type:"Close",prefix:o,local:r},range:i},t)}function R(t,n,e=s.LESS_THAN){const o=t.getPos(),r=typeof e=="number"?t.consumeCodeUnitsWhile(i=>i!==e):t.consumeCodeUnitsWhile((i,a)=>!_(a,e));if(t.config.strictDocument&&r.includes(f))throw new c.XmlError({type:"InvalidCharacterData"},t.genTextPos());n({type:"Text",text:r,range:t.rangeFrom(o)},t)}function _(t,n){return typeof n=="number"?t.currCodeUnit()===n:t.config.lowercaseNames?t.startsWithIgnoreCase(n):t.startsWith(n)}exports.tokenize=$,exports.tokenizeXmlStream=P;
|
package/dist/esm/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={strictDocument:!0,allowDtd:!0,rawTextElements:null,implicitSelfClosingElements:null,contextSliceSize:30},t={strictDocument:!1,allowDtd:!0,rawTextElements:["script","style","title","textarea"],implicitSelfClosingElements:["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],contextSliceSize:30},l={strictDocument:!1,allowDtd:!0,rawTextElements:["style"],implicitSelfClosingElements:[],contextSliceSize:30};export{t as htmlConfig,l as svgConfig,e as xmlConfig};
|
|
1
|
+
const e={strictDocument:!0,lowercaseNames:!1,allowDtd:!0,rawTextElements:null,implicitSelfClosingElements:null,contextSliceSize:30},t={strictDocument:!1,lowercaseNames:!0,allowDtd:!0,rawTextElements:["script","style","title","textarea"],implicitSelfClosingElements:["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],contextSliceSize:30},l={strictDocument:!1,lowercaseNames:!1,allowDtd:!0,rawTextElements:["style"],implicitSelfClosingElements:[],contextSliceSize:30};export{t as htmlConfig,l as svgConfig,e as xmlConfig};
|
package/dist/esm/html-to-md.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{htmlConfig as O}from"./config.js";import{xmlToString as x,getXmlStringNodeContent as
|
|
2
|
-
`},blockquote:(n,t)=>{const r=
|
|
3
|
-
`,code:n=>{const t=
|
|
1
|
+
import{htmlConfig as O}from"./config.js";import{xmlToString as x,getXmlStringNodeContent as s}from"./xml-to-string.js";var y=Object.defineProperty,f=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,h=(e,l,o)=>l in e?y(e,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[l]=o,m=(e,l)=>{for(var o in l||(l={}))$.call(l,o)&&h(e,o,l[o]);if(f)for(var o of f(l))p.call(l,o)&&h(e,o,l[o]);return e},k=(e,l)=>{var o={};for(var c in e)$.call(e,c)&&l.indexOf(c)<0&&(o[c]=e[c]);if(e!=null&&f)for(var c of f(e))l.indexOf(c)<0&&p.call(e,c)&&(o[c]=e[c]);return o};function j(e,l={}){const o=l,{xmlOptions:c=O,transformers:b,skipNodes:g=P}=o,d=k(o,["xmlOptions","transformers","skipNodes"]);return x(e,m({xmlOptions:c,skipNodes:g,transformers:m({h1:(n,t)=>{const r=u(s(n));return r===""?"":`${i(t)}# ${r}`},h2:(n,t)=>{const r=u(s(n));return r===""?"":`${i(t)}## ${r}`},h3:(n,t)=>{const r=u(s(n));return r===""?"":`${i(t)}### ${r}`},h4:(n,t)=>{const r=u(s(n));return r===""?"":`${i(t)}#### ${r}`},h5:(n,t)=>{const r=u(s(n));return r===""?"":`${i(t)}##### ${r}`},h6:(n,t)=>{const r=u(s(n));return r===""?"":`${i(t)}###### ${r}`},p:(n,t)=>{const r=u(s(n));return r===""?"":`${i(t)}${r}`},strong:n=>{const t=u(s(n));return t===""?"":`**${t}**`},b:n=>{const t=u(s(n));return t===""?"":`**${t}**`},em:n=>{const t=u(s(n));return t===""?"":`*${t}*`},i:n=>{const t=u(s(n));return t===""?"":`*${t}*`},a:n=>{var t;const r=(t=n.attributes.find(v=>v.local==="href"))==null?void 0:t.value,a=u(s(n));return a===""?"":r!=null?`[${a}](${r})`:a},ul:(n,t)=>{const r=s(n);return r===""?"":`${i(t)}${r}`},ol:(n,t)=>{const r=s(n);return r===""?"":`${i(t)}${r}`},li:(n,t)=>{const r=u(s(n));if(r==="")return"";const a=w(t);return`${" ".repeat(Math.max(0,a-1))}- ${r}
|
|
2
|
+
`},blockquote:(n,t)=>{const r=u(s(n));return r===""?"":`${i(t)}> ${r}`},hr:(n,t)=>`${i(t)}---`,br:()=>`
|
|
3
|
+
`,code:n=>{const t=u(s(n));return t===""?"":`\`${t}\``},pre:(n,t)=>{const r=s(n);return r===""?"":`${i(t)}\`\`\`
|
|
4
4
|
${r}
|
|
5
|
-
\`\`\``}},b)},d))}function
|
|
5
|
+
\`\`\``}},b)},d))}function u(e){return e.replace(/\s+/g," ").trim()}function i(e){if(e.length===0)return"";const l=e[e.length-1];if(l==null||l.content.length===0)return"";for(let o=l.content.length-1;o>=0;o--){const c=l.content[o];if(typeof c=="object"&&c.string!=null&&c.string!==""){if(S.has(c.local))return`
|
|
6
6
|
|
|
7
|
-
`;if(N.has(
|
|
8
|
-
`}}return""}function w(e){let l=0;for(let o=e.length-1;o>=0;o--){const
|
|
7
|
+
`;if(N.has(c.local))return`
|
|
8
|
+
`}}return""}function w(e){let l=0;for(let o=e.length-1;o>=0;o--){const c=e[o];c&&(c.local==="ul"||c.local==="ol")&&l++}return l}const S=new Set(["h1","h2","h3","h4","h5","h6","p","div","blockquote","hr","pre","ul","ol","li"]),N=new Set(["strong","b","em","i","a","code","br"]),P=["script","style","meta","link","noscript","iframe","object","embed","param","base","title","head"];export{j as htmlToMarkdown};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AMPERSAND as x,HASH as
|
|
1
|
+
import{AMPERSAND as x,HASH as w,LOWERCASE_X as U,ZERO as y,NINE as S,UPPERCASE_A as E,UPPERCASE_F as v,LOWERCASE_A as P,LOWERCASE_F as k,SEMICOLON as N,COLON as A,SINGLE_QUOTE as T,DOUBLE_QUOTE as O,LINE_FEED as b}from"./ascii-constants.js";import{isXmlChar as d,isXmlSpaceByte as I,isAsciiDigit as W,isXmlNameStart as l,isXmlName as m}from"./utils.js";import{XmlError as n}from"./XmlError.js";var F=Object.defineProperty,_=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable,p=(h,t,e)=>t in h?F(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,f=(h,t)=>{for(var e in t||(t={}))L.call(t,e)&&p(h,e,t[e]);if(_)for(var e of _(t))R.call(t,e)&&p(h,e,t[e]);return h},a=(h,t,e)=>p(h,typeof t!="symbol"?t+"":t,e);class u{constructor(t,e={}){a(this,"_text"),a(this,"_pos"),a(this,"_end"),a(this,"config");const{pos:s=0,strictDocument:o=!0,lowercaseNames:i=!1,allowDtd:r=!0,rawTextElements:c=null,implicitSelfClosingElements:C=null,contextSliceSize:g=!1}=e;this._text=t,this._pos=s,this._end=this._text.length,this.config={strictDocument:o,lowercaseNames:i,allowDtd:r,rawTextElements:c,implicitSelfClosingElements:C,contextSliceSize:g}}clone(){return new u(this._text,f({pos:this._pos},this.config))}getPos(){return this._pos}atEnd(){return this._pos>=this._end}currCodeUnit(){if(this._pos>=this._end)throw new n({type:"UnexpectedEndOfStream"});return this._text.charCodeAt(this._pos)}currCodeUnitUnchecked(){return this._text.charCodeAt(this._pos)}nextCodeUnit(){if(this._pos+1>=this._end)throw new n({type:"UnexpectedEndOfStream"});return this._text.charCodeAt(this._pos+1)}consumeCodeUnit(t){const e=this.currCodeUnit();if(e!==t)throw new n({type:"InvalidChar",expected:t,actual:e},this.genTextPos());this._pos+=1}tryConsumeCodeUnit(t){return this.currCodeUnit()===t?(this._pos+=1,!0):!1}consumeCodeUnitsWhile(t){const e=this._pos;return this.skipCodeUnitsWhile(t),this.sliceBack(e)}skipCodeUnitsWhile(t){for(;this._pos<this._end&&t(this.currCodeUnitUnchecked(),this);){if(!d(this.currCodeUnitUnchecked()))throw new n({type:"NonXmlChar",char:String.fromCodePoint(this.currCodeUnitUnchecked())},this.genTextPos());this._pos+=1}}advance(t){this._pos+=t}goTo(t){this._pos=t}goToEnd(){this._pos=this._end}startsWith(t){return this._text.startsWith(t,this._pos)}startsWithIgnoreCase(t){if(this._pos+t.length>this._end)return!1;for(let e=0;e<t.length;e++){const s=this._text.charCodeAt(this._pos+e),o=t.charCodeAt(e),i=s>=97&&s<=122?s-32:s,r=o>=97&&o<=122?o-32:o;if(i!==r)return!1}return!0}skipString(t){if(!this.startsWith(t))throw new n({type:"InvalidString",expected:t},this.genTextPos());this._pos+=t.length}sliceBack(t){return this._text.slice(t,this._pos)}rangeFrom(t){return{start:t,end:this._pos}}skipSpaces(){for(;this.startsWithSpace();)this._pos+=1}startsWithSpace(){return this._pos<this._end&&I(this.currCodeUnitUnchecked())}consumeSpaces(){if(this._pos>=this._end)throw new n({type:"UnexpectedEndOfStream"},this.genTextPos());if(!this.startsWithSpace())throw new n({type:"InvalidChar",expected:"a whitespace",actual:this.currCodeUnitUnchecked()},this.genTextPos());this.skipSpaces()}tryConsumeReference(){const t=this._pos,e=this.clone(),s=e.consumeReference();return s!=null?(this._pos+=e.getPos()-t,s):null}consumeReference(){if(!this.tryConsumeCodeUnit(x))return null;let t;if(this.tryConsumeCodeUnit(w)){let e,s;this.tryConsumeCodeUnit(U)?(e=this.consumeCodeUnitsWhile(i=>i>=y&&i<=S||i>=E&&i<=v||i>=P&&i<=k),s=16):(e=this.consumeCodeUnitsWhile(i=>W(i)),s=10);const o=parseInt(e,s);isNaN(o)||!d(o)?t=null:t={type:"Char",value:String.fromCodePoint(o)}}else{const e=this.consumeName();switch(e){case"quot":t={type:"Char",value:'"'};break;case"amp":t={type:"Char",value:"&"};break;case"apos":t={type:"Char",value:"'"};break;case"lt":t={type:"Char",value:"<"};break;case"gt":t={type:"Char",value:">"};break;default:t={type:"Entity",value:e}}}return this.tryConsumeCodeUnit(N)?t:null}consumeName(){const t=this._pos;this.skipName();const e=this.sliceBack(t);if(e.length===0)throw new n({type:"InvalidName"},this.genTextPosFrom(t));return e}skipName(){const t=this._pos;for(;this._pos<this._end;){const e=this.currCodeUnitUnchecked();if(this._pos===t){if(!l(e))throw new n({type:"InvalidName"},this.genTextPosFrom(t))}else if(!m(e))break;this._pos+=1}}consumeQName(){var t,e;const s=this._pos;let o=null;for(;this._pos<this._end;){const c=this.currCodeUnitUnchecked();if(c===A)if(o==null)o=this._pos,this._pos+=1;else throw new n({type:"InvalidName"},this.genTextPosFrom(s));else if(m(c))this._pos+=1;else break}let i,r;if(o!=null?(i=this._text.slice(s,o),r=this.sliceBack(o+1)):(i="",r=this.sliceBack(s)),i.length>0&&!l((t=i[0])==null?void 0:t.codePointAt(0)))throw new n({type:"InvalidName"},this.genTextPosFrom(s));if(r.length>0){if(!l((e=r[0])==null?void 0:e.codePointAt(0)))throw new n({type:"InvalidName"},this.genTextPosFrom(s))}else throw new n({type:"InvalidName"},this.genTextPosFrom(s));return this.config.lowercaseNames&&(i=i.replace(/[A-Z]/g,c=>c.toLowerCase()),r=r.replace(/[A-Z]/g,c=>c.toLowerCase())),[i,r]}consumeQuote(){const t=this.currCodeUnit();if(t===T||t===O)return this._pos+=1,t;throw new n({type:"InvalidChar",expected:"a quote",actual:t},this.genTextPos())}getTextAround(t,e){const s=Math.floor(e/2),o=Math.max(0,t-s),i=Math.min(this._end,t+s+e%2);return this._text.slice(o,i)}genTextPos(){return this.genTextPosFrom(this._pos)}genTextPosFrom(t){const e=Math.min(t,this._end);let s=1,o=1;for(let i=0;i<e;i++)this._text.charCodeAt(i)===b?(s++,o=1):o++;return f({row:s,col:o},this.config.contextSliceSize?{contextSlice:this.getTextAround(t,this.config.contextSliceSize)}:{})}}export{u as XmlStream};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getQName as w}from"../get-q-name.js";import{LESS_THAN as
|
|
1
|
+
import{getQName as w}from"../get-q-name.js";import{LESS_THAN as u,GREATER_THAN as r,SLASH as f,EQUALS as W,SINGLE_QUOTE as y,DOUBLE_QUOTE as P,HYPHEN as X,QUESTION_MARK as x,OPEN_SQUARE_BRACKET as H,PERCENT as Y,EXCLAMATION_MARK as K,UPPERCASE_S as q,UPPERCASE_P as z,CLOSE_SQUARE_BRACKET as G}from"./ascii-constants.js";import{isXmlSpaceByte as $}from"./utils.js";import{XmlError as a}from"./XmlError.js";import{XmlStream as j}from"./XmlStream.js";const J="\uFEFF",v="<?xml ",I="?>",Z="<!ENTITY",V="<!ELEMENT",tt="<!ATTLIST",nt="<!NOTATION",g="<!DOCTYPE",A="<?",N="?>",h="<!--",D="-->",st="<![CDATA[",C="]]>",et="NDATA",F="PUBLIC",ot="SYSTEM",it="version",ct="encoding",at="standalone";function rt(t,n,s={}){Q(new j(t,s),n)}function Q(t,n){if(t.startsWith(J)&&t.advance(1),t.startsWith(v)&&pt(t),d(t,n),t.config.strictDocument){if(t.skipSpaces(),t.startsWithIgnoreCase(g)&&(U(t,n),d(t,n)),t.skipSpaces(),!t.atEnd()&&t.currCodeUnit()===u&&k(t,n),d(t,n),!t.atEnd())throw new a({type:"UnknownToken",message:"Not at end"},t.genTextPos())}else for(;!t.atEnd();)t.currCodeUnit()===u?k(t,n):O(t,n),d(t,n)}function d(t,n){for(;!t.atEnd();)if(t.skipSpaces(),t.startsWith(h))E(t,n);else if(!t.config.strictDocument&&t.startsWithIgnoreCase(g))U(t,n);else if(t.startsWith(A))S(t,n);else break}function pt(t){function n(s){if(s.startsWithSpace())s.skipSpaces();else if(!s.startsWith(I)&&!s.atEnd())throw new a({type:"InvalidChar",expected:"a whitespace",actual:s.currCodeUnitUnchecked()},s.genTextPos())}if(t.advance(5),n(t),!t.startsWith(it))throw new a({type:"InvalidString",expected:"version"},t.genTextPos());m(t),n(t),t.startsWith(ct)&&(m(t),n(t)),t.startsWith(at)&&m(t),t.skipSpaces(),t.skipString(I)}function E(t,n){const s=t.getPos();t.advance(4);const e=t.consumeCodeUnitsWhile((o,i)=>!(o===X&&i.startsWith(D)));if(t.skipString(D),e.includes("--")||e.endsWith("-"))throw new a({type:"InvalidComment"},t.genTextPosFrom(s));n({type:"Comment",text:e,range:t.rangeFrom(s)},t)}function S(t,n){if(t.startsWith(v))throw new a({type:"UnexpectedDeclaration"},t.genTextPos());const s=t.getPos();t.advance(2);const e=t.consumeName();t.skipSpaces();const o=t.consumeCodeUnitsWhile((i,c)=>!(i===x&&c.startsWith(N)));t.skipString(N),n({type:"ProcessingInstruction",target:e,content:o.length===0?void 0:o,range:t.rangeFrom(s)},t)}function U(t,n){if(!t.config.allowDtd)throw new a({type:"DtdDetected"});const s=t.getPos();if(lt(t),t.skipSpaces(),t.currCodeUnit()===r){t.advance(1);return}for(t.advance(1);!t.atEnd();)if(t.skipSpaces(),t.startsWith(Z))ut(t,n);else if(t.startsWith(h))E(t,n);else if(t.startsWith(A))S(t,n);else if(t.startsWith("]"))if(t.advance(1),t.skipSpaces(),t.currCodeUnit()===r){t.advance(1);break}else throw new a({type:"InvalidChar",expected:"'>'",actual:t.currCodeUnitUnchecked()},t.genTextPos());else if(t.startsWith(V)||t.startsWith(tt)||t.startsWith(nt))try{mt(t)}catch(e){throw new a({type:"UnknownToken",message:"Failed to consume declaration"},t.genTextPosFrom(s))}else throw new a({type:"UnknownToken",message:"Failed to parse doctype"},t.genTextPos())}function lt(t){t.advance(9),t.consumeSpaces(),t.skipName(),t.skipSpaces(),_(t),t.skipSpaces();const n=t.currCodeUnit();if(n!==H&&n!==r)throw new a({type:"InvalidChar",expected:"'[' or '>'",actual:n},t.genTextPos())}function _(t){if(t.startsWith(ot)||t.startsWith(F)){const n=t.getPos();t.advance(6);const s=t.sliceBack(n);t.consumeSpaces();const e=t.consumeQuote();if(t.consumeCodeUnitsWhile(o=>o!==e),t.consumeCodeUnit(e),s===F){t.consumeSpaces();const o=t.consumeQuote();t.consumeCodeUnitsWhile(i=>i!==o),t.consumeCodeUnit(o)}return!0}return!1}function ut(t,n){t.advance(8),t.consumeSpaces();const s=!t.tryConsumeCodeUnit(Y);s||t.consumeSpaces();const e=t.consumeName();t.consumeSpaces();const o=dt(t,s);o!==null&&n({type:"EntityDeclaration",name:e,definition:o},t),t.skipSpaces(),t.consumeCodeUnit(r)}function dt(t,n){const s=t.currCodeUnit();if(s===P||s===y){const e=t.consumeQuote(),o=t.getPos();t.skipCodeUnitsWhile(c=>c!==e);const i=t.sliceBack(o);return t.consumeCodeUnit(e),i}else if(s===q||s===z){if(_(t))return n&&(t.skipSpaces(),t.startsWith(et)&&(t.advance(5),t.consumeSpaces(),t.skipName())),null;throw new a({type:"InvalidExternalID"},t.genTextPos())}else throw new a({type:"InvalidChar",expected:"a quote, SYSTEM or PUBLIC",actual:s},t.genTextPos())}function mt(t){t.skipCodeUnitsWhile(n=>n!==r),t.consumeCodeUnit(r)}function k(t,n){const s=t.getPos();t.advance(1);const[e,o]=t.consumeQName();n({type:"ElementStart",prefix:e,local:o,start:s},t);let i=!1;for(;!t.atEnd();){const c=t.startsWithSpace();t.skipSpaces();const p=t.getPos(),T=t.currCodeUnit();if(T===f){t.advance(1),t.consumeCodeUnit(r);const l=t.rangeFrom(p);n({type:"ElementEnd",end:{type:"Empty"},range:l},t);break}else if(T===r){t.advance(1);const l=t.rangeFrom(p);if(t.config.implicitSelfClosingElements!=null&&t.config.implicitSelfClosingElements.includes(w(o,e))){n({type:"ElementEnd",end:{type:"Empty"},range:l},t);break}else{n({type:"ElementEnd",end:{type:"Open"},range:l},t),i=!0;break}}else{if(!c)throw new a({type:"InvalidChar",expected:"a whitespace",actual:t.currCodeUnitUnchecked()},t.genTextPos());const[l,b,B]=m(t),M=t.getPos();n({type:"Attribute",range:{start:p,end:M},prefix:l,local:b,value:B},t)}}if(i){if(t.config.rawTextElements!=null){const c=w(o,e);if(t.config.rawTextElements.includes(c)){L(t,n,`</${c}>`);return}}L(t,n)}}function m(t){const[n,s]=t.consumeQName();let e;const o=t.getPos();if(t.skipSpaces(),t.tryConsumeCodeUnit(W)){t.skipSpaces();const i=t.currCodeUnit();if(i===y||i===P){const c=t.consumeQuote();e=t.consumeCodeUnitsWhile(p=>p!==c&&p!==u),t.consumeCodeUnit(c)}else if(!t.config.strictDocument)e=t.consumeCodeUnitsWhile(c=>!$(c)&&c!==r&&c!==f&&c!==u);else throw new a({type:"InvalidChar",expected:"a quote",actual:i},t.genTextPos())}else if(!t.config.strictDocument)t.goTo(o),e="true";else throw new a({type:"InvalidChar",expected:W,actual:t.currCodeUnit()},t.genTextPos());return[n,s,e]}function L(t,n,s=u){for(;!t.atEnd();)if(R(t,s)){const e=t.nextCodeUnit();if(e===K)if(t.startsWith(h))E(t,n);else if(t.startsWith(st))ft(t,n);else if(!t.config.strictDocument&&t.startsWithIgnoreCase(g))U(t,n);else throw new a({type:"UnknownToken",message:"Failed to parse content"},t.genTextPos());else if(e===x)S(t,n);else if(e===f){gt(t,n);break}else k(t,n)}else O(t,n,s)}function ft(t,n){const s=t.getPos();t.advance(9);const e=t.consumeCodeUnitsWhile((i,c)=>!(i===G&&c.startsWith(C)));t.skipString(C);const o=t.rangeFrom(s);n({type:"Cdata",text:e,range:o},t)}function gt(t,n){const s=t.getPos();t.advance(2);const[e,o]=t.consumeQName();t.skipSpaces(),t.consumeCodeUnit(r);const i=t.rangeFrom(s);n({type:"ElementEnd",end:{type:"Close",prefix:e,local:o},range:i},t)}function O(t,n,s=u){const e=t.getPos(),o=typeof s=="number"?t.consumeCodeUnitsWhile(i=>i!==s):t.consumeCodeUnitsWhile((i,c)=>!R(c,s));if(t.config.strictDocument&&o.includes(C))throw new a({type:"InvalidCharacterData"},t.genTextPos());n({type:"Text",text:o,range:t.rangeFrom(e)},t)}function R(t,n){return typeof n=="number"?t.currCodeUnit()===n:t.config.lowercaseNames?t.startsWithIgnoreCase(n):t.startsWith(n)}export{rt as tokenize,Q as tokenizeXmlStream};
|
package/dist/types/config.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const xmlConfig: TXmlStreamOptions;
|
|
|
6
6
|
/**
|
|
7
7
|
* HTML configuration with HTML-specific settings.
|
|
8
8
|
* - Non-strict document structure
|
|
9
|
+
* - ASCII lowercase element and attribute names
|
|
9
10
|
* - Raw text elements like script and style
|
|
10
11
|
* - Implicit self-closing elements (void elements in HTML)
|
|
11
12
|
*/
|
|
@@ -102,10 +102,10 @@ export declare class XmlStream {
|
|
|
102
102
|
*/
|
|
103
103
|
startsWith(text: string): boolean;
|
|
104
104
|
/**
|
|
105
|
-
* Checks
|
|
105
|
+
* Checks for text at the current position, ignoring ASCII letter case on both sides.
|
|
106
|
+
* Compares non-ASCII characters exactly and leaves the stream position unchanged.
|
|
106
107
|
*
|
|
107
|
-
* @param text - The text to check for
|
|
108
|
-
* @returns True if the stream starts with the text (case-insensitive), false otherwise.
|
|
108
|
+
* @param text - The text to check for, in any letter case.
|
|
109
109
|
*/
|
|
110
110
|
startsWithIgnoreCase(text: string): boolean;
|
|
111
111
|
/**
|
|
@@ -227,6 +227,13 @@ export interface TXmlStreamConfig {
|
|
|
227
227
|
* @default true
|
|
228
228
|
*/
|
|
229
229
|
strictDocument: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Convert ASCII A-Z to a-z in opening-tag, closing-tag, and attribute names, including prefixes.
|
|
232
|
+
* Also match configured raw text closing tags ignoring ASCII case.
|
|
233
|
+
* Preserve non-ASCII characters, text content, attribute values, and source positions.
|
|
234
|
+
* @default false
|
|
235
|
+
*/
|
|
236
|
+
lowercaseNames: boolean;
|
|
230
237
|
/**
|
|
231
238
|
* List of element names that should be treated as raw text elements.
|
|
232
239
|
* Their content will be parsed as text rather than XML.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xml-tokenizer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Streaming XML, HTML, and SVG tokenizer with typed tokens, selectors, and object helpers",
|
|
6
6
|
"keywords": [
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/sax": "^1.2.7",
|
|
41
41
|
"@types/xml2js": "^0.4.14",
|
|
42
|
-
"camaro": "^6.
|
|
43
|
-
"fast-xml-parser": "^5.
|
|
44
|
-
"sax": "^1.6.
|
|
45
|
-
"saxen": "^11.
|
|
46
|
-
"txml": "^6.0.
|
|
42
|
+
"camaro": "^6.7.2",
|
|
43
|
+
"fast-xml-parser": "^5.11.1",
|
|
44
|
+
"sax": "^1.6.1",
|
|
45
|
+
"saxen": "^11.1.1",
|
|
46
|
+
"txml": "^6.0.3",
|
|
47
47
|
"xml2js": "^0.6.2",
|
|
48
|
-
"@blgc/config": "0.1.
|
|
49
|
-
"rollup-presets": "0.0.
|
|
48
|
+
"@blgc/config": "0.1.2",
|
|
49
|
+
"rollup-presets": "0.0.30"
|
|
50
50
|
},
|
|
51
51
|
"size-limit": [
|
|
52
52
|
{
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"clean": "shx rm -rf dist && shx rm -rf .turbo && shx rm -rf node_modules",
|
|
61
61
|
"install:clean": "pnpm run clean && pnpm install",
|
|
62
62
|
"lint": "eslint .",
|
|
63
|
-
"publish:patch": "pnpm build:prod && pnpm version patch && pnpm publish --no-git-checks --access=public",
|
|
63
|
+
"publish:patch": "pnpm build:prod && pnpm version patch --no-git-tag-version && pnpm publish --no-git-checks --access=public",
|
|
64
64
|
"size": "size-limit --why",
|
|
65
65
|
"start:dev": "tsc -w",
|
|
66
66
|
"test": "vitest run",
|