@metanorma/mirror 0.1.0-beta.1 → 0.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.
package/README.md CHANGED
@@ -121,12 +121,19 @@ Every node shares the shape `{ type, attrs?, content?, marks?, text? }`. Node ty
121
121
  ```bash
122
122
  npm install
123
123
  npm run build # vite build → dist + .d.ts via vite-plugin-dts
124
+ npm run lint # eslint
124
125
  npm test # vitest unit tests
125
126
  npm run test:e2e # puppeteer e2e
126
127
  npm run test:all # both suites
127
128
  ```
128
129
 
129
- Requires **Node.js 20+**. See [CONTRIBUTING.md](./CONTRIBUTING.md) for release flow and conventions.
130
+ Requires **Node.js 20+**.
131
+
132
+ ### Releases
133
+
134
+ Releases are automated through `.github/workflows/release.yml`. A `v*` tag push, or a `workflow_dispatch` run with a `version` input, runs `npm publish --provenance --access public --tag <dist-tag>` and creates a GitHub release. The dist-tag is derived from the version (`0.1.0` → `latest`, `0.1.0-beta.1` → `beta`, `0.9.0-rc.2` → `rc`).
135
+
136
+ Publishing uses npm's [Trusted Publisher](https://docs.npmjs.com/generating-provenance-statements) (OIDC) — no `NPM_TOKEN` secret is required. The npm package lists this repository's `release.yml` workflow as a Trusted Publisher, and the workflow carries `permissions.id-token: write`, which is what npm's OIDC exchange needs.
130
137
 
131
138
  ## License
132
139
 
