@pretextbook/ptxast-util-to-mdast 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -4
- package/dist/index.js +105 -98
- package/dist/lib/ptxast-to-mdast.d.ts +18 -0
- package/dist/lib/ptxast-util-to-mdast.d.ts +5 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`)}}function
|
|
3
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@pretextbook/ptxast"),T=require("mdast-util-to-markdown"),I=require("mdast-util-directive"),S=require("mdast-util-math"),g=new Set([...c.DIVISION_HIERARCHY,...c.EXTRA_DIVISION_TYPES.filter(e=>!c.isTitlelessDivisionType(e))]),k=new Set(c.TITLELESS_DIVISION_TYPES),x=new Set(["pretext","book","article","slideshow","frontmatter","backmatter"]),E=new Map([["theorem",{name:"theorem",category:"theorem-like"}],["lemma",{name:"lemma",category:"theorem-like"}],["corollary",{name:"corollary",category:"theorem-like"}],["proposition",{name:"proposition",category:"theorem-like"}],["claim",{name:"claim",category:"theorem-like"}],["fact",{name:"fact",category:"theorem-like"}],["conjecture",{name:"conjecture",category:"theorem-like"}],["axiom",{name:"axiom",category:"theorem-like"}],["principle",{name:"principle",category:"theorem-like"}],["hypothesis",{name:"hypothesis",category:"theorem-like"}],["algorithm",{name:"algorithm",category:"theorem-like"}],["definition",{name:"definition",category:"definition-like"}],["notation",{name:"notation",category:"definition-like"}],["remark",{name:"remark",category:"remark-like"}],["note",{name:"note",category:"remark-like"}],["observation",{name:"observation",category:"remark-like"}],["warning",{name:"warning",category:"remark-like"}],["insight",{name:"insight",category:"remark-like"}],["assemblage",{name:"assemblage",category:"remark-like"}],["example",{name:"example",category:"example-like"}],["question",{name:"question",category:"example-like"}],["problem",{name:"problem",category:"example-like"}],["exercise",{name:"exercise",category:"example-like"}],["activity",{name:"activity",category:"example-like"}],["exploration",{name:"exploration",category:"example-like"}],["investigation",{name:"investigation",category:"example-like"}],["project",{name:"project",category:"example-like"}],["proof",{name:"proof",category:"proof-like"}],["case",{name:"case",category:"proof-like"}],["solution",{name:"solution",category:"solution-like"}],["hint",{name:"hint",category:"solution-like"}],["answer",{name:"answer",category:"solution-like"}]]),w=new Set(["theorem-like","definition-like"]);function v(e){return{type:"root",children:f(e.children,1)}}function b(e){for(const t of e){if(t.type!=="element")continue;const i=t;if(g.has(i.name)||k.has(i.name)){const n=i.attributes??{},r={};return n["xml:id"]&&(r.xmlid=n["xml:id"]),n.label&&(r.label=n.label),n.component&&(r.component=n.component),{name:i.name,attributes:r}}if(x.has(i.name)){const n=b(i.children);if(n)return n}}}function f(e,t){const i=[];for(const n of e){if(n.type!=="element")continue;const r=n;if(x.has(r.name)||k.has(r.name))i.push(...f(r.children,t));else if(g.has(r.name))i.push(...P(r,Math.min(t,6)));else{const s=p(r);s!==null&&i.push(s)}}return i}function P(e,t){const i=[],n=e.attributes??{},r=e.children,s=r.find(a=>a.type==="element"&&a.name==="title"),m=r.filter(a=>!(a.type==="element"&&a.name==="title")),o={type:"heading",depth:t,children:s?s.children.map(h).filter(u):[],...n["xml:id"]?{data:{id:n["xml:id"],hProperties:{id:n["xml:id"]}}}:{}};i.push(o);const l=Math.min(t+1,6);return i.push(...f(m,l)),i}function p(e){switch(e.name){case"p":return M(e);case"blockquote":return D(e);case"ol":return y(e,!0);case"ul":return y(e,!1);case"program":return N(e);case"me":case"men":case"md":case"mdn":return C(e);default:{const t=E.get(e.name);return t?j(e,t):null}}}function M(e){return{type:"paragraph",children:e.children.map(h).filter(u)}}function D(e){return{type:"blockquote",children:e.children.filter(t=>t.type==="element").map(t=>p(t)).filter(u)}}function y(e,t){return{type:"list",ordered:t,spread:!1,children:e.children.filter(i=>i.type==="element").map(i=>_(i))}}function _(e){return{type:"listItem",spread:!1,children:e.children.filter(t=>t.type==="element").map(t=>p(t)).filter(u)}}function N(e){return{type:"code",lang:(e.attributes??{}).language??null,value:c.getPtxTextContent(e)}}function C(e){const t=e.children;return t.length>0&&t[0].type==="text"?{type:"math",value:c.getPtxTextContent(e)}:{type:"math",value:t.filter(n=>n.type==="element"&&n.name==="mrow").map(n=>c.getPtxTextContent(n)).join(` \\\\
|
|
2
|
+
`)}}function j(e,t){const i=e.attributes??{},n=e.children,r={};i["xml:id"]&&(r.id=i["xml:id"]);for(const[o,l]of Object.entries(i))o==="xml:id"||l==null||(r[o]=l);const s=n.find(o=>o.type==="element"&&o.name==="title"),m=[];if(s){const o={type:"paragraph",data:{directiveLabel:!0},children:s.children.map(h).filter(u)};m.push(o)}if(w.has(t.category))for(const o of n){if(o.type!=="element")continue;const l=o;if(l.name!=="title")if(l.name==="statement")for(const a of l.children){if(a.type!=="element")continue;const d=p(a);d&&m.push(d)}else{const a=p(l);a&&m.push(a)}}else for(const o of n){if(o.type!=="element")continue;const l=o;if(l.name==="title")continue;const a=p(l);a&&m.push(a)}return{type:"containerDirective",name:t.name,attributes:Object.keys(r).length>0?r:void 0,children:m}}function h(e){if(e.type==="text")return{type:"text",value:e.value??""};if(e.type!=="element")return null;const t=e;switch(t.name){case"em":return{type:"emphasis",children:t.children.map(h).filter(u)};case"alert":return{type:"strong",children:t.children.map(h).filter(u)};case"c":return{type:"inlineCode",value:c.getPtxTextContent(t)};case"m":return{type:"inlineMath",value:c.getPtxTextContent(t)};default:return null}}function u(e){return e!==null}function q(e){const t=v(e),i=T.toMarkdown(t,{extensions:[I.directiveToMarkdown(),S.mathToMarkdown()]}),n=b(e.children);if(!n)return i;const r=[];return n.name!=="chapter"&&r.push(`division: ${n.name}`),n.attributes.xmlid&&r.push(`xmlid: ${n.attributes.xmlid}`),n.attributes.label&&r.push(`label: ${n.attributes.label}`),n.attributes.component&&r.push(`component: ${n.attributes.component}`),r.length===0?i:`---
|
|
3
|
+
${r.join(`
|
|
4
|
+
`)}
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
${
|
|
7
|
+
${i}`}exports.ptxastToMarkdown=q;exports.ptxastToMdast=v;
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { DIVISION_HIERARCHY as
|
|
2
|
-
import { toMarkdown as
|
|
3
|
-
import { directiveToMarkdown as
|
|
4
|
-
import { mathToMarkdown as
|
|
1
|
+
import { DIVISION_HIERARCHY as b, EXTRA_DIVISION_TYPES as T, isTitlelessDivisionType as I, TITLELESS_DIVISION_TYPES as S, getPtxTextContent as p } from "@pretextbook/ptxast";
|
|
2
|
+
import { toMarkdown as E } from "mdast-util-to-markdown";
|
|
3
|
+
import { directiveToMarkdown as w } from "mdast-util-directive";
|
|
4
|
+
import { mathToMarkdown as _ } from "mdast-util-math";
|
|
5
5
|
const g = /* @__PURE__ */ new Set([
|
|
6
|
-
...
|
|
7
|
-
|
|
8
|
-
]), k = /* @__PURE__ */ new Set([
|
|
6
|
+
...b,
|
|
7
|
+
...T.filter((e) => !I(e))
|
|
8
|
+
]), k = new Set(S), v = /* @__PURE__ */ new Set([
|
|
9
9
|
"pretext",
|
|
10
10
|
"book",
|
|
11
11
|
"article",
|
|
12
|
+
"slideshow",
|
|
12
13
|
"frontmatter",
|
|
13
14
|
"backmatter"
|
|
14
|
-
]),
|
|
15
|
+
]), P = /* @__PURE__ */ new Map([
|
|
15
16
|
// theorem-like
|
|
16
17
|
["theorem", { name: "theorem", category: "theorem-like" }],
|
|
17
18
|
["lemma", { name: "lemma", category: "theorem-like" }],
|
|
@@ -50,88 +51,91 @@ const g = /* @__PURE__ */ new Set([
|
|
|
50
51
|
["solution", { name: "solution", category: "solution-like" }],
|
|
51
52
|
["hint", { name: "hint", category: "solution-like" }],
|
|
52
53
|
["answer", { name: "answer", category: "solution-like" }]
|
|
53
|
-
]),
|
|
54
|
-
function
|
|
54
|
+
]), D = /* @__PURE__ */ new Set(["theorem-like", "definition-like"]);
|
|
55
|
+
function N(e) {
|
|
55
56
|
return {
|
|
56
57
|
type: "root",
|
|
57
58
|
children: h(e.children, 1)
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
+
function x(e) {
|
|
61
62
|
for (const t of e) {
|
|
62
63
|
if (t.type !== "element") continue;
|
|
63
|
-
const
|
|
64
|
-
if (g.has(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
const i = t;
|
|
65
|
+
if (g.has(i.name) || k.has(i.name)) {
|
|
66
|
+
const n = i.attributes ?? {}, r = {};
|
|
67
|
+
return n["xml:id"] && (r.xmlid = n["xml:id"]), n.label && (r.label = n.label), n.component && (r.component = n.component), { name: i.name, attributes: r };
|
|
68
|
+
}
|
|
69
|
+
if (v.has(i.name)) {
|
|
70
|
+
const n = x(i.children);
|
|
71
|
+
if (n) return n;
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
function h(e, t) {
|
|
72
|
-
const
|
|
73
|
-
for (const
|
|
74
|
-
if (
|
|
75
|
-
const
|
|
76
|
-
if (k.has(
|
|
77
|
-
|
|
78
|
-
else if (g.has(
|
|
79
|
-
|
|
76
|
+
const i = [];
|
|
77
|
+
for (const n of e) {
|
|
78
|
+
if (n.type !== "element") continue;
|
|
79
|
+
const r = n;
|
|
80
|
+
if (v.has(r.name) || k.has(r.name))
|
|
81
|
+
i.push(...h(r.children, t));
|
|
82
|
+
else if (g.has(r.name))
|
|
83
|
+
i.push(...M(r, Math.min(t, 6)));
|
|
80
84
|
else {
|
|
81
|
-
const
|
|
82
|
-
|
|
85
|
+
const c = u(r);
|
|
86
|
+
c !== null && i.push(c);
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
|
-
return
|
|
89
|
+
return i;
|
|
86
90
|
}
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
(
|
|
90
|
-
),
|
|
91
|
-
(
|
|
92
|
-
),
|
|
91
|
+
function M(e, t) {
|
|
92
|
+
const i = [], n = e.attributes ?? {}, r = e.children, c = r.find(
|
|
93
|
+
(a) => a.type === "element" && a.name === "title"
|
|
94
|
+
), s = r.filter(
|
|
95
|
+
(a) => !(a.type === "element" && a.name === "title")
|
|
96
|
+
), o = {
|
|
93
97
|
type: "heading",
|
|
94
98
|
depth: t,
|
|
95
|
-
children:
|
|
96
|
-
...
|
|
99
|
+
children: c ? c.children.map(f).filter(m) : [],
|
|
100
|
+
...n["xml:id"] ? { data: { id: n["xml:id"], hProperties: { id: n["xml:id"] } } } : {}
|
|
97
101
|
};
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
return
|
|
102
|
+
i.push(o);
|
|
103
|
+
const l = Math.min(t + 1, 6);
|
|
104
|
+
return i.push(...h(s, l)), i;
|
|
101
105
|
}
|
|
102
106
|
function u(e) {
|
|
103
107
|
switch (e.name) {
|
|
104
108
|
case "p":
|
|
105
|
-
return
|
|
109
|
+
return L(e);
|
|
106
110
|
case "blockquote":
|
|
107
|
-
return
|
|
111
|
+
return A(e);
|
|
108
112
|
case "ol":
|
|
109
113
|
return y(e, !0);
|
|
110
114
|
case "ul":
|
|
111
115
|
return y(e, !1);
|
|
112
116
|
case "program":
|
|
113
|
-
return
|
|
117
|
+
return j(e);
|
|
114
118
|
case "me":
|
|
115
119
|
case "men":
|
|
116
120
|
case "md":
|
|
117
121
|
case "mdn":
|
|
118
|
-
return
|
|
122
|
+
return R(e);
|
|
119
123
|
default: {
|
|
120
|
-
const t =
|
|
121
|
-
return t ?
|
|
124
|
+
const t = P.get(e.name);
|
|
125
|
+
return t ? Y(e, t) : null;
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
|
-
function
|
|
129
|
+
function L(e) {
|
|
126
130
|
return {
|
|
127
131
|
type: "paragraph",
|
|
128
|
-
children: e.children.map(f).filter(
|
|
132
|
+
children: e.children.map(f).filter(m)
|
|
129
133
|
};
|
|
130
134
|
}
|
|
131
|
-
function
|
|
135
|
+
function A(e) {
|
|
132
136
|
return {
|
|
133
137
|
type: "blockquote",
|
|
134
|
-
children: e.children.filter((t) => t.type === "element").map((t) => u(t)).filter(
|
|
138
|
+
children: e.children.filter((t) => t.type === "element").map((t) => u(t)).filter(m)
|
|
135
139
|
};
|
|
136
140
|
}
|
|
137
141
|
function y(e, t) {
|
|
@@ -139,73 +143,73 @@ function y(e, t) {
|
|
|
139
143
|
type: "list",
|
|
140
144
|
ordered: t,
|
|
141
145
|
spread: !1,
|
|
142
|
-
children: e.children.filter((
|
|
146
|
+
children: e.children.filter((i) => i.type === "element").map((i) => O(i))
|
|
143
147
|
};
|
|
144
148
|
}
|
|
145
|
-
function
|
|
149
|
+
function O(e) {
|
|
146
150
|
return {
|
|
147
151
|
type: "listItem",
|
|
148
152
|
spread: !1,
|
|
149
|
-
children: e.children.filter((t) => t.type === "element").map((t) => u(t)).filter(
|
|
153
|
+
children: e.children.filter((t) => t.type === "element").map((t) => u(t)).filter(m)
|
|
150
154
|
};
|
|
151
155
|
}
|
|
152
|
-
function
|
|
156
|
+
function j(e) {
|
|
153
157
|
return {
|
|
154
158
|
type: "code",
|
|
155
159
|
lang: (e.attributes ?? {}).language ?? null,
|
|
156
160
|
value: p(e)
|
|
157
161
|
};
|
|
158
162
|
}
|
|
159
|
-
function
|
|
163
|
+
function R(e) {
|
|
160
164
|
const t = e.children;
|
|
161
|
-
return t.length > 0 && t[0].type === "text" ? { type: "math", value: p(e) } : { type: "math", value: t.filter((
|
|
165
|
+
return t.length > 0 && t[0].type === "text" ? { type: "math", value: p(e) } : { type: "math", value: t.filter((n) => n.type === "element" && n.name === "mrow").map((n) => p(n)).join(` \\\\
|
|
162
166
|
`) };
|
|
163
167
|
}
|
|
164
|
-
function
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
for (const [
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
(
|
|
171
|
-
),
|
|
172
|
-
if (
|
|
173
|
-
const
|
|
168
|
+
function Y(e, t) {
|
|
169
|
+
const i = e.attributes ?? {}, n = e.children, r = {};
|
|
170
|
+
i["xml:id"] && (r.id = i["xml:id"]);
|
|
171
|
+
for (const [o, l] of Object.entries(i))
|
|
172
|
+
o === "xml:id" || l == null || (r[o] = l);
|
|
173
|
+
const c = n.find(
|
|
174
|
+
(o) => o.type === "element" && o.name === "title"
|
|
175
|
+
), s = [];
|
|
176
|
+
if (c) {
|
|
177
|
+
const o = {
|
|
174
178
|
type: "paragraph",
|
|
175
179
|
data: { directiveLabel: !0 },
|
|
176
|
-
children:
|
|
180
|
+
children: c.children.map(f).filter(m)
|
|
177
181
|
};
|
|
178
|
-
|
|
182
|
+
s.push(o);
|
|
179
183
|
}
|
|
180
|
-
if (
|
|
181
|
-
for (const
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
185
|
-
if (
|
|
186
|
-
for (const
|
|
187
|
-
if (
|
|
188
|
-
const d = u(
|
|
189
|
-
d &&
|
|
184
|
+
if (D.has(t.category))
|
|
185
|
+
for (const o of n) {
|
|
186
|
+
if (o.type !== "element") continue;
|
|
187
|
+
const l = o;
|
|
188
|
+
if (l.name !== "title")
|
|
189
|
+
if (l.name === "statement")
|
|
190
|
+
for (const a of l.children) {
|
|
191
|
+
if (a.type !== "element") continue;
|
|
192
|
+
const d = u(a);
|
|
193
|
+
d && s.push(d);
|
|
190
194
|
}
|
|
191
195
|
else {
|
|
192
|
-
const
|
|
193
|
-
|
|
196
|
+
const a = u(l);
|
|
197
|
+
a && s.push(a);
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
else
|
|
197
|
-
for (const
|
|
198
|
-
if (
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
201
|
-
const
|
|
202
|
-
|
|
201
|
+
for (const o of n) {
|
|
202
|
+
if (o.type !== "element") continue;
|
|
203
|
+
const l = o;
|
|
204
|
+
if (l.name === "title") continue;
|
|
205
|
+
const a = u(l);
|
|
206
|
+
a && s.push(a);
|
|
203
207
|
}
|
|
204
208
|
return {
|
|
205
209
|
type: "containerDirective",
|
|
206
210
|
name: t.name,
|
|
207
|
-
attributes: Object.keys(
|
|
208
|
-
children:
|
|
211
|
+
attributes: Object.keys(r).length > 0 ? r : void 0,
|
|
212
|
+
children: s
|
|
209
213
|
};
|
|
210
214
|
}
|
|
211
215
|
function f(e) {
|
|
@@ -217,12 +221,12 @@ function f(e) {
|
|
|
217
221
|
case "em":
|
|
218
222
|
return {
|
|
219
223
|
type: "emphasis",
|
|
220
|
-
children: t.children.map(f).filter(
|
|
224
|
+
children: t.children.map(f).filter(m)
|
|
221
225
|
};
|
|
222
226
|
case "alert":
|
|
223
227
|
return {
|
|
224
228
|
type: "strong",
|
|
225
|
-
children: t.children.map(f).filter(
|
|
229
|
+
children: t.children.map(f).filter(m)
|
|
226
230
|
};
|
|
227
231
|
case "c":
|
|
228
232
|
return { type: "inlineCode", value: p(t) };
|
|
@@ -232,20 +236,23 @@ function f(e) {
|
|
|
232
236
|
return null;
|
|
233
237
|
}
|
|
234
238
|
}
|
|
235
|
-
function
|
|
239
|
+
function m(e) {
|
|
236
240
|
return e !== null;
|
|
237
241
|
}
|
|
238
|
-
function
|
|
239
|
-
const t =
|
|
240
|
-
extensions: [
|
|
241
|
-
}),
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
function H(e) {
|
|
243
|
+
const t = N(e), i = E(t, {
|
|
244
|
+
extensions: [w(), _()]
|
|
245
|
+
}), n = x(e.children);
|
|
246
|
+
if (!n) return i;
|
|
247
|
+
const r = [];
|
|
248
|
+
return n.name !== "chapter" && r.push(`division: ${n.name}`), n.attributes.xmlid && r.push(`xmlid: ${n.attributes.xmlid}`), n.attributes.label && r.push(`label: ${n.attributes.label}`), n.attributes.component && r.push(`component: ${n.attributes.component}`), r.length === 0 ? i : `---
|
|
249
|
+
${r.join(`
|
|
250
|
+
`)}
|
|
244
251
|
---
|
|
245
252
|
|
|
246
|
-
${
|
|
253
|
+
${i}`;
|
|
247
254
|
}
|
|
248
255
|
export {
|
|
249
|
-
|
|
250
|
-
|
|
256
|
+
H as ptxastToMarkdown,
|
|
257
|
+
N as ptxastToMdast
|
|
251
258
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Root as MdastRoot } from 'mdast';
|
|
2
2
|
import { Root, ElementContent } from '@pretextbook/ptxast';
|
|
3
3
|
export declare const DIVISION_TYPE_NAMES: Set<string>;
|
|
4
|
+
export declare const TITLELESS_DIVISION_TYPES: Set<string>;
|
|
4
5
|
/**
|
|
5
6
|
* Structural container types whose content should be recursed into
|
|
6
7
|
* without emitting a heading, and without changing the current depth.
|
|
@@ -10,6 +11,23 @@ export declare const DIVISION_TYPE_NAMES: Set<string>;
|
|
|
10
11
|
export declare const TRANSPARENT_TYPES: Set<string>;
|
|
11
12
|
/** Convert an xast Root (PreTeXt document) to an mdast Root. */
|
|
12
13
|
export declare function ptxastToMdast(root: Root): MdastRoot;
|
|
14
|
+
/** The outermost division's name plus the subset of its attributes that
|
|
15
|
+
* round-trip through markdown frontmatter (`xmlid`, `label`, `component`). */
|
|
16
|
+
export interface TopLevelDivisionInfo {
|
|
17
|
+
name: string;
|
|
18
|
+
attributes: {
|
|
19
|
+
xmlid?: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
component?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Find the outermost division in a ptxast tree (skipping transparent
|
|
26
|
+
* structural wrappers), i.e. the division a depth-1 heading would represent
|
|
27
|
+
* if this tree were flattened to markdown — along with its `xml:id`/
|
|
28
|
+
* `label`/`component` attributes, for round-tripping into frontmatter.
|
|
29
|
+
*/
|
|
30
|
+
export declare function findTopLevelDivisionInfo(nodes: ElementContent[]): TopLevelDivisionInfo | undefined;
|
|
13
31
|
/**
|
|
14
32
|
* Find the name of the outermost division in a ptxast tree (skipping
|
|
15
33
|
* transparent structural wrappers), i.e. the division a depth-1 heading
|
|
@@ -4,8 +4,10 @@ export { ptxastToMdast } from './ptxast-to-mdast.js';
|
|
|
4
4
|
* Convert an xast Root (PreTeXt document) to a markdown string using the directive
|
|
5
5
|
* syntax for PreTeXt block environments.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* A leading frontmatter block is prepended when the outermost division
|
|
8
|
+
* carries information that markdown can't otherwise represent: a
|
|
9
|
+
* `division:` field when it isn't `chapter` (the default a depth-1 heading
|
|
10
|
+
* is assumed to mean), and `xmlid:`/`label:`/`component:` fields mirroring
|
|
11
|
+
* that division's `xml:id`/`label`/`component` attributes.
|
|
10
12
|
*/
|
|
11
13
|
export declare function ptxastToMarkdown(root: Root): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pretextbook/ptxast-util-to-mdast",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Convert ptxast to mdast (markdown AST) and markdown strings",
|
|
5
5
|
"author": "Oscar Levin",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "vitest run"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@pretextbook/ptxast": "^0.0.
|
|
42
|
+
"@pretextbook/ptxast": "^0.0.7",
|
|
43
43
|
"@types/mdast": "^4.0.0",
|
|
44
44
|
"mdast-util-directive": "^3.0.0",
|
|
45
45
|
"mdast-util-math": "^3.0.0",
|