@metanorma/mirror 0.1.0-beta.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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Ribose
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # @metanorma/mirror
2
+
3
+ TypeScript library and optional Vue 3 components for the **Metanorma Mirror** document format — a JSON tree representation of standards documents (clauses, terms, tables, formulas, lists, etc.).
4
+
5
+ The library is framework-agnostic. The Vue layer is opt-in via a separate subpath export.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @metanorma/mirror
11
+ ```
12
+
13
+ For the Vue components, Vue 3 (`>=3.4`) is a peer dependency:
14
+
15
+ ```bash
16
+ npm install @metanorma/mirror vue
17
+ ```
18
+
19
+ ## Entry points
20
+
21
+ | Subpath | Description |
22
+ | --- | --- |
23
+ | `@metanorma/mirror` | Core types, traversal, mark registry, math helpers |
24
+ | `@metanorma/mirror/vue` | `<MirrorNode>` and `<MirrorText>` Vue 3 components |
25
+
26
+ ## Core usage
27
+
28
+ ```ts
29
+ import {
30
+ buildToc,
31
+ findNodes,
32
+ getNodeText,
33
+ type MirrorDocument,
34
+ } from '@metanorma/mirror'
35
+
36
+ const doc: MirrorDocument = {
37
+ type: 'doc',
38
+ content: [
39
+ {
40
+ type: 'clause',
41
+ attrs: { id: 'scope', title: 'Scope', number: '1' },
42
+ content: [
43
+ {
44
+ type: 'paragraph',
45
+ content: [
46
+ { type: 'text', text: 'Hello ' },
47
+ { type: 'text', text: 'world', marks: [{ type: 'strong' }] },
48
+ ],
49
+ },
50
+ ],
51
+ },
52
+ ],
53
+ }
54
+
55
+ buildToc(doc)
56
+ // => [{ id: 'scope', title: '1 Scope', depth: 0 }]
57
+
58
+ findNodes(doc, n => n.type === 'paragraph').length
59
+ // => 1
60
+
61
+ getNodeText(doc)
62
+ // => 'Hello world'
63
+ ```
64
+
65
+ ### Mark registry
66
+
67
+ Inline marks (`strong`, `emphasis`, `link`, `xref`, `footnote`, `stem`, …) are resolved through a registry. Built-ins can be overridden and custom marks can be added via `registerMark`:
68
+
69
+ ```ts
70
+ import { registerMark, resolveMark } from '@metanorma/mirror'
71
+
72
+ registerMark('highlight', { tag: 'mark', classes: 'hl' })
73
+ resolveMark({ type: 'highlight' })
74
+ // => { tag: 'mark', classes: 'hl' }
75
+ ```
76
+
77
+ `getMarkHref` extracts the URL from `link` and `xref` marks (reads `attrs.target`, falls back to `attrs.href` for `link`).
78
+
79
+ ### Math formulas
80
+
81
+ Formula nodes may carry pre-computed MathML in `attrs.mathml`, or AsciiMath in `attrs.asciimath` / `attrs.math_text`. `renderFormula` returns MathML when available, otherwise lazily converts AsciiMath → MathML via [`@plurimath/plurimath`](https://www.npmjs.com/package/@plurimath/plurimath), falling back to the raw AsciiMath string if conversion fails.
82
+
83
+ ```ts
84
+ import { renderFormula } from '@metanorma/mirror'
85
+
86
+ await renderFormula({ type: 'formula', attrs: { asciimath: 'E = mc^2' } })
87
+ ```
88
+
89
+ ## Vue usage
90
+
91
+ ```vue
92
+ <script setup lang="ts">
93
+ import { MirrorNode } from '@metanorma/mirror/vue'
94
+ import type { MirrorDocument } from '@metanorma/mirror'
95
+
96
+ const doc: MirrorDocument = /* … */
97
+ </script>
98
+
99
+ <template>
100
+ <MirrorNode :node="doc" :depth="0" />
101
+ </template>
102
+ ```
103
+
104
+ `<MirrorNode>` walks the node tree recursively and emits semantic HTML with `mirror-<type>` class names (e.g. `mirror-paragraph`, `mirror-section`, `mirror-table`). `<MirrorText>` renders a text node with the first matching mark as the appropriate HTML element (`<strong>`, `<em>`, `<a>`, `<sub>`, `<sup>`, etc.).
105
+
106
+ CSS is intentionally not bundled — apply your own styles to the `.mirror-*` classes, or override the component templates.
107
+
108
+ ## Node model
109
+
110
+ Every node shares the shape `{ type, attrs?, content?, marks?, text? }`. Node types are partitioned into disjoint categories exported from the core:
111
+
112
+ - `STRUCTURAL_TYPES` — `doc`, `preface`, `sections`, `bibliography`
113
+ - `SECTION_TYPES` — `clause`, `annex`, `terms`, `definitions`, `references`, …
114
+ - `BLOCK_TYPES` — `paragraph`, `note`, `admonition`, `example`, `quote`, `formula`, `sourcecode`, `review`
115
+ - `LIST_TYPES`, `TABLE_TYPES`, `MEDIA_TYPES`, `FOOTNOTE_TYPES`, `LEAF_TYPES`
116
+
117
+ `SECTION_TYPES` is used by `buildToc` to decide which nodes become TOC entries.
118
+
119
+ ## Development
120
+
121
+ ```bash
122
+ npm install
123
+ npm run build # vite build → dist + .d.ts via vite-plugin-dts
124
+ npm test # vitest unit tests
125
+ npm run test:e2e # puppeteer e2e
126
+ npm run test:all # both suites
127
+ ```
128
+
129
+ Requires **Node.js 20+**. See [CONTRIBUTING.md](./CONTRIBUTING.md) for release flow and conventions.
130
+
131
+ ## License
132
+
133
+ BSD-3-Clause — see [LICENSE](./LICENSE).
@@ -0,0 +1 @@
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;
@@ -0,0 +1,48 @@
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
+ };
@@ -0,0 +1,5 @@
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';
3
+ export { getNodeText, findNodes, buildToc, type TocEntry } from './traversal';
4
+ export { resolveMark, resolveFirstMark, getMarkHref, registerMark, type MarkRenderer } from './marks';
5
+ export { extractFormulaAttrs, renderFormula, type FormulaDisplay } from './math';
@@ -0,0 +1,14 @@
1
+ import { MirrorMark } from './types';
2
+ export interface MarkRenderer {
3
+ tag: string;
4
+ classes?: string;
5
+ extractHref?: (mark: MirrorMark) => string | undefined;
6
+ }
7
+ declare function register(type: string, renderer: MarkRenderer): void;
8
+ export { register as registerMark };
9
+ export declare function resolveMark(mark: MirrorMark): MarkRenderer | undefined;
10
+ export declare function getMarkHref(mark: MirrorMark): string | undefined;
11
+ export declare function resolveFirstMark(marks?: MirrorMark[]): {
12
+ renderer: MarkRenderer;
13
+ mark: MirrorMark;
14
+ } | null;
package/dist/math.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { MirrorNode } from './types';
2
+ export interface FormulaDisplay {
3
+ mathml: string | null;
4
+ asciimath: string | null;
5
+ number: string | null;
6
+ }
7
+ export declare function extractFormulaAttrs(node: MirrorNode): FormulaDisplay;
8
+ export declare function renderFormula(node: MirrorNode): Promise<string>;
@@ -0,0 +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;
package/dist/mirror.js ADDED
@@ -0,0 +1,111 @@
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("") : "";
42
+ }
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;
48
+ }
49
+ function x(t) {
50
+ const e = [];
51
+ return c(t, 0, e), e;
52
+ }
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} ` : "";
57
+ if (r.push({
58
+ id: t.attrs.id,
59
+ title: `${a}${t.attrs.title}`,
60
+ depth: e
61
+ }), t.content)
62
+ for (const i of t.content)
63
+ c(i, e + 1, r);
64
+ return;
65
+ }
66
+ 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 "";
92
+ }
93
+ 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,
100
+ _ 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
111
+ };
@@ -0,0 +1,9 @@
1
+ import { MirrorNode } from './types';
2
+ export declare function getNodeText(node: MirrorNode): string;
3
+ export declare function findNodes(node: MirrorNode, predicate: (n: MirrorNode) => boolean, results?: MirrorNode[]): MirrorNode[];
4
+ export interface TocEntry {
5
+ id: string;
6
+ title: string;
7
+ depth: number;
8
+ }
9
+ export declare function buildToc(root: MirrorNode): TocEntry[];
@@ -0,0 +1,33 @@
1
+ export declare const MARK_TYPES: readonly ["emphasis", "strong", "subscript", "superscript", "code", "underline", "strike", "smallcap", "link", "xref", "eref", "footnote", "stem", "concept", "bcp14", "span"];
2
+ export type MirrorMarkType = typeof MARK_TYPES[number];
3
+ export interface MirrorMark {
4
+ type: MirrorMarkType;
5
+ attrs?: Record<string, unknown>;
6
+ }
7
+ export declare const STRUCTURAL_TYPES: readonly ["doc", "preface", "sections", "bibliography"];
8
+ export declare const SECTION_TYPES: readonly ["clause", "annex", "content_section", "abstract", "foreword", "introduction", "acknowledgements", "terms", "definitions", "references"];
9
+ export declare const BLOCK_TYPES: readonly ["paragraph", "note", "admonition", "example", "sourcecode", "formula", "quote", "review"];
10
+ export declare const LIST_TYPES: readonly ["bullet_list", "ordered_list", "list_item", "dl", "dt", "dd"];
11
+ export declare const TABLE_TYPES: readonly ["table", "table_head", "table_body", "table_foot", "table_row", "table_cell"];
12
+ export declare const MEDIA_TYPES: readonly ["figure", "image"];
13
+ export declare const FOOTNOTE_TYPES: readonly ["footnotes", "footnote_marker", "footnote_entry"];
14
+ export declare const LEAF_TYPES: readonly ["text", "soft_break", "floating_title"];
15
+ export type MirrorNodeType = typeof STRUCTURAL_TYPES[number] | typeof SECTION_TYPES[number] | typeof BLOCK_TYPES[number] | typeof LIST_TYPES[number] | typeof TABLE_TYPES[number] | typeof MEDIA_TYPES[number] | typeof FOOTNOTE_TYPES[number] | typeof LEAF_TYPES[number];
16
+ export interface MirrorNode {
17
+ type: string;
18
+ attrs?: Record<string, unknown>;
19
+ content?: MirrorNode[];
20
+ marks?: MirrorMark[];
21
+ text?: string;
22
+ }
23
+ export type MirrorDocument = MirrorNode;
24
+ export interface DocumentPart {
25
+ id: string;
26
+ label: string;
27
+ title: string;
28
+ }
29
+ export interface DocumentManifest {
30
+ [standardId: string]: {
31
+ parts: DocumentPart[];
32
+ };
33
+ }
@@ -0,0 +1,8 @@
1
+ import { MirrorNode as MirrorNodeType } from '../types';
2
+ type __VLS_Props = {
3
+ node: MirrorNodeType;
4
+ depth?: number;
5
+ };
6
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { MirrorMark } from '../types';
2
+ type __VLS_Props = {
3
+ text: string;
4
+ marks?: MirrorMark[];
5
+ };
6
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as MirrorNode } from './MirrorNode.vue';
2
+ export { default as MirrorText } from './MirrorText.vue';
package/dist/vue.cjs ADDED
@@ -0,0 +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;
package/dist/vue.js ADDED
@@ -0,0 +1,395 @@
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({
22
+ __name: "MirrorText",
23
+ props: {
24
+ text: {},
25
+ marks: {}
26
+ },
27
+ 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
+ };
47
+ }
48
+ }), ne = {
49
+ key: 1,
50
+ class: "mirror-doc"
51
+ }, de = {
52
+ key: 2,
53
+ class: "mirror-preface"
54
+ }, oe = {
55
+ key: 3,
56
+ class: "mirror-sections"
57
+ }, re = {
58
+ key: 4,
59
+ class: "mirror-bibliography"
60
+ }, le = ["id"], ie = {
61
+ key: 0,
62
+ class: "mirror-number"
63
+ }, ae = {
64
+ key: 6,
65
+ class: "mirror-paragraph"
66
+ }, se = {
67
+ key: 7,
68
+ class: "mirror-note"
69
+ }, ce = ["data-admonition-type"], ue = {
70
+ key: 0,
71
+ class: "mirror-admonition-label"
72
+ }, he = {
73
+ key: 9,
74
+ class: "mirror-example"
75
+ }, ye = {
76
+ key: 10,
77
+ class: "mirror-quote"
78
+ }, me = {
79
+ key: 11,
80
+ class: "mirror-review"
81
+ }, ke = {
82
+ key: 12,
83
+ class: "mirror-figure"
84
+ }, fe = {
85
+ key: 0,
86
+ class: "mirror-figure-caption"
87
+ }, be = {
88
+ key: 0,
89
+ class: "mirror-number"
90
+ }, xe = {
91
+ key: 13,
92
+ class: "mirror-image"
93
+ }, ve = ["src", "alt"], ge = {
94
+ key: 14,
95
+ class: "mirror-table"
96
+ }, $e = {
97
+ key: 0,
98
+ class: "mirror-table-title"
99
+ }, Me = {
100
+ key: 0,
101
+ class: "mirror-number"
102
+ }, we = { key: 15 }, Ne = { key: 16 }, Ce = { key: 17 }, Te = { key: 18 }, He = ["colspan", "rowspan"], qe = {
103
+ key: 20,
104
+ class: "mirror-formula"
105
+ }, Be = ["innerHTML"], Ee = {
106
+ key: 1,
107
+ class: "mirror-formula-content"
108
+ }, Le = {
109
+ key: 2,
110
+ class: "mirror-formula-content"
111
+ }, Ve = {
112
+ key: 3,
113
+ class: "mirror-formula-number"
114
+ }, De = {
115
+ key: 21,
116
+ class: "mirror-sourcecode"
117
+ }, ze = {
118
+ key: 22,
119
+ class: "mirror-bullet-list"
120
+ }, Fe = {
121
+ key: 23,
122
+ class: "mirror-ordered-list"
123
+ }, Re = {
124
+ key: 24,
125
+ class: "mirror-list-item"
126
+ }, Se = {
127
+ key: 25,
128
+ class: "mirror-dl"
129
+ }, je = {
130
+ key: 26,
131
+ class: "mirror-dt"
132
+ }, Ae = {
133
+ key: 27,
134
+ class: "mirror-dd"
135
+ }, Ge = {
136
+ key: 28,
137
+ class: "mirror-footnotes"
138
+ }, Ie = {
139
+ key: 29,
140
+ class: "mirror-footnote-entry"
141
+ }, Je = { key: 31 }, Pe = /* @__PURE__ */ S({
142
+ name: "MirrorNode",
143
+ __name: "MirrorNode",
144
+ props: {
145
+ node: {},
146
+ depth: {}
147
+ },
148
+ setup(e) {
149
+ function k(c) {
150
+ return "h" + Math.min(c + 1, 6);
151
+ }
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, {
156
+ key: 0,
157
+ text: e.node.text ?? "",
158
+ 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, {
161
+ key: o,
162
+ node: d,
163
+ depth: e.depth ?? 0
164
+ }, 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, {
167
+ key: o,
168
+ node: d,
169
+ depth: (e.depth ?? 0) + 1
170
+ }, 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, {
173
+ key: o,
174
+ node: d,
175
+ depth: (e.depth ?? 0) + 1
176
+ }, 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, {
179
+ key: o,
180
+ node: d,
181
+ depth: (e.depth ?? 0) + 1
182
+ }, 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", {
184
+ key: 5,
185
+ class: z(["mirror-section", "mirror-" + e.node.type]),
186
+ id: ((m = e.node.attrs) == null ? void 0 : m.id) || void 0
187
+ }, [
188
+ (u = e.node.attrs) != null && u.title ? (t(), l(F(k(e.depth ?? 1)), {
189
+ key: 0,
190
+ class: "mirror-heading"
191
+ }, {
192
+ default: R(() => {
193
+ var d;
194
+ 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)
197
+ ];
198
+ }),
199
+ _: 1
200
+ })) : h("", !0),
201
+ (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
202
+ key: o,
203
+ node: d,
204
+ depth: (e.depth ?? 1) + 1
205
+ }, 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, {
208
+ key: o,
209
+ node: d
210
+ }, 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, {
214
+ key: o,
215
+ node: d,
216
+ depth: e.depth
217
+ }, null, 8, ["node", "depth"]))), 128))
218
+ ])) : e.node.type === "admonition" ? (t(), n("div", {
219
+ key: 8,
220
+ class: "mirror-admonition",
221
+ "data-admonition-type": ((x = e.node.attrs) == null ? void 0 : x.type) || "note"
222
+ }, [
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, {
225
+ key: o,
226
+ node: d,
227
+ depth: e.depth
228
+ }, 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, {
232
+ key: o,
233
+ node: d,
234
+ depth: e.depth
235
+ }, 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, {
238
+ key: o,
239
+ node: d,
240
+ depth: e.depth
241
+ }, 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, {
245
+ key: o,
246
+ node: d,
247
+ depth: e.depth
248
+ }, 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, {
251
+ key: o,
252
+ node: d,
253
+ depth: e.depth
254
+ }, 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", {
261
+ key: 0,
262
+ 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, {
272
+ key: o,
273
+ node: d,
274
+ depth: e.depth
275
+ }, null, 8, ["node", "depth"]))), 128))
276
+ ])
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, {
279
+ key: o,
280
+ node: d,
281
+ depth: e.depth
282
+ }, 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, {
285
+ key: o,
286
+ node: d,
287
+ depth: e.depth
288
+ }, 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, {
291
+ key: o,
292
+ node: d,
293
+ depth: e.depth
294
+ }, 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, {
297
+ key: o,
298
+ node: d,
299
+ depth: e.depth
300
+ }, null, 8, ["node", "depth"]))), 128))
301
+ ])) : e.node.type === "table_cell" ? (t(), n("td", {
302
+ 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
305
+ }, [
306
+ (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
307
+ key: o,
308
+ node: d,
309
+ depth: e.depth
310
+ }, 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", {
313
+ key: 0,
314
+ 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, {
322
+ key: o,
323
+ node: d,
324
+ depth: e.depth
325
+ }, 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, {
328
+ key: o,
329
+ node: d,
330
+ depth: e.depth
331
+ }, 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, {
334
+ key: o,
335
+ node: d,
336
+ depth: e.depth
337
+ }, 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, {
340
+ key: o,
341
+ node: d,
342
+ depth: e.depth
343
+ }, 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, {
346
+ key: o,
347
+ node: d,
348
+ depth: e.depth
349
+ }, 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, {
352
+ key: o,
353
+ node: d,
354
+ depth: e.depth
355
+ }, 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, {
358
+ key: o,
359
+ node: d,
360
+ depth: e.depth
361
+ }, 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, {
364
+ key: o,
365
+ node: d,
366
+ depth: e.depth
367
+ }, null, 8, ["node", "depth"]))), 128))
368
+ ])) : e.node.type === "floating_title" ? (t(), l(F(k((e.depth ?? 2) + 1)), {
369
+ key: 30,
370
+ class: "mirror-floating-title"
371
+ }, {
372
+ default: R(() => {
373
+ var d;
374
+ return [
375
+ b(a((d = e.node.attrs) == null ? void 0 : d.title), 1)
376
+ ];
377
+ }),
378
+ _: 1
379
+ })) : e.node.type === "soft_break" ? (t(), n("br", Je)) : (D = e.node.content) != null && D.length ? (t(), n("div", {
380
+ key: 32,
381
+ class: z("mirror-" + e.node.type)
382
+ }, [
383
+ (t(!0), n(i, null, s(e.node.content, (d, o) => (t(), l(r, {
384
+ key: o,
385
+ node: d,
386
+ depth: e.depth
387
+ }, null, 8, ["node", "depth"]))), 128))
388
+ ], 2)) : h("", !0);
389
+ };
390
+ }
391
+ });
392
+ export {
393
+ Pe as MirrorNode,
394
+ te as MirrorText
395
+ };
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@metanorma/mirror",
3
+ "version": "0.1.0-beta.1",
4
+ "description": "TypeScript library and Vue components for the Metanorma Mirror document format",
5
+ "type": "module",
6
+ "license": "BSD-3-Clause",
7
+ "author": "Ribose",
8
+ "homepage": "https://github.com/metanorma/metanorma-mirror-js#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/metanorma/metanorma-mirror-js.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/metanorma/metanorma-mirror-js/issues"
15
+ },
16
+ "keywords": [
17
+ "metanorma",
18
+ "mirror",
19
+ "standards",
20
+ "iso",
21
+ "documents",
22
+ "vue"
23
+ ],
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "main": "./dist/mirror.cjs",
31
+ "module": "./dist/mirror.js",
32
+ "types": "./dist/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/mirror.js",
37
+ "require": "./dist/mirror.cjs"
38
+ },
39
+ "./vue": {
40
+ "types": "./dist/vue/index.d.ts",
41
+ "import": "./dist/vue.js",
42
+ "require": "./dist/vue.cjs"
43
+ }
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "README.md",
48
+ "LICENSE"
49
+ ],
50
+ "scripts": {
51
+ "clean": "rm -rf dist",
52
+ "build": "vite build",
53
+ "test": "vitest run",
54
+ "test:e2e": "vitest run --config vite.config.e2e.ts",
55
+ "test:all": "vitest run && vitest run --config vite.config.e2e.ts",
56
+ "prepublishOnly": "npm run clean && npm run build && npm run test:all"
57
+ },
58
+ "peerDependencies": {
59
+ "vue": "^3.4.0"
60
+ },
61
+ "peerDependenciesMeta": {
62
+ "vue": {
63
+ "optional": true
64
+ }
65
+ },
66
+ "devDependencies": {
67
+ "@vitejs/plugin-vue": "^5.2.0",
68
+ "@vue/language-core": "^3.3.5",
69
+ "puppeteer": "^24.0.0",
70
+ "typescript": "^5.7.0",
71
+ "vite": "^6.0.0",
72
+ "vite-plugin-dts": "^5.0.2",
73
+ "vitest": "^3.0.0",
74
+ "vue": "^3.5.0",
75
+ "vue-tsc": "^3.3.5"
76
+ },
77
+ "dependencies": {
78
+ "@plurimath/plurimath": "^0.2.2"
79
+ }
80
+ }