@@ -0,0 +1 @@
1
+ "use strict";var Y=Object.create;var l=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var L=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of M(t))!I.call(e,a)&&a!==r&&l(e,a,{get:()=>t[a],enumerable:!(i=h(t,a))||i.enumerable});return e};var O=(e,t,r)=>(r=e!=null?Y(R(e)):{},L(t||!e||!e.__esModule?l(r,"default",{value:e,enumerable:!0}):r,e));const T=["emphasis","strong","subscript","superscript","code","underline","strike","smallcap","link","xref","eref","footnote","stem","concept","bcp14","span"],u=["doc","preface","sections","bibliography"],y=["clause","annex","content_section","abstract","foreword","introduction","acknowledgements","terms","definitions","references"],f=["paragraph","note","admonition","example","sourcecode","formula","quote","review"],m=["bullet_list","ordered_list","list_item","dl","dt","dd"],g=["table","table_head","table_body","table_foot","table_row","table_cell"],_=["figure","image"],E=["footnotes","footnote_marker","footnote_entry"],S=["text","soft_break","floating_title"];function o(e){const t=new Set(e);return r=>t.has(r)}const x=o(T),A=o(u),F=o(y),k=o(f),N=o(m),w=o(g),C=o(_),B=o(E),v=o(S);function H(e){return e.type==="text"}const c=new Map;function s(e,t){c.set(e,t)}const d=100,P=60,p=50,n=10;s("link",{tag:"a",priority:d,extractHref:e=>{var t,r;return((t=e.attrs)==null?void 0:t.target)||((r=e.attrs)==null?void 0:r.href)}});s("xref",{tag:"a",priority:d,extractHref:e=>{var t;return(t=e.attrs)==null?void 0:t.target}});s("footnote",{tag:"sup",priority:P,classes:"mirror-footnote"});s("eref",{tag:"span",priority:P,classes:"mirror-eref"});s("stem",{tag:"span",priority:p,classes:"mirror-stem"});s("concept",{tag:"span",priority:p,classes:"mirror-concept"});s("bcp14",{tag:"span",priority:p,classes:"mirror-bcp14"});s("smallcap",{tag:"span",priority:p,classes:"mirror-smallcap"});s("strong",{tag:"strong",priority:n});s("emphasis",{tag:"em",priority:n});s("code",{tag:"code",priority:n});s("subscript",{tag:"sub",priority:n});s("superscript",{tag:"sup",priority:n});s("underline",{tag:"u",priority:n});s("strike",{tag:"s",priority:n});s("span",{tag:"span"});function K(e){return c.get(e.type)}function U(e){var r;const t=c.get(e.type);return(r=t==null?void 0:t.extractHref)==null?void 0:r.call(t,e)}function D(e){if(!(e!=null&&e.length))return null;let t=null;for(const r of e){const i=c.get(r.type);i&&(!t||(i.priority??0)>(t.renderer.priority??0))&&(t={renderer:i,mark:r})}return t}function b(e){const t=e.attrs??{};return{mathml:t.mathml||null,asciimath:t.asciimath||t.math_text||null,number:t.number||null}}async function q(e){const{mathml:t,asciimath:r}=b(e);if(t)return t;if(r)try{const{default:i}=await import("@plurimath/plurimath");return new i(r,"asciimath").toMathml()}catch{return r}return""}exports.BLOCK_TYPES=f;exports.FOOTNOTE_TYPES=E;exports.LEAF_TYPES=S;exports.LIST_TYPES=m;exports.MARK_TYPES=T;exports.MEDIA_TYPES=_;exports.SECTION_TYPES=y;exports.STRUCTURAL_TYPES=u;exports.TABLE_TYPES=g;exports.extractFormulaAttrs=b;exports.getMarkHref=U;exports.isBlockType=k;exports.isFootnoteType=B;exports.isLeafType=v;exports.isListType=N;exports.isMarkType=x;exports.isMediaType=C;exports.isSectionType=F;exports.isStructuralType=A;exports.isTableType=w;exports.isTextNode=H;exports.register=s;exports.renderFormula=q;exports.resolveFirstMark=D;exports.resolveMark=K;
@@ -0,0 +1,145 @@
1
+ const u = [
2
+ "emphasis",
3
+ "strong",
4
+ "subscript",
5
+ "superscript",
6
+ "code",
7
+ "underline",
8
+ "strike",
9
+ "smallcap",
10
+ "link",
11
+ "xref",
12
+ "eref",
13
+ "footnote",
14
+ "stem",
15
+ "concept",
16
+ "bcp14",
17
+ "span"
18
+ ], f = ["doc", "preface", "sections", "bibliography"], m = [
19
+ "clause",
20
+ "annex",
21
+ "content_section",
22
+ "abstract",
23
+ "foreword",
24
+ "introduction",
25
+ "acknowledgements",
26
+ "terms",
27
+ "definitions",
28
+ "references"
29
+ ], y = [
30
+ "paragraph",
31
+ "note",
32
+ "admonition",
33
+ "example",
34
+ "sourcecode",
35
+ "formula",
36
+ "quote",
37
+ "review"
38
+ ], g = ["bullet_list", "ordered_list", "list_item", "dl", "dt", "dd"], T = ["table", "table_head", "table_body", "table_foot", "table_row", "table_cell"], _ = ["figure", "image"], d = ["footnotes", "footnote_marker", "footnote_entry"], b = ["text", "soft_break", "floating_title"];
39
+ function o(e) {
40
+ const t = new Set(e);
41
+ return (r) => t.has(r);
42
+ }
43
+ const S = o(u), P = o(f), R = o(m), x = o(y), I = o(g), Y = o(T), M = o(_), O = o(d), k = o(b);
44
+ function F(e) {
45
+ return e.type === "text";
46
+ }
47
+ const i = /* @__PURE__ */ new Map();
48
+ function s(e, t) {
49
+ i.set(e, t);
50
+ }
51
+ const p = 100, l = 60, c = 50, a = 10;
52
+ s("link", {
53
+ tag: "a",
54
+ priority: p,
55
+ extractHref: (e) => {
56
+ var t, r;
57
+ return ((t = e.attrs) == null ? void 0 : t.target) || ((r = e.attrs) == null ? void 0 : r.href);
58
+ }
59
+ });
60
+ s("xref", {
61
+ tag: "a",
62
+ priority: p,
63
+ extractHref: (e) => {
64
+ var t;
65
+ return (t = e.attrs) == null ? void 0 : t.target;
66
+ }
67
+ });
68
+ s("footnote", { tag: "sup", priority: l, classes: "mirror-footnote" });
69
+ s("eref", { tag: "span", priority: l, classes: "mirror-eref" });
70
+ s("stem", { tag: "span", priority: c, classes: "mirror-stem" });
71
+ s("concept", { tag: "span", priority: c, classes: "mirror-concept" });
72
+ s("bcp14", { tag: "span", priority: c, classes: "mirror-bcp14" });
73
+ s("smallcap", { tag: "span", priority: c, classes: "mirror-smallcap" });
74
+ s("strong", { tag: "strong", priority: a });
75
+ s("emphasis", { tag: "em", priority: a });
76
+ s("code", { tag: "code", priority: a });
77
+ s("subscript", { tag: "sub", priority: a });
78
+ s("superscript", { tag: "sup", priority: a });
79
+ s("underline", { tag: "u", priority: a });
80
+ s("strike", { tag: "s", priority: a });
81
+ s("span", { tag: "span" });
82
+ function L(e) {
83
+ return i.get(e.type);
84
+ }
85
+ function w(e) {
86
+ var r;
87
+ const t = i.get(e.type);
88
+ return (r = t == null ? void 0 : t.extractHref) == null ? void 0 : r.call(t, e);
89
+ }
90
+ function A(e) {
91
+ if (!(e != null && e.length)) return null;
92
+ let t = null;
93
+ for (const r of e) {
94
+ const n = i.get(r.type);
95
+ n && (!t || (n.priority ?? 0) > (t.renderer.priority ?? 0)) && (t = { renderer: n, mark: r });
96
+ }
97
+ return t;
98
+ }
99
+ function h(e) {
100
+ const t = e.attrs ?? {};
101
+ return {
102
+ mathml: t.mathml || null,
103
+ asciimath: t.asciimath || t.math_text || null,
104
+ number: t.number || null
105
+ };
106
+ }
107
+ async function N(e) {
108
+ const { mathml: t, asciimath: r } = h(e);
109
+ if (t) return t;
110
+ if (r)
111
+ try {
112
+ const { default: n } = await import("@plurimath/plurimath");
113
+ return new n(r, "asciimath").toMathml();
114
+ } catch {
115
+ return r;
116
+ }
117
+ return "";
118
+ }
119
+ export {
120
+ y as B,
121
+ d as F,
122
+ b as L,
123
+ u as M,
124
+ m as S,
125
+ T,
126
+ g as a,
127
+ _ as b,
128
+ f as c,
129
+ O as d,
130
+ h as e,
131
+ k as f,
132
+ w as g,
133
+ I as h,
134
+ x as i,
135
+ S as j,
136
+ M as k,
137
+ R as l,
138
+ P as m,
139
+ Y as n,
140
+ F as o,
141
+ N as p,
142
+ A as q,
143
+ s as r,
144
+ L as s
145
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { MirrorNode, MirrorMark, MirrorDocument, DocumentPart, DocumentManifest, MirrorMarkType, MirrorNodeType, } from './types';
2
- export { MARK_TYPES, STRUCTURAL_TYPES, SECTION_TYPES, BLOCK_TYPES, LIST_TYPES, TABLE_TYPES, MEDIA_TYPES, LEAF_TYPES, } from './types';
2
+ export { MARK_TYPES, STRUCTURAL_TYPES, SECTION_TYPES, BLOCK_TYPES, LIST_TYPES, TABLE_TYPES, MEDIA_TYPES, FOOTNOTE_TYPES, LEAF_TYPES, isMarkType, isStructuralType, isSectionType, isBlockType, isListType, isTableType, isMediaType, isFootnoteType, isLeafType, isTextNode, } from './types';
3
3
  export { getNodeText, findNodes, buildToc, type TocEntry } from './traversal';
4
4
  export { resolveMark, resolveFirstMark, getMarkHref, registerMark, type MarkRenderer } from './marks';
5
5
  export { extractFormulaAttrs, renderFormula, type FormulaDisplay } from './math';
package/dist/marks.d.ts CHANGED
@@ -2,6 +2,7 @@ import { MirrorMark } from './types';
2
2
  export interface MarkRenderer {
3
3
  tag: string;
4
4
  classes?: string;
5
+ priority?: number;
5
6
  extractHref?: (mark: MirrorMark) => string | undefined;
6
7
  }
7
8
  declare function register(type: string, renderer: MarkRenderer): void;
package/dist/mirror.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var _=Object.create;var s=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var p=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!h.call(t,o)&&o!==r&&s(t,o,{get:()=>e[o],enumerable:!(n=S(e,o))||n.enumerable});return t};var P=(t,e,r)=>(r=t!=null?_(b(t)):{},p(e||!t||!t.__esModule?s(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./chunks/marks.cjs"),d=["emphasis","strong","subscript","superscript","code","underline","strike","smallcap","link","xref","eref","footnote","stem","concept","bcp14","span"],Y=["doc","preface","sections","bibliography"],l=["clause","annex","content_section","abstract","foreword","introduction","acknowledgements","terms","definitions","references"],g=["paragraph","note","admonition","example","sourcecode","formula","quote","review"],k=["bullet_list","ordered_list","list_item","dl","dt","dd"],M=["table","table_head","table_body","table_foot","table_row","table_cell"],A=["figure","image"],x=["text","soft_break","floating_title"],L=new Set(l);function u(t){return t.text?t.text:t.content?t.content.map(u).join(""):""}function f(t,e,r=[]){if(e(t)&&r.push(t),t.content)for(const n of t.content)f(n,e,r);return r}function F(t){const e=[];return a(t,0,e),e}function a(t,e,r){var n,o;if(w(t)&&((n=t.attrs)!=null&&n.title)&&((o=t.attrs)!=null&&o.id)){const c=t.attrs.number?`${t.attrs.number} `:"";if(r.push({id:t.attrs.id,title:`${c}${t.attrs.title}`,depth:e}),t.content)for(const T of t.content)a(T,e+1,r);return}if(t.content)for(const c of t.content)a(c,e,r)}function w(t){return L.has(t.type)}function m(t){const e=t.attrs??{};return{mathml:e.mathml||null,asciimath:e.asciimath||e.math_text||null,number:e.number||null}}async function y(t){const{mathml:e,asciimath:r}=m(t);if(e)return e;if(r)try{const{default:n}=await import("@plurimath/plurimath");return new n(r,"asciimath").toMathml()}catch{return r}return""}exports.getMarkHref=i.getMarkHref;exports.registerMark=i.register;exports.resolveFirstMark=i.resolveFirstMark;exports.resolveMark=i.resolveMark;exports.BLOCK_TYPES=g;exports.LEAF_TYPES=x;exports.LIST_TYPES=k;exports.MARK_TYPES=d;exports.MEDIA_TYPES=A;exports.SECTION_TYPES=l;exports.STRUCTURAL_TYPES=Y;exports.TABLE_TYPES=M;exports.buildToc=F;exports.extractFormulaAttrs=m;exports.findNodes=f;exports.getNodeText=u;exports.renderFormula=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/math.cjs");function c(e){return e.text?e.text:e.content?e.content.map(c).join(""):""}function u(e,r){const i=[];return a(e,r,i),i}function a(e,r,i){if(r(e)&&i.push(e),e.content)for(const T of e.content)a(T,r,i)}function E(e){const r=[];return o(e,0,r),r}function o(e,r,i){var T,n;if(t.isSectionType(e.type)&&((T=e.attrs)!=null&&T.title)&&((n=e.attrs)!=null&&n.id)){const s=e.attrs.number?`${e.attrs.number} `:"";if(i.push({id:e.attrs.id,title:`${s}${e.attrs.title}`,depth:r}),e.content)for(const S of e.content)o(S,r+1,i);return}if(e.content)for(const s of e.content)o(s,r,i)}exports.BLOCK_TYPES=t.BLOCK_TYPES;exports.FOOTNOTE_TYPES=t.FOOTNOTE_TYPES;exports.LEAF_TYPES=t.LEAF_TYPES;exports.LIST_TYPES=t.LIST_TYPES;exports.MARK_TYPES=t.MARK_TYPES;exports.MEDIA_TYPES=t.MEDIA_TYPES;exports.SECTION_TYPES=t.SECTION_TYPES;exports.STRUCTURAL_TYPES=t.STRUCTURAL_TYPES;exports.TABLE_TYPES=t.TABLE_TYPES;exports.extractFormulaAttrs=t.extractFormulaAttrs;exports.getMarkHref=t.getMarkHref;exports.isBlockType=t.isBlockType;exports.isFootnoteType=t.isFootnoteType;exports.isLeafType=t.isLeafType;exports.isListType=t.isListType;exports.isMarkType=t.isMarkType;exports.isMediaType=t.isMediaType;exports.isSectionType=t.isSectionType;exports.isStructuralType=t.isStructuralType;exports.isTableType=t.isTableType;exports.isTextNode=t.isTextNode;exports.registerMark=t.register;exports.renderFormula=t.renderFormula;exports.resolveFirstMark=t.resolveFirstMark;exports.resolveMark=t.resolveMark;exports.buildToc=E;exports.findNodes=u;exports.getNodeText=c;
package/dist/mirror.js CHANGED
@@ -1,111 +1,65 @@
1
- import { g as w, r as Y, a as M, b as y } from "./chunks/marks.js";
2
- const p = [
3
- "emphasis",
4
- "strong",
5
- "subscript",
6
- "superscript",
7
- "code",
8
- "underline",
9
- "strike",
10
- "smallcap",
11
- "link",
12
- "xref",
13
- "eref",
14
- "footnote",
15
- "stem",
16
- "concept",
17
- "bcp14",
18
- "span"
19
- ], _ = ["doc", "preface", "sections", "bibliography"], s = [
20
- "clause",
21
- "annex",
22
- "content_section",
23
- "abstract",
24
- "foreword",
25
- "introduction",
26
- "acknowledgements",
27
- "terms",
28
- "definitions",
29
- "references"
30
- ], h = [
31
- "paragraph",
32
- "note",
33
- "admonition",
34
- "example",
35
- "sourcecode",
36
- "formula",
37
- "quote",
38
- "review"
39
- ], T = ["bullet_list", "ordered_list", "list_item", "dl", "dt", "dd"], S = ["table", "table_head", "table_body", "table_foot", "table_row", "table_cell"], E = ["figure", "image"], g = ["text", "soft_break", "floating_title"], l = new Set(s);
40
- function u(t) {
41
- return t.text ? t.text : t.content ? t.content.map(u).join("") : "";
1
+ import { l as c } from "./chunks/math.js";
2
+ import { B as m, F as y, L as F, a as k, M, b as P, S as Y, c as _, T as L, e as x, g as b, i as A, d as N, f as O, h as g, j as h, k as B, m as C, n as I, o as R, r as $, p as j, q as v, s as w } from "./chunks/math.js";
3
+ function f(t) {
4
+ return t.text ? t.text : t.content ? t.content.map(f).join("") : "";
42
5
  }
43
- function f(t, e, r = []) {
44
- if (e(t) && r.push(t), t.content)
45
- for (const n of t.content)
46
- f(n, e, r);
47
- return r;
6
+ function l(t, s) {
7
+ const r = [];
8
+ return n(t, s, r), r;
48
9
  }
49
- function x(t) {
50
- const e = [];
51
- return c(t, 0, e), e;
10
+ function n(t, s, r) {
11
+ if (s(t) && r.push(t), t.content)
12
+ for (const a of t.content)
13
+ n(a, s, r);
14
+ }
15
+ function S(t) {
16
+ const s = [];
17
+ return e(t, 0, s), s;
52
18
  }
53
- function c(t, e, r) {
54
- var n, o;
55
- if (m(t) && ((n = t.attrs) != null && n.title) && ((o = t.attrs) != null && o.id)) {
56
- const a = t.attrs.number ? `${t.attrs.number} ` : "";
19
+ function e(t, s, r) {
20
+ var a, o;
21
+ if (c(t.type) && ((a = t.attrs) != null && a.title) && ((o = t.attrs) != null && o.id)) {
22
+ const i = t.attrs.number ? `${t.attrs.number} ` : "";
57
23
  if (r.push({
58
24
  id: t.attrs.id,
59
- title: `${a}${t.attrs.title}`,
60
- depth: e
25
+ title: `${i}${t.attrs.title}`,
26
+ depth: s
61
27
  }), t.content)
62
- for (const i of t.content)
63
- c(i, e + 1, r);
28
+ for (const T of t.content)
29
+ e(T, s + 1, r);
64
30
  return;
65
31
  }
66
32
  if (t.content)
67
- for (const a of t.content)
68
- c(a, e, r);
69
- }
70
- function m(t) {
71
- return l.has(t.type);
72
- }
73
- function b(t) {
74
- const e = t.attrs ?? {};
75
- return {
76
- mathml: e.mathml || null,
77
- asciimath: e.asciimath || e.math_text || null,
78
- number: e.number || null
79
- };
80
- }
81
- async function d(t) {
82
- const { mathml: e, asciimath: r } = b(t);
83
- if (e) return e;
84
- if (r)
85
- try {
86
- const { default: n } = await import("@plurimath/plurimath");
87
- return new n(r, "asciimath").toMathml();
88
- } catch {
89
- return r;
90
- }
91
- return "";
33
+ for (const i of t.content)
34
+ e(i, s, r);
92
35
  }
93
36
  export {
94
- h as BLOCK_TYPES,
95
- g as LEAF_TYPES,
96
- T as LIST_TYPES,
97
- p as MARK_TYPES,
98
- E as MEDIA_TYPES,
99
- s as SECTION_TYPES,
37
+ m as BLOCK_TYPES,
38
+ y as FOOTNOTE_TYPES,
39
+ F as LEAF_TYPES,
40
+ k as LIST_TYPES,
41
+ M as MARK_TYPES,
42
+ P as MEDIA_TYPES,
43
+ Y as SECTION_TYPES,
100
44
  _ as STRUCTURAL_TYPES,
101
- S as TABLE_TYPES,
102
- x as buildToc,
103
- b as extractFormulaAttrs,
104
- f as findNodes,
105
- w as getMarkHref,
106
- u as getNodeText,
107
- Y as registerMark,
108
- d as renderFormula,
109
- M as resolveFirstMark,
110
- y as resolveMark
45
+ L as TABLE_TYPES,
46
+ S as buildToc,
47
+ x as extractFormulaAttrs,
48
+ l as findNodes,
49
+ b as getMarkHref,
50
+ f as getNodeText,
51
+ A as isBlockType,
52
+ N as isFootnoteType,
53
+ O as isLeafType,
54
+ g as isListType,
55
+ h as isMarkType,
56
+ B as isMediaType,
57
+ c as isSectionType,
58
+ C as isStructuralType,
59
+ I as isTableType,
60
+ R as isTextNode,
61
+ $ as registerMark,
62
+ j as renderFormula,
63
+ v as resolveFirstMark,
64
+ w as resolveMark
111
65
  };
@@ -1,6 +1,6 @@
1
1
  import { MirrorNode } from './types';
2
2
  export declare function getNodeText(node: MirrorNode): string;
3
- export declare function findNodes(node: MirrorNode, predicate: (n: MirrorNode) => boolean, results?: MirrorNode[]): MirrorNode[];
3
+ export declare function findNodes(node: MirrorNode, predicate: (n: MirrorNode) => boolean): MirrorNode[];
4
4
  export interface TocEntry {
5
5
  id: string;
6
6
  title: string;
package/dist/types.d.ts CHANGED
@@ -20,6 +20,16 @@ export interface MirrorNode {
20
20
  marks?: MirrorMark[];
21
21
  text?: string;
22
22
  }
23
+ export declare const isMarkType: (type: string) => type is "emphasis" | "strong" | "subscript" | "superscript" | "code" | "underline" | "strike" | "smallcap" | "link" | "xref" | "eref" | "footnote" | "stem" | "concept" | "bcp14" | "span";
24
+ export declare const isStructuralType: (type: string) => type is "doc" | "preface" | "sections" | "bibliography";
25
+ export declare const isSectionType: (type: string) => type is "clause" | "annex" | "content_section" | "abstract" | "foreword" | "introduction" | "acknowledgements" | "terms" | "definitions" | "references";
26
+ export declare const isBlockType: (type: string) => type is "paragraph" | "note" | "admonition" | "example" | "sourcecode" | "formula" | "quote" | "review";
27
+ export declare const isListType: (type: string) => type is "bullet_list" | "ordered_list" | "list_item" | "dl" | "dt" | "dd";
28
+ export declare const isTableType: (type: string) => type is "table" | "table_head" | "table_body" | "table_foot" | "table_row" | "table_cell";
29
+ export declare const isMediaType: (type: string) => type is "figure" | "image";
30
+ export declare const isFootnoteType: (type: string) => type is "footnotes" | "footnote_marker" | "footnote_entry";
31
+ export declare const isLeafType: (type: string) => type is "text" | "soft_break" | "floating_title";
32
+ export declare function isTextNode(node: MirrorNode): boolean;
23
33
  export type MirrorDocument = MirrorNode;
24
34
  export interface DocumentPart {
25
35
  id: string;
package/dist/vue.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),F=require("./chunks/marks.cjs"),N=["href"],V={key:2},C={key:3},$={key:4},M={key:5},w={key:6},T={key:7},q={key:8},H={key:9,class:"mirror-smallcap"},z={key:10,class:"mirror-stem"},j={key:11,class:"mirror-footnote"},O={key:12,class:"mirror-concept"},P={key:13,class:"mirror-bcp14"},R={key:14,class:"mirror-eref"},A={key:15},L=e.defineComponent({__name:"MirrorText",props:{text:{},marks:{}},setup(t){const k=t;function c(l){var a;return!!((a=k.marks)!=null&&a.some(r=>r.type===l))}function d(){if(!k.marks)return;const l=k.marks.find(r=>r.type==="link"),a=k.marks.find(r=>r.type==="xref");return F.getMarkHref(l||a)}return(l,a)=>{var r;return(r=t.marks)!=null&&r.length?c("link")||c("xref")?(e.openBlock(),e.createElementBlock("a",{key:1,href:d()},e.toDisplayString(t.text),9,N)):c("strong")?(e.openBlock(),e.createElementBlock("strong",V,e.toDisplayString(t.text),1)):c("emphasis")?(e.openBlock(),e.createElementBlock("em",C,e.toDisplayString(t.text),1)):c("code")?(e.openBlock(),e.createElementBlock("code",$,e.toDisplayString(t.text),1)):c("subscript")?(e.openBlock(),e.createElementBlock("sub",M,e.toDisplayString(t.text),1)):c("superscript")?(e.openBlock(),e.createElementBlock("sup",w,e.toDisplayString(t.text),1)):c("underline")?(e.openBlock(),e.createElementBlock("u",T,e.toDisplayString(t.text),1)):c("strike")?(e.openBlock(),e.createElementBlock("s",q,e.toDisplayString(t.text),1)):c("smallcap")?(e.openBlock(),e.createElementBlock("span",H,e.toDisplayString(t.text),1)):c("stem")?(e.openBlock(),e.createElementBlock("span",z,e.toDisplayString(t.text),1)):c("footnote")?(e.openBlock(),e.createElementBlock("sup",j,e.toDisplayString(t.text),1)):c("concept")?(e.openBlock(),e.createElementBlock("span",O,e.toDisplayString(t.text),1)):c("bcp14")?(e.openBlock(),e.createElementBlock("span",P,e.toDisplayString(t.text),1)):c("eref")?(e.openBlock(),e.createElementBlock("span",R,e.toDisplayString(t.text),1)):(e.openBlock(),e.createElementBlock("span",A,e.toDisplayString(t.text),1)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(t.text),1)],64))}}}),G={key:1,class:"mirror-doc"},I={key:2,class:"mirror-preface"},J={key:3,class:"mirror-sections"},K={key:4,class:"mirror-bibliography"},Q=["id"],U={key:0,class:"mirror-number"},W={key:6,class:"mirror-paragraph"},X={key:7,class:"mirror-note"},Y=["data-admonition-type"],Z={key:0,class:"mirror-admonition-label"},_={key:9,class:"mirror-example"},ee={key:10,class:"mirror-quote"},te={key:11,class:"mirror-review"},ne={key:12,class:"mirror-figure"},oe={key:0,class:"mirror-figure-caption"},le={key:0,class:"mirror-number"},ce={key:13,class:"mirror-image"},re=["src","alt"],de={key:14,class:"mirror-table"},ae={key:0,class:"mirror-table-title"},ke={key:0,class:"mirror-number"},ie={key:15},me={key:16},se={key:17},Be={key:18},ue=["colspan","rowspan"],ye={key:20,class:"mirror-formula"},he=["innerHTML"],Ee={key:1,class:"mirror-formula-content"},ge={key:2,class:"mirror-formula-content"},pe={key:3,class:"mirror-formula-number"},fe={key:21,class:"mirror-sourcecode"},be={key:22,class:"mirror-bullet-list"},xe={key:23,class:"mirror-ordered-list"},ve={key:24,class:"mirror-list-item"},De={key:25,class:"mirror-dl"},Se={key:26,class:"mirror-dt"},Le={key:27,class:"mirror-dd"},Fe={key:28,class:"mirror-footnotes"},Ne={key:29,class:"mirror-footnote-entry"},Ve={key:31},Ce=e.defineComponent({name:"MirrorNode",__name:"MirrorNode",props:{node:{},depth:{}},setup(t){function k(c){return"h"+Math.min(c+1,6)}return(c,d)=>{var a,r,i,m,s,B,u,y,h,E,g,p,f,b,x,v,D,S;const l=e.resolveComponent("MirrorNode",!0);return t.node.type==="text"?(e.openBlock(),e.createBlock(L,{key:0,text:t.node.text??"",marks:t.node.marks},null,8,["text","marks"])):t.node.type==="doc"?(e.openBlock(),e.createElementBlock("article",G,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth??0},null,8,["node","depth"]))),128))])):t.node.type==="preface"?(e.openBlock(),e.createElementBlock("div",I,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:(t.depth??0)+1},null,8,["node","depth"]))),128))])):t.node.type==="sections"?(e.openBlock(),e.createElementBlock("div",J,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:(t.depth??0)+1},null,8,["node","depth"]))),128))])):t.node.type==="bibliography"?(e.openBlock(),e.createElementBlock("div",K,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:(t.depth??0)+1},null,8,["node","depth"]))),128))])):"clause annex content_section abstract foreword introduction acknowledgements terms definitions references".split(" ").includes(t.node.type)?(e.openBlock(),e.createElementBlock("section",{key:5,class:e.normalizeClass(["mirror-section","mirror-"+t.node.type]),id:((a=t.node.attrs)==null?void 0:a.id)||void 0},[(r=t.node.attrs)!=null&&r.title?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k(t.depth??1)),{key:0,class:"mirror-heading"},{default:e.withCtx(()=>{var n;return[(n=t.node.attrs)!=null&&n.number?(e.openBlock(),e.createElementBlock("span",U,e.toDisplayString(t.node.attrs.number)+" ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(t.node.attrs.title),1)]}),_:1})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:(t.depth??1)+1},null,8,["node","depth"]))),128))],10,Q)):t.node.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",W,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n},null,8,["node"]))),128))])):t.node.type==="note"?(e.openBlock(),e.createElementBlock("div",X,[d[0]||(d[0]=e.createElementVNode("div",{class:"mirror-note-label"},"Note",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="admonition"?(e.openBlock(),e.createElementBlock("div",{key:8,class:"mirror-admonition","data-admonition-type":((i=t.node.attrs)==null?void 0:i.type)||"note"},[(m=t.node.attrs)!=null&&m.type?(e.openBlock(),e.createElementBlock("div",Z,e.toDisplayString(t.node.attrs.type),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))],8,Y)):t.node.type==="example"?(e.openBlock(),e.createElementBlock("div",_,[d[1]||(d[1]=e.createElementVNode("div",{class:"mirror-example-label"},"Example",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="quote"?(e.openBlock(),e.createElementBlock("blockquote",ee,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="review"?(e.openBlock(),e.createElementBlock("div",te,[d[2]||(d[2]=e.createElementVNode("div",{class:"mirror-review-label"},"Review",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="figure"?(e.openBlock(),e.createElementBlock("figure",ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128)),(s=t.node.attrs)!=null&&s.title?(e.openBlock(),e.createElementBlock("figcaption",oe,[(B=t.node.attrs)!=null&&B.number?(e.openBlock(),e.createElementBlock("span",le,e.toDisplayString(t.node.attrs.number)+" ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(t.node.attrs.title),1)])):e.createCommentVNode("",!0)])):t.node.type==="image"?(e.openBlock(),e.createElementBlock("div",ce,[(u=t.node.attrs)!=null&&u.src?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.node.attrs.src,alt:((y=t.node.attrs)==null?void 0:y.alt)||""},null,8,re)):e.createCommentVNode("",!0)])):t.node.type==="table"?(e.openBlock(),e.createElementBlock("div",de,[(h=t.node.attrs)!=null&&h.title?(e.openBlock(),e.createElementBlock("div",ae,[(E=t.node.attrs)!=null&&E.number?(e.openBlock(),e.createElementBlock("span",ke,e.toDisplayString(t.node.attrs.number)+" ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(t.node.attrs.title),1)])):e.createCommentVNode("",!0),e.createElementVNode("table",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])])):t.node.type==="table_head"?(e.openBlock(),e.createElementBlock("thead",ie,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="table_body"?(e.openBlock(),e.createElementBlock("tbody",me,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="table_foot"?(e.openBlock(),e.createElementBlock("tfoot",se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="table_row"?(e.openBlock(),e.createElementBlock("tr",Be,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="table_cell"?(e.openBlock(),e.createElementBlock("td",{key:19,colspan:((g=t.node.attrs)==null?void 0:g.colspan)||void 0,rowspan:((p=t.node.attrs)==null?void 0:p.rowspan)||void 0},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))],8,ue)):t.node.type==="formula"?(e.openBlock(),e.createElementBlock("div",ye,[(f=t.node.attrs)!=null&&f.mathml?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mirror-formula-content",innerHTML:t.node.attrs.mathml},null,8,he)):(b=t.node.attrs)!=null&&b.asciimath?(e.openBlock(),e.createElementBlock("span",Ee,e.toDisplayString(t.node.attrs.asciimath),1)):(x=t.node.attrs)!=null&&x.math_text?(e.openBlock(),e.createElementBlock("span",ge,e.toDisplayString(t.node.attrs.math_text),1)):e.createCommentVNode("",!0),(v=t.node.attrs)!=null&&v.number?(e.openBlock(),e.createElementBlock("span",pe,"("+e.toDisplayString(t.node.attrs.number)+")",1)):e.createCommentVNode("",!0)])):t.node.type==="sourcecode"?(e.openBlock(),e.createElementBlock("pre",fe,[e.createElementVNode("code",null,e.toDisplayString((D=t.node.attrs)==null?void 0:D.text),1)])):t.node.type==="bullet_list"?(e.openBlock(),e.createElementBlock("ul",be,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="ordered_list"?(e.openBlock(),e.createElementBlock("ol",xe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="list_item"?(e.openBlock(),e.createElementBlock("li",ve,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="dl"?(e.openBlock(),e.createElementBlock("dl",De,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="dt"?(e.openBlock(),e.createElementBlock("dt",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="dd"?(e.openBlock(),e.createElementBlock("dd",Le,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="footnotes"?(e.openBlock(),e.createElementBlock("div",Fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="footnote_entry"?(e.openBlock(),e.createElementBlock("div",Ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="floating_title"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k((t.depth??2)+1)),{key:30,class:"mirror-floating-title"},{default:e.withCtx(()=>{var n;return[e.createTextVNode(e.toDisplayString((n=t.node.attrs)==null?void 0:n.title),1)]}),_:1})):t.node.type==="soft_break"?(e.openBlock(),e.createElementBlock("br",Ve)):(S=t.node.content)!=null&&S.length?(e.openBlock(),e.createElementBlock("div",{key:32,class:e.normalizeClass("mirror-"+t.node.type)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))],2)):e.createCommentVNode("",!0)}}});exports.MirrorNode=Ce;exports.MirrorText=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),k=require("./chunks/math.cjs"),V=e.defineComponent({__name:"MirrorText",props:{text:{},marks:{}},setup(t){const a=t,c=e.computed(()=>k.resolveFirstMark(a.marks)),r=e.computed(()=>c.value?k.getMarkHref(c.value.mark):void 0);return(i,d)=>c.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.value.renderer.tag),{key:1,href:r.value,class:e.normalizeClass(c.value.renderer.classes)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.text),1)]),_:1},8,["href","class"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(t.text),1)],64))}}),D={key:1,class:"mirror-doc"},S={key:2,class:"mirror-preface"},M={key:3,class:"mirror-sections"},T={key:4,class:"mirror-bibliography"},w=["id"],q={key:0,class:"mirror-number"},z={key:6,class:"mirror-paragraph"},H={key:7,class:"mirror-note"},j=["data-admonition-type"],A={key:0,class:"mirror-admonition-label"},O={key:9,class:"mirror-example"},P={key:10,class:"mirror-quote"},R={key:11,class:"mirror-review"},$={key:12,class:"mirror-figure"},G={key:0,class:"mirror-figure-caption"},I={key:0,class:"mirror-number"},J={key:13,class:"mirror-image"},K=["src","alt"],Q={key:14,class:"mirror-table"},U={key:0,class:"mirror-table-title"},W={key:0,class:"mirror-number"},X={key:15},Y={key:16},Z={key:17},_={key:18},ee=["colspan","rowspan"],te={key:20,class:"mirror-formula"},ne=["innerHTML"],oe={key:1,class:"mirror-formula-content"},le={key:2,class:"mirror-formula-number"},ce={key:21,class:"mirror-sourcecode"},re={key:22,class:"mirror-bullet-list"},de={key:23,class:"mirror-ordered-list"},ae={key:24,class:"mirror-list-item"},ke={key:25,class:"mirror-dl"},ie={key:26,class:"mirror-dt"},me={key:27,class:"mirror-dd"},Be={key:28,class:"mirror-footnotes"},ue={key:29,class:"mirror-footnote-entry"},se={key:31},he=e.defineComponent({name:"MirrorNode",__name:"MirrorNode",props:{node:{},depth:{}},setup(t){const a=t;function c(i){return"h"+Math.min(i+1,6)}const r=e.computed(()=>a.node.type==="formula"?k.extractFormulaAttrs(a.node):null);return(i,d)=>{var m,B,u,s,h,y,E,g,p,v,b,f,F,L,N,x,C;const l=e.resolveComponent("MirrorNode",!0);return t.node.type==="text"?(e.openBlock(),e.createBlock(V,{key:0,text:t.node.text??"",marks:t.node.marks},null,8,["text","marks"])):t.node.type==="doc"?(e.openBlock(),e.createElementBlock("article",D,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth??0},null,8,["node","depth"]))),128))])):t.node.type==="preface"?(e.openBlock(),e.createElementBlock("div",S,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:(t.depth??0)+1},null,8,["node","depth"]))),128))])):t.node.type==="sections"?(e.openBlock(),e.createElementBlock("div",M,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:(t.depth??0)+1},null,8,["node","depth"]))),128))])):t.node.type==="bibliography"?(e.openBlock(),e.createElementBlock("div",T,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:(t.depth??0)+1},null,8,["node","depth"]))),128))])):e.unref(k.isSectionType)(t.node.type)?(e.openBlock(),e.createElementBlock("section",{key:5,id:((m=t.node.attrs)==null?void 0:m.id)||void 0,class:e.normalizeClass(["mirror-section","mirror-"+t.node.type])},[(B=t.node.attrs)!=null&&B.title?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c(t.depth??1)),{key:0,class:"mirror-heading"},{default:e.withCtx(()=>{var n;return[(n=t.node.attrs)!=null&&n.number?(e.openBlock(),e.createElementBlock("span",q,e.toDisplayString(t.node.attrs.number)+" ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(t.node.attrs.title),1)]}),_:1})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:(t.depth??1)+1},null,8,["node","depth"]))),128))],10,w)):t.node.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",z,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n},null,8,["node"]))),128))])):t.node.type==="note"?(e.openBlock(),e.createElementBlock("div",H,[d[0]||(d[0]=e.createElementVNode("div",{class:"mirror-note-label"},"Note",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="admonition"?(e.openBlock(),e.createElementBlock("div",{key:8,class:"mirror-admonition","data-admonition-type":((u=t.node.attrs)==null?void 0:u.type)||"note"},[(s=t.node.attrs)!=null&&s.type?(e.openBlock(),e.createElementBlock("div",A,e.toDisplayString(t.node.attrs.type),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))],8,j)):t.node.type==="example"?(e.openBlock(),e.createElementBlock("div",O,[d[1]||(d[1]=e.createElementVNode("div",{class:"mirror-example-label"},"Example",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="quote"?(e.openBlock(),e.createElementBlock("blockquote",P,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="review"?(e.openBlock(),e.createElementBlock("div",R,[d[2]||(d[2]=e.createElementVNode("div",{class:"mirror-review-label"},"Review",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="figure"?(e.openBlock(),e.createElementBlock("figure",$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128)),(h=t.node.attrs)!=null&&h.title?(e.openBlock(),e.createElementBlock("figcaption",G,[(y=t.node.attrs)!=null&&y.number?(e.openBlock(),e.createElementBlock("span",I,e.toDisplayString(t.node.attrs.number)+" ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(t.node.attrs.title),1)])):e.createCommentVNode("",!0)])):t.node.type==="image"?(e.openBlock(),e.createElementBlock("div",J,[(E=t.node.attrs)!=null&&E.src?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.node.attrs.src,alt:((g=t.node.attrs)==null?void 0:g.alt)||""},null,8,K)):e.createCommentVNode("",!0)])):t.node.type==="table"?(e.openBlock(),e.createElementBlock("div",Q,[(p=t.node.attrs)!=null&&p.title?(e.openBlock(),e.createElementBlock("div",U,[(v=t.node.attrs)!=null&&v.number?(e.openBlock(),e.createElementBlock("span",W,e.toDisplayString(t.node.attrs.number)+" ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(t.node.attrs.title),1)])):e.createCommentVNode("",!0),e.createElementVNode("table",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])])):t.node.type==="table_head"?(e.openBlock(),e.createElementBlock("thead",X,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="table_body"?(e.openBlock(),e.createElementBlock("tbody",Y,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="table_foot"?(e.openBlock(),e.createElementBlock("tfoot",Z,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="table_row"?(e.openBlock(),e.createElementBlock("tr",_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="table_cell"?(e.openBlock(),e.createElementBlock("td",{key:19,colspan:((b=t.node.attrs)==null?void 0:b.colspan)||void 0,rowspan:((f=t.node.attrs)==null?void 0:f.rowspan)||void 0},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))],8,ee)):t.node.type==="formula"?(e.openBlock(),e.createElementBlock("div",te,[(F=r.value)!=null&&F.mathml?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mirror-formula-content",innerHTML:r.value.mathml},null,8,ne)):(L=r.value)!=null&&L.asciimath?(e.openBlock(),e.createElementBlock("span",oe,e.toDisplayString(r.value.asciimath),1)):e.createCommentVNode("",!0),(N=r.value)!=null&&N.number?(e.openBlock(),e.createElementBlock("span",le,"("+e.toDisplayString(r.value.number)+")",1)):e.createCommentVNode("",!0)])):t.node.type==="sourcecode"?(e.openBlock(),e.createElementBlock("pre",ce,[e.createElementVNode("code",null,e.toDisplayString((x=t.node.attrs)==null?void 0:x.text),1)])):t.node.type==="bullet_list"?(e.openBlock(),e.createElementBlock("ul",re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="ordered_list"?(e.openBlock(),e.createElementBlock("ol",de,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="list_item"?(e.openBlock(),e.createElementBlock("li",ae,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="dl"?(e.openBlock(),e.createElementBlock("dl",ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="dt"?(e.openBlock(),e.createElementBlock("dt",ie,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="dd"?(e.openBlock(),e.createElementBlock("dd",me,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="footnotes"?(e.openBlock(),e.createElementBlock("div",Be,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="footnote_entry"?(e.openBlock(),e.createElementBlock("div",ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))])):t.node.type==="floating_title"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c((t.depth??2)+1)),{key:30,class:"mirror-floating-title"},{default:e.withCtx(()=>{var n;return[e.createTextVNode(e.toDisplayString((n=t.node.attrs)==null?void 0:n.title),1)]}),_:1})):t.node.type==="soft_break"?(e.openBlock(),e.createElementBlock("br",se)):(C=t.node.content)!=null&&C.length?(e.openBlock(),e.createElementBlock("div",{key:32,class:e.normalizeClass("mirror-"+t.node.type)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.content,(n,o)=>(e.openBlock(),e.createBlock(l,{key:o,node:n,depth:t.depth},null,8,["node","depth"]))),128))],2)):e.createCommentVNode("",!0)}}});exports.MirrorNode=he;exports.MirrorText=V;
package/dist/vue.js CHANGED
@@ -1,144 +1,117 @@
1
- import { defineComponent as S, openBlock as t, createElementBlock as n, Fragment as i, createTextVNode as b, toDisplayString as a, resolveComponent as j, createBlock as l, renderList as s, normalizeClass as z, resolveDynamicComponent as F, withCtx as R, createCommentVNode as h, createElementVNode as f } from "vue";
2
- import { g as A } from "./chunks/marks.js";
3
- const G = ["href"], I = { key: 2 }, J = { key: 3 }, K = { key: 4 }, O = { key: 5 }, P = { key: 6 }, Q = { key: 7 }, U = { key: 8 }, W = {
4
- key: 9,
5
- class: "mirror-smallcap"
6
- }, X = {
7
- key: 10,
8
- class: "mirror-stem"
9
- }, Y = {
10
- key: 11,
11
- class: "mirror-footnote"
12
- }, Z = {
13
- key: 12,
14
- class: "mirror-concept"
15
- }, p = {
16
- key: 13,
17
- class: "mirror-bcp14"
18
- }, _ = {
19
- key: 14,
20
- class: "mirror-eref"
21
- }, ee = { key: 15 }, te = /* @__PURE__ */ S({
1
+ import { defineComponent as j, computed as b, openBlock as t, createElementBlock as n, Fragment as r, createTextVNode as m, toDisplayString as u, createBlock as l, resolveDynamicComponent as g, normalizeClass as x, withCtx as M, resolveComponent as G, renderList as a, unref as I, createCommentVNode as c, createElementVNode as k } from "vue";
2
+ import { q as J, g as K, e as O, l as P } from "./chunks/math.js";
3
+ const Q = /* @__PURE__ */ j({
22
4
  __name: "MirrorText",
23
5
  props: {
24
6
  text: {},
25
7
  marks: {}
26
8
  },
27
9
  setup(e) {
28
- const k = e;
29
- function c(r) {
30
- var m;
31
- return !!((m = k.marks) != null && m.some((u) => u.type === r));
32
- }
33
- function y() {
34
- if (!k.marks) return;
35
- const r = k.marks.find((u) => u.type === "link"), m = k.marks.find((u) => u.type === "xref");
36
- return A(r || m);
37
- }
38
- return (r, m) => {
39
- var u;
40
- return (u = e.marks) != null && u.length ? c("link") || c("xref") ? (t(), n("a", {
41
- key: 1,
42
- href: y()
43
- }, a(e.text), 9, G)) : c("strong") ? (t(), n("strong", I, a(e.text), 1)) : c("emphasis") ? (t(), n("em", J, a(e.text), 1)) : c("code") ? (t(), n("code", K, a(e.text), 1)) : c("subscript") ? (t(), n("sub", O, a(e.text), 1)) : c("superscript") ? (t(), n("sup", P, a(e.text), 1)) : c("underline") ? (t(), n("u", Q, a(e.text), 1)) : c("strike") ? (t(), n("s", U, a(e.text), 1)) : c("smallcap") ? (t(), n("span", W, a(e.text), 1)) : c("stem") ? (t(), n("span", X, a(e.text), 1)) : c("footnote") ? (t(), n("sup", Y, a(e.text), 1)) : c("concept") ? (t(), n("span", Z, a(e.text), 1)) : c("bcp14") ? (t(), n("span", p, a(e.text), 1)) : c("eref") ? (t(), n("span", _, a(e.text), 1)) : (t(), n("span", ee, a(e.text), 1)) : (t(), n(i, { key: 0 }, [
44
- b(a(e.text), 1)
45
- ], 64));
46
- };
10
+ const v = e, s = b(() => J(v.marks)), h = b(() => s.value ? K(s.value.mark) : void 0);
11
+ return (f, y) => s.value ? (t(), l(g(s.value.renderer.tag), {
12
+ key: 1,
13
+ href: h.value,
14
+ class: x(s.value.renderer.classes)
15
+ }, {
16
+ default: M(() => [
17
+ m(u(e.text), 1)
18
+ ]),
19
+ _: 1
20
+ }, 8, ["href", "class"])) : (t(), n(r, { key: 0 }, [
21
+ m(u(e.text), 1)
22
+ ], 64));
47
23
  }
48
- }), ne = {
24
+ }), U = {
49
25
  key: 1,
50
26
  class: "mirror-doc"
51
- }, de = {
27
+ }, W = {
52
28
  key: 2,
53
29
  class: "mirror-preface"
54
- }, oe = {
30
+ }, X = {
55
31
  key: 3,
56
32
  class: "mirror-sections"
57
- }, re = {
33
+ }, Y = {
58
34
  key: 4,
59
35
  class: "mirror-bibliography"
60
- }, le = ["id"], ie = {
36
+ }, Z = ["id"], p = {
61
37
  key: 0,
62
38
  class: "mirror-number"
63
- }, ae = {
39
+ }, _ = {
64
40
  key: 6,
65
41
  class: "mirror-paragraph"
66
- }, se = {
42
+ }, ee = {
67
43
  key: 7,
68
44
  class: "mirror-note"
69
- }, ce = ["data-admonition-type"], ue = {
45
+ }, te = ["data-admonition-type"], ne = {
70
46
  key: 0,
71
47
  class: "mirror-admonition-label"
72
- }, he = {
48
+ }, de = {
73
49
  key: 9,
74
50
  class: "mirror-example"
75
- }, ye = {
51
+ }, oe = {
76
52
  key: 10,
77
53
  class: "mirror-quote"
78
- }, me = {
54
+ }, le = {
79
55
  key: 11,
80
56
  class: "mirror-review"
81
- }, ke = {
57
+ }, re = {
82
58
  key: 12,
83
59
  class: "mirror-figure"
84
- }, fe = {
60
+ }, ie = {
85
61
  key: 0,
86
62
  class: "mirror-figure-caption"
87
- }, be = {
63
+ }, ae = {
88
64
  key: 0,
89
65
  class: "mirror-number"
90
- }, xe = {
66
+ }, ue = {
91
67
  key: 13,
92
68
  class: "mirror-image"
93
- }, ve = ["src", "alt"], ge = {
69
+ }, ce = ["src", "alt"], se = {
94
70
  key: 14,
95
71
  class: "mirror-table"
96
- }, $e = {
72
+ }, he = {
97
73
  key: 0,
98
74
  class: "mirror-table-title"
99
- }, Me = {
75
+ }, ye = {
100
76
  key: 0,
101
77
  class: "mirror-number"
102
- }, we = { key: 15 }, Ne = { key: 16 }, Ce = { key: 17 }, Te = { key: 18 }, He = ["colspan", "rowspan"], qe = {
78
+ }, me = { key: 15 }, ke = { key: 16 }, ve = { key: 17 }, fe = { key: 18 }, be = ["colspan", "rowspan"], ge = {
103
79
  key: 20,
104
80
  class: "mirror-formula"
105
- }, Be = ["innerHTML"], Ee = {
81
+ }, xe = ["innerHTML"], Me = {
106
82
  key: 1,
107
83
  class: "mirror-formula-content"
108
- }, Le = {
84
+ }, we = {
109
85
  key: 2,
110
- class: "mirror-formula-content"
111
- }, Ve = {
112
- key: 3,
113
86
  class: "mirror-formula-number"
114
- }, De = {
87
+ }, Ne = {
115
88
  key: 21,
116
89
  class: "mirror-sourcecode"
117
- }, ze = {
90
+ }, Te = {
118
91
  key: 22,
119
92
  class: "mirror-bullet-list"
120
- }, Fe = {
93
+ }, Ce = {
121
94
  key: 23,
122
95
  class: "mirror-ordered-list"
123
- }, Re = {
96
+ }, qe = {
124
97
  key: 24,
125
98
  class: "mirror-list-item"
126
- }, Se = {
99
+ }, Be = {
127
100
  key: 25,
128
101
  class: "mirror-dl"
129
- }, je = {
102
+ }, Ee = {
130
103
  key: 26,
131
104
  class: "mirror-dt"
132
- }, Ae = {
105
+ }, Fe = {
133
106
  key: 27,
134
107
  class: "mirror-dd"
135
- }, Ge = {
108
+ }, He = {
136
109
  key: 28,
137
110
  class: "mirror-footnotes"
138
- }, Ie = {
111
+ }, Le = {
139
112
  key: 29,
140
113
  class: "mirror-footnote-entry"
141
- }, Je = { key: 31 }, Pe = /* @__PURE__ */ S({
114
+ }, Ve = { key: 31 }, ze = /* @__PURE__ */ j({
142
115
  name: "MirrorNode",
143
116
  __name: "MirrorNode",
144
117
  props: {
@@ -146,71 +119,73 @@ const G = ["href"], I = { key: 2 }, J = { key: 3 }, K = { key: 4 }, O = { key: 5
146
119
  depth: {}
147
120
  },
148
121
  setup(e) {
149
- function k(c) {
150
- return "h" + Math.min(c + 1, 6);
122
+ const v = e;
123
+ function s(f) {
124
+ return "h" + Math.min(f + 1, 6);
151
125
  }
152
- return (c, y) => {
153
- var m, u, x, v, g, $, M, w, N, C, T, H, q, B, E, L, V, D;
154
- const r = j("MirrorNode", !0);
155
- return e.node.type === "text" ? (t(), l(te, {
126
+ const h = b(() => v.node.type === "formula" ? O(v.node) : null);
127
+ return (f, y) => {
128
+ var w, N, T, C, q, B, E, F, H, L, V, D, S, z, A, R, $;
129
+ const i = G("MirrorNode", !0);
130
+ return e.node.type === "text" ? (t(), l(Q, {
156
131
  key: 0,
157
132
  text: e.node.text ?? "",
158
133
  marks: e.node.marks
159
- }, null, 8, ["text", "marks"])) : e.node.type === "doc" ? (t(), n("article", ne, [
160
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
134
+ }, null, 8, ["text", "marks"])) : e.node.type === "doc" ? (t(), n("article", U, [
135
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
161
136
  key: o,
162
137
  node: d,
163
138
  depth: e.depth ?? 0
164
139
  }, null, 8, ["node", "depth"]))), 128))
165
- ])) : e.node.type === "preface" ? (t(), n("div", de, [
166
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
140
+ ])) : e.node.type === "preface" ? (t(), n("div", W, [
141
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
167
142
  key: o,
168
143
  node: d,
169
144
  depth: (e.depth ?? 0) + 1
170
145
  }, null, 8, ["node", "depth"]))), 128))
171
- ])) : e.node.type === "sections" ? (t(), n("div", oe, [
172
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
146
+ ])) : e.node.type === "sections" ? (t(), n("div", X, [
147
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
173
148
  key: o,
174
149
  node: d,
175
150
  depth: (e.depth ?? 0) + 1
176
151
  }, null, 8, ["node", "depth"]))), 128))
