@gw2/markup-parser 1.1.0 → 1.1.1

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.
Files changed (2) hide show
  1. package/dist/parser.js +6 -4
  2. package/package.json +2 -2
package/dist/parser.js CHANGED
@@ -1,4 +1,6 @@
1
- function e(){let e={line:1,column:1,offset:0};return{point:()=>n(e),advance:r=>{let i=n(e);return t(e,r),{start:i,end:n(e)}}}}function t(e,t){for(let n of t)e.offset!==void 0&&(e.offset+=1),n===`
2
- `?(e.line+=1,e.column=1):e.column+=1}function n(e){return{...e}}const r=/^<c([^>]*)>/i,i=/^<\/c([^>]*)>/i,a=/^<br\s*\/?>/i;function o(t,n={}){let o=typeof t==`string`?t:``,c=n.includePosition??!0?e():void 0,l={type:`root`,children:[],position:c?{start:c.point(),end:c.point()}:void 0},u=[],d=()=>u.length?u[u.length-1].children:l.children,f=0;for(;f<o.length;){let e=o.slice(f);if(e[0]===`
3
- `){d().push({type:`break`,position:c?.advance(`
4
- `)}),f+=1;continue}let t=e.match(a);if(t){d().push({type:`break`,position:c?.advance(t[0])}),f+=t[0].length;continue}let n=e.match(r);if(n){let e=s(n[1]?.trim()??``);if(e===``||e===`/`){let e=c?.advance(n[0]),t=u.pop();t&&e&&(t.position.end=e.end),f+=n[0].length;continue}let t={type:`color`,color:e,children:[],position:c?.advance(n[0])};d().push(t),u.push(t),f+=n[0].length;continue}let l=e.match(i);if(l){let e=c?.advance(l[0]),t=u.pop();t&&e&&(t.position.end=e.end),f+=l[0].length;continue}let p=e.slice(1).search(/<|\n/);p===-1?p=e.length:p+=1;let m=e.slice(0,p),h=d(),g=h[h.length-1],_=c?.advance(m);g?.type===`text`?(g.value+=m,_&&(g.position.end=_.end)):h.push({type:`text`,value:m,position:_}),f+=p}if(c){for(let e of u)e.position.end=c.point();l.position.end=c.point()}return l}function s(e){return e.startsWith(`=#`)?`#${e.slice(2)}`:e.startsWith(`=@`)||e.startsWith(`@=`)?`@${e.slice(2)}`:e}export{o as parseGw2Markup};
1
+ function e(){let e={line:1,column:1,offset:0};return{point:()=>n(e),advance:r=>{let i=n(e);return t(e,r),{start:i,end:n(e)}}}}function t(e,t){if(e.offset!==void 0&&(e.offset+=t.length),t===`
2
+ `){e.line+=1,e.column=1;return}if(!t.includes(`
3
+ `)){e.column+=t.length;return}for(let n=0;n<t.length;n++)t.charCodeAt(n)===10?(e.line+=1,e.column=1):e.column+=1}function n(e){return{line:e.line,column:e.column,offset:e.offset}}const r=/^<c([^>]*)>/i,i=/^<\/c([^>]*)>/i,a=/^<br\s*\/?>/i;function o(t,n={}){let o=typeof t==`string`?t:``,c=n.includePosition??!0?e():void 0,l={type:`root`,children:[],position:c?{start:c.point(),end:c.point()}:void 0},u=[],d=l.children,f=0;for(;f<o.length;){let e=o[f];if(e===`
4
+ `){d.push({type:`break`,position:c?.advance(`
5
+ `)}),f+=1;continue}if(e===`<`){let e=o.slice(f),t=e.match(a);if(t){d.push({type:`break`,position:c?.advance(t[0])}),f+=t[0].length;continue}let n=e.match(r);if(n){let e=s(n[1]?.trim()??``);if(e===``||e===`/`){let e=c?.advance(n[0]),t=u.pop();t&&e&&(t.position.end=e.end),d=u.length>0?u[u.length-1].children:l.children,f+=n[0].length;continue}let t={type:`color`,color:e,children:[],position:c?.advance(n[0])};d.push(t),u.push(t),d=t.children,f+=n[0].length;continue}let p=e.match(i);if(p){let e=c?.advance(p[0]),t=u.pop();t&&e&&(t.position.end=e.end),d=u.length>0?u[u.length-1].children:l.children,f+=p[0].length;continue}}let t=o.indexOf(`<`,f+1),n=o.indexOf(`
6
+ `,f+1),p=o.length;t!==-1&&(p=t),n!==-1&&n<p&&(p=n);let m=o.slice(f,p),h=d[d.length-1],g=c?.advance(m);h?.type===`text`?(h.value+=m,g&&(h.position.end=g.end)):d.push({type:`text`,value:m,position:g}),f=p}if(c){for(let e of u)e.position.end=c.point();l.position.end=c.point()}return l}function s(e){return e.startsWith(`=#`)?`#${e.slice(2)}`:e.startsWith(`=@`)||e.startsWith(`@=`)?`@${e.slice(2)}`:e}export{o as parseGw2Markup};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gw2/markup-parser",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Guild Wars 2 markup parser",
5
5
  "keywords": [
6
6
  "gw2",
@@ -36,7 +36,7 @@
36
36
  "url": "https://github.com/gw2treasures/gw2-markup/issues"
37
37
  },
38
38
  "dependencies": {
39
- "@gw2/markup-ast": "^1.0.1"
39
+ "@gw2/markup-ast": "^1.0.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "tsdown": "0.20.3",