177
- ])) : e.node.type === "bibliography" ? (t(), n("div", re, [
178
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
152
+ ])) : e.node.type === "bibliography" ? (t(), n("div", Y, [
153
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
179
154
  key: o,
180
155
  node: d,
181
156
  depth: (e.depth ?? 0) + 1
182
157
  }, null, 8, ["node", "depth"]))), 128))
183
- ])) : "clause annex content_section abstract foreword introduction acknowledgements terms definitions references".split(" ").includes(e.node.type) ? (t(), n("section", {
158
+ ])) : I(P)(e.node.type) ? (t(), n("section", {
184
159
  key: 5,
185
- class: z(["mirror-section", "mirror-" + e.node.type]),
186
- id: ((m = e.node.attrs) == null ? void 0 : m.id) || void 0
160
+ id: ((w = e.node.attrs) == null ? void 0 : w.id) || void 0,
161
+ class: x(["mirror-section", "mirror-" + e.node.type])
187
162
  }, [
188
- (u = e.node.attrs) != null && u.title ? (t(), l(F(k(e.depth ?? 1)), {
163
+ (N = e.node.attrs) != null && N.title ? (t(), l(g(s(e.depth ?? 1)), {
189
164
  key: 0,
190
165
  class: "mirror-heading"
191
166
  }, {
192
- default: R(() => {
167
+ default: M(() => {
193
168
  var d;
194
169
  return [
195
- (d = e.node.attrs) != null && d.number ? (t(), n("span", ie, a(e.node.attrs.number) + " ", 1)) : h("", !0),
196
- b(a(e.node.attrs.title), 1)
170
+ (d = e.node.attrs) != null && d.number ? (t(), n("span", p, u(e.node.attrs.number) + " ", 1)) : c("", !0),
171
+ m(u(e.node.attrs.title), 1)
197
172
  ];
198
173
  }),
199
174
  _: 1
200
- })) : h("", !0),
201
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
175
+ })) : c("", !0),
176
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
202
177
  key: o,
203
178
  node: d,
204
179
  depth: (e.depth ?? 1) + 1
205
180
  }, null, 8, ["node", "depth"]))), 128))
206
- ], 10, le)) : e.node.type === "paragraph" ? (t(), n("p", ae, [
207
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
181
+ ], 10, Z)) : e.node.type === "paragraph" ? (t(), n("p", _, [
182
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
208
183
  key: o,
209
184
  node: d
210
185
  }, null, 8, ["node"]))), 128))
211
- ])) : e.node.type === "note" ? (t(), n("div", se, [
212
- y[0] || (y[0] = f("div", { class: "mirror-note-label" }, "Note", -1)),
213
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
186
+ ])) : e.node.type === "note" ? (t(), n("div", ee, [
187
+ y[0] || (y[0] = k("div", { class: "mirror-note-label" }, "Note", -1)),
188
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
214
189
  key: o,
215
190
  node: d,
216
191
  depth: e.depth
@@ -218,178 +193,178 @@ const G = ["href"], I = { key: 2 }, J = { key: 3 }, K = { key: 4 }, O = { key: 5
218
193
  ])) : e.node.type === "admonition" ? (t(), n("div", {
219
194
  key: 8,
220
195
  class: "mirror-admonition",
221
- "data-admonition-type": ((x = e.node.attrs) == null ? void 0 : x.type) || "note"
196
+ "data-admonition-type": ((T = e.node.attrs) == null ? void 0 : T.type) || "note"
222
197
  }, [
223
- (v = e.node.attrs) != null && v.type ? (t(), n("div", ue, a(e.node.attrs.type), 1)) : h("", !0),
224
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
198
+ (C = e.node.attrs) != null && C.type ? (t(), n("div", ne, u(e.node.attrs.type), 1)) : c("", !0),
199
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
225
200
  key: o,
226
201
  node: d,
227
202
  depth: e.depth
228
203
  }, null, 8, ["node", "depth"]))), 128))
229
- ], 8, ce)) : e.node.type === "example" ? (t(), n("div", he, [
230
- y[1] || (y[1] = f("div", { class: "mirror-example-label" }, "Example", -1)),
231
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
204
+ ], 8, te)) : e.node.type === "example" ? (t(), n("div", de, [
205
+ y[1] || (y[1] = k("div", { class: "mirror-example-label" }, "Example", -1)),
206
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
232
207
  key: o,
233
208
  node: d,
234
209
  depth: e.depth
235
210
  }, null, 8, ["node", "depth"]))), 128))
236
- ])) : e.node.type === "quote" ? (t(), n("blockquote", ye, [
237
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
211
+ ])) : e.node.type === "quote" ? (t(), n("blockquote", oe, [
212
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
238
213
  key: o,
239
214
  node: d,
240
215
  depth: e.depth
241
216
  }, null, 8, ["node", "depth"]))), 128))
242
- ])) : e.node.type === "review" ? (t(), n("div", me, [
243
- y[2] || (y[2] = f("div", { class: "mirror-review-label" }, "Review", -1)),
244
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
217
+ ])) : e.node.type === "review" ? (t(), n("div", le, [
218
+ y[2] || (y[2] = k("div", { class: "mirror-review-label" }, "Review", -1)),
219
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
245
220
  key: o,
246
221
  node: d,
247
222
  depth: e.depth
248
223
  }, null, 8, ["node", "depth"]))), 128))
249
- ])) : e.node.type === "figure" ? (t(), n("figure", ke, [
250
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
224
+ ])) : e.node.type === "figure" ? (t(), n("figure", re, [
225
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
251
226
  key: o,
252
227
  node: d,
253
228
  depth: e.depth
254
229
  }, null, 8, ["node", "depth"]))), 128)),
255
- (g = e.node.attrs) != null && g.title ? (t(), n("figcaption", fe, [
256
- ($ = e.node.attrs) != null && $.number ? (t(), n("span", be, a(e.node.attrs.number) + " ", 1)) : h("", !0),
257
- b(a(e.node.attrs.title), 1)
258
- ])) : h("", !0)
259
- ])) : e.node.type === "image" ? (t(), n("div", xe, [
260
- (M = e.node.attrs) != null && M.src ? (t(), n("img", {
230
+ (q = e.node.attrs) != null && q.title ? (t(), n("figcaption", ie, [
231
+ (B = e.node.attrs) != null && B.number ? (t(), n("span", ae, u(e.node.attrs.number) + " ", 1)) : c("", !0),
232
+ m(u(e.node.attrs.title), 1)
233
+ ])) : c("", !0)
234
+ ])) : e.node.type === "image" ? (t(), n("div", ue, [
235
+ (E = e.node.attrs) != null && E.src ? (t(), n("img", {
261
236
  key: 0,
262
237
  src: e.node.attrs.src,
263
- alt: ((w = e.node.attrs) == null ? void 0 : w.alt) || ""
264
- }, null, 8, ve)) : h("", !0)
265
- ])) : e.node.type === "table" ? (t(), n("div", ge, [
266
- (N = e.node.attrs) != null && N.title ? (t(), n("div", $e, [
267
- (C = e.node.attrs) != null && C.number ? (t(), n("span", Me, a(e.node.attrs.number) + " ", 1)) : h("", !0),
268
- b(a(e.node.attrs.title), 1)
269
- ])) : h("", !0),
270
- f("table", null, [
271
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
238
+ alt: ((F = e.node.attrs) == null ? void 0 : F.alt) || ""
239
+ }, null, 8, ce)) : c("", !0)
240
+ ])) : e.node.type === "table" ? (t(), n("div", se, [
241
+ (H = e.node.attrs) != null && H.title ? (t(), n("div", he, [
242
+ (L = e.node.attrs) != null && L.number ? (t(), n("span", ye, u(e.node.attrs.number) + " ", 1)) : c("", !0),
243
+ m(u(e.node.attrs.title), 1)
244
+ ])) : c("", !0),
245
+ k("table", null, [
246
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
272
247
  key: o,
273
248
  node: d,
274
249
  depth: e.depth
275
250
  }, null, 8, ["node", "depth"]))), 128))
276
251
  ])
277
- ])) : e.node.type === "table_head" ? (t(), n("thead", we, [
278
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
252
+ ])) : e.node.type === "table_head" ? (t(), n("thead", me, [
253
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
279
254
  key: o,
280
255
  node: d,
281
256
  depth: e.depth
282
257
  }, null, 8, ["node", "depth"]))), 128))
283
- ])) : e.node.type === "table_body" ? (t(), n("tbody", Ne, [
284
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
258
+ ])) : e.node.type === "table_body" ? (t(), n("tbody", ke, [
259
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
285
260
  key: o,
286
261
  node: d,
287
262
  depth: e.depth
288
263
  }, null, 8, ["node", "depth"]))), 128))
289
- ])) : e.node.type === "table_foot" ? (t(), n("tfoot", Ce, [
290
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
264
+ ])) : e.node.type === "table_foot" ? (t(), n("tfoot", ve, [
265
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
291
266
  key: o,
292
267
  node: d,
293
268
  depth: e.depth
294
269
  }, null, 8, ["node", "depth"]))), 128))
295
- ])) : e.node.type === "table_row" ? (t(), n("tr", Te, [
296
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
270
+ ])) : e.node.type === "table_row" ? (t(), n("tr", fe, [
271
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
297
272
  key: o,
298
273
  node: d,
299
274
  depth: e.depth
300
275
  }, null, 8, ["node", "depth"]))), 128))
301
276
  ])) : e.node.type === "table_cell" ? (t(), n("td", {
302
277
  key: 19,
303
- colspan: ((T = e.node.attrs) == null ? void 0 : T.colspan) || void 0,
304
- rowspan: ((H = e.node.attrs) == null ? void 0 : H.rowspan) || void 0
278
+ colspan: ((V = e.node.attrs) == null ? void 0 : V.colspan) || void 0,
279
+ rowspan: ((D = e.node.attrs) == null ? void 0 : D.rowspan) || void 0
305
280
  }, [
306
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
281
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
307
282
  key: o,
308
283
  node: d,
309
284
  depth: e.depth
310
285
  }, null, 8, ["node", "depth"]))), 128))
311
- ], 8, He)) : e.node.type === "formula" ? (t(), n("div", qe, [
312
- (q = e.node.attrs) != null && q.mathml ? (t(), n("div", {
286
+ ], 8, be)) : e.node.type === "formula" ? (t(), n("div", ge, [
287
+ (S = h.value) != null && S.mathml ? (t(), n("div", {
313
288
  key: 0,
314
289
  class: "mirror-formula-content",
315
- innerHTML: e.node.attrs.mathml
316
- }, null, 8, Be)) : (B = e.node.attrs) != null && B.asciimath ? (t(), n("span", Ee, a(e.node.attrs.asciimath), 1)) : (E = e.node.attrs) != null && E.math_text ? (t(), n("span", Le, a(e.node.attrs.math_text), 1)) : h("", !0),
317
- (L = e.node.attrs) != null && L.number ? (t(), n("span", Ve, "(" + a(e.node.attrs.number) + ")", 1)) : h("", !0)
318
- ])) : e.node.type === "sourcecode" ? (t(), n("pre", De, [
319
- f("code", null, a((V = e.node.attrs) == null ? void 0 : V.text), 1)
320
- ])) : e.node.type === "bullet_list" ? (t(), n("ul", ze, [
321
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
290
+ innerHTML: h.value.mathml
291
+ }, null, 8, xe)) : (z = h.value) != null && z.asciimath ? (t(), n("span", Me, u(h.value.asciimath), 1)) : c("", !0),
292
+ (A = h.value) != null && A.number ? (t(), n("span", we, "(" + u(h.value.number) + ")", 1)) : c("", !0)
293
+ ])) : e.node.type === "sourcecode" ? (t(), n("pre", Ne, [
294
+ k("code", null, u((R = e.node.attrs) == null ? void 0 : R.text), 1)
295
+ ])) : e.node.type === "bullet_list" ? (t(), n("ul", Te, [
296
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
322
297
  key: o,
323
298
  node: d,
324
299
  depth: e.depth
325
300
  }, null, 8, ["node", "depth"]))), 128))
326
- ])) : e.node.type === "ordered_list" ? (t(), n("ol", Fe, [
327
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
301
+ ])) : e.node.type === "ordered_list" ? (t(), n("ol", Ce, [
302
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
328
303
  key: o,
329
304
  node: d,
330
305
  depth: e.depth
331
306
  }, null, 8, ["node", "depth"]))), 128))
332
- ])) : e.node.type === "list_item" ? (t(), n("li", Re, [
333
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
307
+ ])) : e.node.type === "list_item" ? (t(), n("li", qe, [
308
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
334
309
  key: o,
335
310
  node: d,
336
311
  depth: e.depth
337
312
  }, null, 8, ["node", "depth"]))), 128))
338
- ])) : e.node.type === "dl" ? (t(), n("dl", Se, [
339
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
313
+ ])) : e.node.type === "dl" ? (t(), n("dl", Be, [
314
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
340
315
  key: o,
341
316
  node: d,
342
317
  depth: e.depth
343
318
  }, null, 8, ["node", "depth"]))), 128))
344
- ])) : e.node.type === "dt" ? (t(), n("dt", je, [
345
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
319
+ ])) : e.node.type === "dt" ? (t(), n("dt", Ee, [
320
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
346
321
  key: o,
347
322
  node: d,
348
323
  depth: e.depth
349
324
  }, null, 8, ["node", "depth"]))), 128))
350
- ])) : e.node.type === "dd" ? (t(), n("dd", Ae, [
351
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
325
+ ])) : e.node.type === "dd" ? (t(), n("dd", Fe, [
326
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
352
327
  key: o,
353
328
  node: d,
354
329
  depth: e.depth
355
330
  }, null, 8, ["node", "depth"]))), 128))
356
- ])) : e.node.type === "footnotes" ? (t(), n("div", Ge, [
357
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
331
+ ])) : e.node.type === "footnotes" ? (t(), n("div", He, [
332
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
358
333
  key: o,
359
334
  node: d,
360
335
  depth: e.depth
361
336
  }, null, 8, ["node", "depth"]))), 128))
362
- ])) : e.node.type === "footnote_entry" ? (t(), n("div", Ie, [
363
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
337
+ ])) : e.node.type === "footnote_entry" ? (t(), n("div", Le, [
338
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
364
339
  key: o,
365
340
  node: d,
366
341
  depth: e.depth
367
342
  }, null, 8, ["node", "depth"]))), 128))
368
- ])) : e.node.type === "floating_title" ? (t(), l(F(k((e.depth ?? 2) + 1)), {
343
+ ])) : e.node.type === "floating_title" ? (t(), l(g(s((e.depth ?? 2) + 1)), {
369
344
  key: 30,
370
345
  class: "mirror-floating-title"
371
346
  }, {
372
- default: R(() => {
347
+ default: M(() => {
373
348
  var d;
374
349
  return [
375
- b(a((d = e.node.attrs) == null ? void 0 : d.title), 1)
350
+ m(u((d = e.node.attrs) == null ? void 0 : d.title), 1)
376
351
  ];
377
352
  }),
378
353
  _: 1
379
- })) : e.node.type === "soft_break" ? (t(), n("br", Je)) : (D = e.node.content) != null && D.length ? (t(), n("div", {
354
+ })) : e.node.type === "soft_break" ? (t(), n("br", Ve)) : ($ = e.node.content) != null && $.length ? (t(), n("div", {
380
355
  key: 32,
381
- class: z("mirror-" + e.node.type)
356
+ class: x("mirror-" + e.node.type)
382
357
  }, [
383
- (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
358
+ (t(!0), n(r, null, a(e.node.content, (d, o) => (t(), l(i, {
384
359
  key: o,
385
360
  node: d,
386
361
  depth: e.depth
387
362
  }, null, 8, ["node", "depth"]))), 128))
388
- ], 2)) : h("", !0);
363
+ ], 2)) : c("", !0);
389
364
  };
390
365
  }
391
366
  });
392
367
  export {
393
- Pe as MirrorNode,
394
- te as MirrorText
368
+ ze as MirrorNode,
369
+ Q as MirrorText
395
370
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metanorma/mirror",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.1",
4
4
  "description": "TypeScript library and Vue components for the Metanorma Mirror document format",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
@@ -50,6 +50,7 @@
50
50
  "scripts": {
51
51
  "clean": "rm -rf dist",
52
52
  "build": "vite build",
53
+ "lint": "eslint .",
53
54
  "test": "vitest run",
54
55
  "test:e2e": "vitest run --config vite.config.e2e.ts",
55
56
  "test:all": "vitest run && vitest run --config vite.config.e2e.ts",
@@ -64,14 +65,20 @@
64
65
  }
65
66
  },
66
67
  "devDependencies": {
68
+ "@eslint/js": "^10.0.1",
67
69
  "@vitejs/plugin-vue": "^5.2.0",
68
70
  "@vue/language-core": "^3.3.5",
71
+ "eslint": "^10.5.0",
72
+ "eslint-plugin-vue": "^10.9.2",
73
+ "globals": "^17.6.0",
69
74
  "puppeteer": "^24.0.0",
70
75
  "typescript": "^5.7.0",
76
+ "typescript-eslint": "^8.61.1",
71
77
  "vite": "^6.0.0",
72
78
  "vite-plugin-dts": "^5.0.2",
73
79
  "vitest": "^3.0.0",
74
80
  "vue": "^3.5.0",
81
+ "vue-eslint-parser": "^10.4.1",
75
82
  "vue-tsc": "^3.3.5"
76
83
  },
77
84
  "dependencies": {
@@ -1 +0,0 @@
1
- "use strict";const s=new Map;function t(e,r){s.set(e,r)}t("strong",{tag:"strong"});t("emphasis",{tag:"em"});t("code",{tag:"code"});t("subscript",{tag:"sub"});t("superscript",{tag:"sup"});t("underline",{tag:"u"});t("strike",{tag:"s"});t("smallcap",{tag:"span"});t("link",{tag:"a",extractHref:e=>{var r,a;return((r=e.attrs)==null?void 0:r.target)||((a=e.attrs)==null?void 0:a.href)}});t("xref",{tag:"a",extractHref:e=>{var r;return(r=e.attrs)==null?void 0:r.target}});t("eref",{tag:"span"});t("footnote",{tag:"sup"});t("stem",{tag:"span"});t("concept",{tag:"span"});t("bcp14",{tag:"span"});t("span",{tag:"span"});function n(e){return s.get(e.type)}function g(e){var a;const r=s.get(e.type);return(a=r==null?void 0:r.extractHref)==null?void 0:a.call(r,e)}function o(e){if(!(e!=null&&e.length))return null;for(const r of e){const a=s.get(r.type);if(a)return{renderer:a,mark:r}}return null}exports.getMarkHref=g;exports.register=t;exports.resolveFirstMark=o;exports.resolveMark=n;
@@ -1,48 +0,0 @@
1
- const s = /* @__PURE__ */ new Map();
2
- function a(t, e) {
3
- s.set(t, e);
4
- }
5
- a("strong", { tag: "strong" });
6
- a("emphasis", { tag: "em" });
7
- a("code", { tag: "code" });
8
- a("subscript", { tag: "sub" });
9
- a("superscript", { tag: "sup" });
10
- a("underline", { tag: "u" });
11
- a("strike", { tag: "s" });
12
- a("smallcap", { tag: "span" });
13
- a("link", { tag: "a", extractHref: (t) => {
14
- var e, r;
15
- return ((e = t.attrs) == null ? void 0 : e.target) || ((r = t.attrs) == null ? void 0 : r.href);
16
- } });
17
- a("xref", { tag: "a", extractHref: (t) => {
18
- var e;
19
- return (e = t.attrs) == null ? void 0 : e.target;
20
- } });
21
- a("eref", { tag: "span" });
22
- a("footnote", { tag: "sup" });
23
- a("stem", { tag: "span" });
24
- a("concept", { tag: "span" });
25
- a("bcp14", { tag: "span" });
26
- a("span", { tag: "span" });
27
- function n(t) {
28
- return s.get(t.type);
29
- }
30
- function g(t) {
31
- var r;
32
- const e = s.get(t.type);
33
- return (r = e == null ? void 0 : e.extractHref) == null ? void 0 : r.call(e, t);
34
- }
35
- function o(t) {
36
- if (!(t != null && t.length)) return null;
37
- for (const e of t) {
38
- const r = s.get(e.type);
39
- if (r) return { renderer: r, mark: e };
40
- }
41
- return null;
42
- }
43
- export {
44
- o as a,
45
- n as b,
46
- g,
47
- a as r
48
- };