@pretextbook/remark-pretext 0.0.6 → 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/README.md CHANGED
@@ -86,6 +86,58 @@ There are two ways to change it:
86
86
  // → '<section><title>Title</title><subsection>...'
87
87
  ```
88
88
 
89
+ ### Section-like divisions
90
+
91
+ `division:` also accepts a set of section-like types that don't belong to
92
+ the part/chapter/.../paragraphs hierarchy: `worksheet`, `exercises`,
93
+ `references`, `appendix`, `glossary`, `handout`, `solutions`,
94
+ `reading-questions`, `introduction`, and `conclusion`.
95
+
96
+ `appendix` nests like `chapter` (deeper headings become `section`,
97
+ `subsection`, etc.), since the PreTeXt schema allows nested sections inside
98
+ an appendix. The rest don't support nested sections, so any heading deeper
99
+ than the top-level one becomes a `<paragraphs>` division instead:
100
+
101
+ ```markdown
102
+ ---
103
+ division: worksheet
104
+ ---
105
+
106
+ # Worksheet on Limits
107
+
108
+ ## Part A
109
+
110
+ A `<paragraphs>` division, titled "Part A".
111
+ ```
112
+
113
+ ### Attributes from frontmatter
114
+
115
+ `xmlid:`, `label:`, and `component:` frontmatter fields become `xml:id`,
116
+ `label`, and `component` attributes on the document's first top-level
117
+ division:
118
+
119
+ ```markdown
120
+ ---
121
+ division: section
122
+ xmlid: limits-intro
123
+ label: sec-limits-intro
124
+ component: limits
125
+ ---
126
+
127
+ # Introduction to Limits
128
+ ```
129
+
130
+ ```xml
131
+ <section xml:id="limits-intro" label="sec-limits-intro" component="limits">
132
+ <title>Introduction to Limits</title>
133
+ ...
134
+ </section>
135
+ ```
136
+
137
+ Pass `topLevelAttributes` to `remarkPretext` or `markdownToPretext` to set
138
+ these explicitly instead; like `topLevelDivision`, it overrides frontmatter
139
+ when both are present.
140
+
89
141
  ## Syntax Rules
90
142
 
91
143
  - `:::name[optional title]{#id attr=val}` opens a block directive
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("unified"),j=require("remark-parse"),B=require("remark-directive"),z=require("@pretextbook/ptxast"),W=require("unist-util-visit"),I={theorem:{type:"theorem",category:"theorem-like",requiresStatement:!0},lemma:{type:"lemma",category:"theorem-like",requiresStatement:!0},corollary:{type:"corollary",category:"theorem-like",requiresStatement:!0},proposition:{type:"proposition",category:"theorem-like",requiresStatement:!0},claim:{type:"claim",category:"theorem-like",requiresStatement:!0},fact:{type:"fact",category:"theorem-like",requiresStatement:!0},conjecture:{type:"conjecture",category:"theorem-like",requiresStatement:!0},axiom:{type:"axiom",category:"theorem-like",requiresStatement:!0},principle:{type:"principle",category:"theorem-like",requiresStatement:!0},hypothesis:{type:"hypothesis",category:"theorem-like",requiresStatement:!0},algorithm:{type:"algorithm",category:"theorem-like",requiresStatement:!0},definition:{type:"definition",category:"definition-like",requiresStatement:!0},notation:{type:"notation",category:"definition-like",requiresStatement:!0},remark:{type:"remark",category:"remark-like",requiresStatement:!1},note:{type:"note",category:"remark-like",requiresStatement:!1},observation:{type:"observation",category:"remark-like",requiresStatement:!1},warning:{type:"warning",category:"remark-like",requiresStatement:!1},insight:{type:"insight",category:"remark-like",requiresStatement:!1},assemblage:{type:"assemblage",category:"remark-like",requiresStatement:!1},example:{type:"example",category:"example-like",requiresStatement:!1},question:{type:"question",category:"example-like",requiresStatement:!1},problem:{type:"problem",category:"example-like",requiresStatement:!1},exercise:{type:"exercise",category:"example-like",requiresStatement:!0,hasNestedTasks:!0},activity:{type:"activity",category:"example-like",requiresStatement:!1},exploration:{type:"exploration",category:"example-like",requiresStatement:!1},investigation:{type:"investigation",category:"example-like",requiresStatement:!1},project:{type:"project",category:"example-like",requiresStatement:!0,hasNestedTasks:!0},task:{type:"task",category:"example-like",requiresStatement:!0,hasNestedTasks:!0},proof:{type:"proof",category:"proof-like",requiresStatement:!1},case:{type:"case",category:"proof-like",requiresStatement:!1},solution:{type:"solution",category:"solution-like",requiresStatement:!1},hint:{type:"hint",category:"solution-like",requiresStatement:!1},answer:{type:"answer",category:"solution-like",requiresStatement:!1}},se=I;function le(e){return I[e.toLowerCase()]}const $=new Set(Object.entries(I).filter(([e,t])=>t.category==="proof-like"||t.category==="solution-like").map(([e])=>e));function x(e,t,o){return{type:"element",name:e,attributes:o??{},children:t}}function C(e){return e.type==="containerDirective"&&e.name==="task"}function ce(e){return e.type==="containerDirective"&&$.has(e.name)}function w(e){const t=[];for(const o of e)o.name==="ul"||o.name==="ol"?t.length>0&&t[t.length-1]?.name==="p"?t[t.length-1].children.push(o):t.push(x("p",[o])):t.push(o);return t}function ae(e,t,o,n,r,i,s){const l=[];if(o&&l.push(o),e.hasNestedTasks){const c=n.findIndex(C);if(c!==-1){const a=[];for(let p=0;p<n.length;p++)C(n[p])&&a.push(p);const u=a[a.length-1],d=n.slice(0,c),m=n.slice(c).filter(C),v=[],y=[],O=[];for(let p=c;p<n.length;p++){const f=n[p];if(!C(f)){if(p<u){v.push(f);continue}if(ce(f)){O.push(f);continue}y.push(f)}}if(v.length>0&&(r.messages??(r.messages=[])).push({type:"warning",reason:`Dropped ${v.length} non-task node(s) between task directives in ${e.type}.`,category:"dropped-content-between-tasks",position:v[0].position?.start}),d.length>0){const p=w(d.map(f=>i(f,r)).filter(f=>f!==null));p.length>0&&l.push(x("introduction",p))}for(const p of m){const f=s(p,r);f&&l.push(f)}if(y.length>0){const p=w(y.map(f=>i(f,r)).filter(f=>f!==null));p.length>0&&l.push(x("conclusion",p))}for(const p of O){const f=s(p,r);f&&l.push(f)}}else N(l,e,n,r,i,s)}else N(l,e,n,r,i,s);return x(e.type,l,t)}function N(e,t,o,n,r,i){if(t.requiresStatement){const s=[],l=[];for(const c of o)if(c.type==="containerDirective"&&$.has(c.name)){const a=i(c,n);a&&l.push(a)}else s.push(c);if(s.length>0){const c=w(s.map(a=>r(a,n)).filter(a=>a!==null));c.length>0&&e.push(x("statement",c))}e.push(...l)}else{const s=w(o.map(l=>r(l,n)).filter(l=>l!==null));e.push(...s)}}function U(e){return{type:"text",value:e}}function h(e,t,o){return{type:"element",name:e,attributes:o??{},children:t}}function g(e,t,o){return h(e,[U(t)],o)}function H(e){return{type:"comment",value:e.replace(/--/g,"- -")}}function F(e,t){const o=e?.position,n=o?.start?.offset,r=o?.end?.offset;return t.source&&n!=null&&r!=null?t.source.slice(n,r):""}function Z(e,t,o){return h("TODO",[H(`todo: ${t}`),g("pre",o)],{type:e})}function ue(e,t,o){return h("TODO",[H(`todo: ${t}`),g("c",o)],{type:e})}function V(e){const t=[];for(const o of e)o.name==="ul"||o.name==="ol"?t.length>0&&t[t.length-1]?.name==="p"?t[t.length-1].children.push(o):t.push(h("p",[o])):t.push(o);return t}function T(e,t,o){return pe(e,t,o).tree}function pe(e,t,o){const n=[],r={ancestors:[],depth:0,messages:n,source:t,topLevelDivision:o?.topLevelDivision??"chapter"},i=e.children;return{tree:{type:"root",children:X(i,r)},messages:n}}function X(e,t,o=!1){let n=7;for(const a of e)a.type==="heading"&&(n=Math.min(n,a.depth));if(n===7)return D(e,t,o);const r=[];let i=null,s=[],l=[];const c=()=>{i&&(r.push(fe(i,l,t)),i=null,l=[])};for(const a of e)a.type==="heading"&&a.depth===n?(!i&&s.length>0&&(r.push(...D(s,t,o)),s=[]),c(),i=a,l=[]):i?l.push(a):s.push(a);return!i&&s.length>0&&r.push(...D(s,t,o)),c(),r}function D(e,t,o=!1){const n=[];for(let r=0;r<e.length;r+=1){const i=e[r],s=E(i,t);if(s!==null){if(s.name==="p"&&s.children.length===1&&s.children[0].name==="md"){const l=s.children[0],c=n[n.length-1],a=r+1<e.length?E(e[r+1],t):null,u=a?.name==="p"?a.children:null;if(c?.name==="p")c.children.push(l),u&&(c.children.push(...u),r+=1);else{const d=[l];u&&(d.push(...u),r+=1),n.push(h("p",d))}continue}if((s.name==="ul"||s.name==="ol")&&n.length>0){const l=n[n.length-1];if(l?.name==="p"){l.children.push(s);continue}}n.push(s)}}return o?V(n):n}function fe(e,t,o){const n=z.divisionTypeAtRelativeDepth(o.topLevelDivision,e.depth),r=h("title",b(e.children,o)),i=he(e),s=X(t,{...o,depth:o.depth+1},!0),l=V(s);return h(n,[r,...l],i)}function he(e){const t=e.data;return t?.id?{"xml:id":t.id}:void 0}const de={paragraph:(e,t)=>K(e,t),blockquote:(e,t)=>me(e,t),list:(e,t)=>ge(e,t),code:(e,t)=>ke(e),containerDirective:(e,t)=>Y(e,t)};function E(e,t){const o=de[e.type];return o?o(e,t):(t.messages&&t.messages.push({type:"warning",reason:`Unknown block type: ${e.type}`,category:"unknown-block-type"}),Z("unknown-block-type",`unknown block type "${e.type}"`,F(e,t)))}function K(e,t){return h("p",b(e.children,t))}function me(e,t){const o=e.children.filter(n=>n.type==="paragraph").map(n=>{const r={...t,ancestors:[...t.ancestors,e],depth:t.depth+1};return K(n,r)});return h("blockquote",o)}function ge(e,t){const o=e.children.map(n=>{const r={...t,ancestors:[...t.ancestors,e],depth:t.depth+1};return ye(n,r)});return h(e.ordered?"ol":"ul",o)}function ye(e,t){const o=D(e.children,t);return h("li",o)}function ke(e,t){return g("program",e.value,e.lang?{language:e.lang}:void 0)}function ve(e,t){const o=e.value.split(/\\\\|[\r\n]+/).map(n=>n.trim()).filter(n=>n.length>0);return o.length>1?h("md",o.map(n=>g("mrow",n))):g("md",o[0]??"")}function xe(e,t){return e.meta==="inline"?g("m",e.value):ve(e)}function Y(e,t){const o=le(e.name);if(!o)return t.messages&&t.messages.push({type:"warning",reason:`Unknown directive: ${e.name}`,category:"unknown-directive"}),Z("unknown-directive",`unknown directive "${e.name}"`,F(e,t));const n=Ce(e),r=e.children,{title:i,body:s}=be(r,t),l={...t,ancestors:[...t.ancestors,e],depth:t.depth+1};return ae(o,n,i,s,l,(c,a)=>E(c,a),(c,a)=>Y(c,a))}function be(e,t){const o=e[0];return o?.type==="paragraph"&&o.data?.directiveLabel===!0?{title:h("title",b(o.children,t)),body:e.slice(1)}:{title:null,body:e}}function Ce(e){const t=e.attributes??{},o={};for(const[n,r]of Object.entries(t))r!=null&&(o[n==="id"?"xml:id":n]=r);return Object.keys(o).length>0?o:void 0}function De(e,t){return!t||e.position?.start?.offset===null||e.position?.start?.offset===void 0?"asterisk":t.charAt(e.position.start.offset)==="_"?"underscore":"asterisk"}const we={text:(e,t)=>U(e.value),emphasis:(e,t)=>{const n=De(e,t.source)==="underscore"?"term":"em";return h(n,b(e.children,t))},strong:(e,t)=>h("alert",b(e.children,t)),inlineCode:(e,t)=>g("c",e.value),math:(e,t)=>xe(e)};function b(e,t){return e.flatMap(o=>Se(o,t)).filter(o=>o!==null)}function Se(e,t){const o=we[e.type];if(!o)return t.messages&&t.messages.push({type:"warning",reason:`Unknown inline type: ${e.type}`,category:"unknown-inline-type"}),ue("unknown-inline-type",`unknown inline type "${e.type}"`,F(e,t));const n={...t,ancestors:[...t.ancestors,e]};return o(e,n)}const Ie=[{open:"$$",close:"$$",isDisplay:!0},{open:"\\[",close:"\\]",isDisplay:!0},{open:"$",close:"$",isDisplay:!1},{open:"\\(",close:"\\)",isDisplay:!1}],G="PTX_MATH_TOKEN_",q=new RegExp(`${G}(\\d+)`,"g");function J(e,t){let o=null;for(const n of Ie){const r=e.indexOf(n.open,t);if(r===-1)continue;const i=e.indexOf(n.close,r+n.open.length);if(i!==-1&&!(n.open==="$"&&(r>0&&e[r-1]==="$"||r+1<e.length&&e[r+1]==="$"))&&(!o||r<o.index)){const s=e.substring(r+n.open.length,i);o={index:r,pattern:n,content:s}}}return o}function qe(e,t){let o=t;for(;o<e.length;){const n=e.indexOf("`",o);if(n===-1)return null;let r=0,i=n;for(;i<e.length&&e[i]==="`";)r++,i++;const s="`".repeat(r);let l=i;for(;l<e.length;){const c=e.indexOf(s,l);if(c===-1)break;const a=c+r;if(a>=e.length||e[a]!=="`")return{start:n,end:a};l=c+1}o=n+r}return null}function Te(e){const t=new Map;let o="",n=0,r=0;for(;n<e.length;){const i=qe(e,n),s=J(e,n);if(i&&(!s||i.start<s.index)){o+=e.substring(n,i.end),n=i.end;continue}if(!s){o+=e.substring(n);break}o+=e.substring(n,s.index);const l=`${G}${r}`;o+=l,t.set(l,{type:"math",value:s.content,meta:s.pattern.isDisplay?"display":"inline"}),n=s.index+s.pattern.open.length+s.content.length+s.pattern.close.length,r+=1}return{markdown:o,tokens:t}}function Ee(e){const t=[];let o=0;for(;o<e.length;){const n=J(e,o);if(!n){o<e.length&&t.push({type:"text",value:e.substring(o)});break}n.index>o&&t.push({type:"text",value:e.substring(o,n.index)}),t.push({type:"math",value:n.content,meta:n.pattern.isDisplay?"display":"inline"}),o=n.index+n.pattern.open.length+n.content.length+n.pattern.close.length}return t.length===0?[{type:"text",value:e}]:t}function Me(e,t){const o=[];let n=0;q.lastIndex=0;let r=q.exec(e);for(;r;){const i=r.index,s=r[0];i>n&&o.push({type:"text",value:e.substring(n,i)});const l=t.get(s);l?o.push(l):o.push({type:"text",value:s}),n=i+s.length,r=q.exec(e)}return n<e.length&&o.push({type:"text",value:e.substring(n)}),o.length===0?[{type:"text",value:e}]:o}function Q(e){W.visit(e,"paragraph",t=>{const o=t.children||[],n=[];for(const r of o)if(r.type==="text"){const i=Ee(r.value);n.push(...i)}else n.push(r);t.children=n})}function Le(e,t){W.visit(e,"paragraph",o=>{const n=o.children||[],r=[];for(const i of n)if(i.type==="text"){const s=Me(i.value,t);r.push(...s)}else r.push(i);o.children=r})}const $e=()=>e=>{Q(e)};function Fe(e){const t=e.trim();if(!t.startsWith(":"))return null;let o=0;for(let i=0;i<t.length&&t[i]===":";i++)o++;if(o<3)return null;const n=t.slice(o).trim(),r=n.match(/^([a-zA-Z0-9_-]+)(\[[^\]]*\])?(\{[^}]*\})?$/);return n===""?{colons:o,label:null,lineIndex:-1,isOpen:!1}:r?{colons:o,label:r[0],lineIndex:-1,isOpen:!0}:null}function Oe(e){const t=[],o=[];for(const n of e)if(n.isOpen){const r={colons:n.colons,finalColons:n.colons,label:n.label,openLineIndex:n.lineIndex,closeLineIndex:null,children:[],parent:null};if(t.length>0){const i=t[t.length-1];r.parent=i,i.children.push(r)}else o.push(r);t.push(r)}else{const r=t[t.length-1];r&&r.colons===n.colons&&(r.closeLineIndex=n.lineIndex,t.pop())}return o}function ee(e){if(e.children.length===0)e.finalColons=e.colons;else{const t=Math.max(...e.children.map(ee));e.finalColons=Math.max(e.colons,t+1)}return e.finalColons}function Ne(e,t,o){const n=e.slice(),r=[],i=t.slice();for(;i.length>0;){const s=i.shift();r.push(s),i.push(...s.children)}for(const s of r){if(s.openLineIndex>=0){const l=n[s.openLineIndex],c=l.match(/^:+/)?.[0].length||3,a=l.slice(c);n[s.openLineIndex]=":".repeat(s.finalColons)+a}s.closeLineIndex!==null&&s.closeLineIndex>=0&&(n[s.closeLineIndex]=":".repeat(s.finalColons))}return n}function Ae(e){const t=e.split(`
2
- `),o=[];let n=!1,r=null;for(let l=0;l<t.length;l++){const c=t[l],u=c.trim().match(/^(`{3,}|~{3,})/);if(u){const m=u[1];n?r&&m[0]===r[0]&&m.length>=r.length&&(n=!1,r=null):(n=!0,r=m);continue}if(n)continue;const d=Fe(c);d&&o.push({...d,lineIndex:l})}if(o.length===0)return e;const i=Oe(o);for(const l of i)ee(l);return Ne(t,i).join(`
3
- `)}function Pe(e){const t=e.trim();if(!t.endsWith(":"))return null;const o=t.slice(0,-1);if(!/^[a-zA-Z]/.test(o))return null;const n=o.match(/^([a-zA-Z][a-zA-Z0-9_-]*)(.*)$/);if(!n)return null;const[,r,i]=n;return i&&!/^(\[[^\]]*\]|\{[^}]*\})*$/.test(i)||!I[r.toLowerCase()]?null:o}function M(e){let t=0;for(let o=0;o<e.length;o++)if(e[o]===" ")t+=1;else if(e[o]===" ")t+=4;else break;return t}function Re(e,t){const o=M(e[t]);for(let n=t+1;n<e.length;n++)if(!te(e[n]))return M(e[n])>o;return!1}function te(e){return e.trim()===""}function _e(e,t){let o=0,n=0;for(;n<e.length&&o<t;)if(e[n]===" ")o++,n++;else if(e[n]===" ")o+=4,n++;else break;return e.slice(n)}function je(e){const t=e.split(`
4
- `),o=[],n={level:0,openDirectives:[],inCodeFence:!1,codeFenceMarker:null};for(let r=0;r<t.length;r++){const i=t[r],s=i.trim(),l=M(i),c=s.match(/^(`{3,}|~{3,})/);if(c){const u=c[1];n.inCodeFence?n.codeFenceMarker&&s.startsWith(n.codeFenceMarker)&&(n.inCodeFence=!1,n.codeFenceMarker=null):(n.inCodeFence=!0,n.codeFenceMarker=u),o.push(i);continue}if(n.inCodeFence){o.push(i);continue}if(te(i)){o.push("");continue}const a=Pe(s);if(a&&Re(t,r)){for(;n.openDirectives.length>0&&!(n.openDirectives[n.openDirectives.length-1].indentLevel<l);){const y=n.openDirectives.pop();y&&o.push(":".repeat(y.colonCount))}const u=a.match(/^([a-zA-Z][a-zA-Z0-9_-]*)(.*)/),d=u?u[1].toLowerCase()+(u[2]||""):a,m=n.openDirectives.length*1+3;o.push(":".repeat(m)+d),n.openDirectives.push({label:d,indentLevel:l,colonCount:m,bodyBaseIndent:-1}),n.level=l}else{for(;n.openDirectives.length>0&&l<=n.openDirectives[n.openDirectives.length-1].indentLevel;){const u=n.openDirectives.pop();u&&o.push(":".repeat(u.colonCount))}if(n.openDirectives.length>0){const u=n.openDirectives[n.openDirectives.length-1];u.bodyBaseIndent<0&&(u.bodyBaseIndent=l),o.push(_e(i,u.bodyBaseIndent))}else o.push(i);n.level=l}}for(;n.openDirectives.length>0;){const r=n.openDirectives.pop();r&&o.push(":".repeat(r.colonCount))}return o.join(`
5
- `)}const Be=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/,ze=/^division:\s*(\S+)\s*$/m;function We(e){const t=e.match(Be);if(!t)return{body:e};const o=t[1],n=e.slice(t[0].length),i=o.match(ze)?.[1];return{division:i&&z.isDivisionType(i)?i:void 0,body:n}}const ne=function(e){return function(o,n){if(typeof n?.value=="string"){const r=We(n.value),i=e?.topLevelDivision??r.division??"chapter",s=je(r.body),l=Ae(s),c=Te(l),u=_.unified().data("micromarkExtensions",[{disable:{null:["codeIndented"]}}]).use(j).use(B).parse(c.markdown);return Le(u,c.tokens),T(u,c.markdown,{topLevelDivision:i})}return Q(o),T(o,void 0,{topLevelDivision:e?.topLevelDivision??"chapter"})}},Ue=/["&'<>`]/g,He=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ze=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Ve=/[|\\{}()[\]^$+*?.]/g,A=new WeakMap;function Xe(e,t){if(e=e.replace(t.subset?Ke(t.subset):Ue,n),t.subset||t.escapeOnly)return e;return e.replace(He,o).replace(Ze,n);function o(r,i,s){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,s.charCodeAt(i+2),t)}function n(r,i,s){return t.format(r.charCodeAt(0),s.charCodeAt(i+1),t)}}function Ke(e){let t=A.get(e);return t||(t=Ye(e),A.set(e,t)),t}function Ye(e){const t=[];let o=-1;for(;++o<e.length;)t.push(e[o].replace(Ve,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}function Ge(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Je(e,t){return Xe(e,Object.assign({format:Ge},t))}const Qe=/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g;function k(e,t,o){const n=et(e);return o?n.replace(o,r):r(n);function r(i){return Je(i,{subset:t})}}function et(e){return String(e||"").replace(Qe,"")}const tt=/]]>/g,nt=[">"];function ot(e){return"<![CDATA["+k(e.value,nt,tt)+"]]>"}function rt(e){return"<!--"+k(e.value,["-"])+"-->"}const it=[" ",`
6
- `," ",'"',"&","'","/","<","=",">"];function S(e){return k(e,it)}function P(e,t){const o=String(e);if(typeof t!="string")throw new TypeError("Expected character");let n=0,r=o.indexOf(t);for(;r!==-1;)n++,r=o.indexOf(t,r+t.length);return n}function L(e,t){const o=String(e);let n=t.options.quote||'"';if(t.options.quoteSmart){const r=n==='"'?"'":'"';P(o,n)>P(o,r)&&(n=r)}return n+k(o,["<","&",n])+n}function st(e,t){const o=S(e.name),n=e.public,r=e.system;let i="<!DOCTYPE";return o!==""&&(i+=" "+o),n?i+=" PUBLIC "+L(n,t):r&&(i+=" SYSTEM"),r&&(i+=" "+L(r,t)),i+">"}const lt={}.hasOwnProperty;function ct(e,t){const o=S(e.name),n=ie(e,t),r=e.attributes||{},i=n?!1:t.options.closeEmptyElements,s=[];let l;for(l in r)if(lt.call(r,l)){const c=r[l];c!=null&&s.push(S(l)+"="+L(c,t))}return"<"+o+(s.length===0?"":" "+s.join(" "))+(i?(t.options.tightClose?"":" ")+"/":"")+">"+n+(i?"":"</"+o+">")}const at=/\?>/g,ut=[">"];function pt(e){const t=S(e.name)||"x",o=k(e.value,ut,at);return"<?"+t+(o?" "+o:"")+"?>"}const ft=["&","<"];function oe(e){return k(e.value,ft)}function ht(e,t){return t.options.allowDangerousXml?e.value:oe(e)}const dt={}.hasOwnProperty,R={cdata:ot,comment:rt,doctype:st,element:ct,instruction:pt,raw:ht,root:ie,text:oe};function re(e,t){const o=e&&e.type;if(!o)throw new Error("Expected node, not `"+e+"`");if(!dt.call(R,o))throw new Error("Cannot compile unknown node `"+o+"`");const n=R[o];return n(e,t)}function ie(e,t){const o=e&&e.children||[];let n=-1;const r=[];for(;++n<o.length;)r[n]=re(o[n],t);return r.join("")}function mt(e,t){const o={options:{}};if(typeof o.options.quote=="string"&&o.options.quote!=='"'&&o.options.quote!=="'")throw new Error("Invalid quote `"+o.options.quote+"`, expected `'` or `\"`");const n=Array.isArray(e)?{type:"root",children:e}:e;return re(n,o)}function gt(e,t){const o=_.unified().use(j).use(B).use(ne,t),n=o.parse(e),r=o.runSync(n,{value:e});return mt(r.children)}exports.DIRECTIVE_MAP=se;exports.PROOF_SOLUTION_NAMES=$;exports.markdownToPretext=gt;exports.mdastToPtxast=T;exports.remarkMath=$e;exports.remarkPretext=ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("unified"),W=require("remark-parse"),U=require("remark-directive"),$=require("@pretextbook/ptxast"),H=require("unist-util-visit"),L={theorem:{type:"theorem",category:"theorem-like",requiresStatement:!0},lemma:{type:"lemma",category:"theorem-like",requiresStatement:!0},corollary:{type:"corollary",category:"theorem-like",requiresStatement:!0},proposition:{type:"proposition",category:"theorem-like",requiresStatement:!0},claim:{type:"claim",category:"theorem-like",requiresStatement:!0},fact:{type:"fact",category:"theorem-like",requiresStatement:!0},conjecture:{type:"conjecture",category:"theorem-like",requiresStatement:!0},axiom:{type:"axiom",category:"theorem-like",requiresStatement:!0},principle:{type:"principle",category:"theorem-like",requiresStatement:!0},hypothesis:{type:"hypothesis",category:"theorem-like",requiresStatement:!0},algorithm:{type:"algorithm",category:"theorem-like",requiresStatement:!0},definition:{type:"definition",category:"definition-like",requiresStatement:!0},notation:{type:"notation",category:"definition-like",requiresStatement:!0},remark:{type:"remark",category:"remark-like",requiresStatement:!1},note:{type:"note",category:"remark-like",requiresStatement:!1},observation:{type:"observation",category:"remark-like",requiresStatement:!1},warning:{type:"warning",category:"remark-like",requiresStatement:!1},insight:{type:"insight",category:"remark-like",requiresStatement:!1},assemblage:{type:"assemblage",category:"remark-like",requiresStatement:!1},example:{type:"example",category:"example-like",requiresStatement:!1},question:{type:"question",category:"example-like",requiresStatement:!1},problem:{type:"problem",category:"example-like",requiresStatement:!1},exercise:{type:"exercise",category:"example-like",requiresStatement:!0,hasNestedTasks:!0},activity:{type:"activity",category:"example-like",requiresStatement:!1},exploration:{type:"exploration",category:"example-like",requiresStatement:!1},investigation:{type:"investigation",category:"example-like",requiresStatement:!1},project:{type:"project",category:"example-like",requiresStatement:!0,hasNestedTasks:!0},task:{type:"task",category:"example-like",requiresStatement:!0,hasNestedTasks:!0},proof:{type:"proof",category:"proof-like",requiresStatement:!1},case:{type:"case",category:"proof-like",requiresStatement:!1},solution:{type:"solution",category:"solution-like",requiresStatement:!1},hint:{type:"hint",category:"solution-like",requiresStatement:!1},answer:{type:"answer",category:"solution-like",requiresStatement:!1}},le=L;function ce(e){return L[e.toLowerCase()]}const F=new Set(Object.entries(L).filter(([e,t])=>t.category==="proof-like"||t.category==="solution-like").map(([e])=>e));function b(e,t,n){return{type:"element",name:e,attributes:n??{},children:t}}function D(e){return e.type==="containerDirective"&&e.name==="task"}function ae(e){return e.type==="containerDirective"&&F.has(e.name)}function w(e){const t=[];for(const n of e)n.name==="ul"||n.name==="ol"?t.length>0&&t[t.length-1]?.name==="p"?t[t.length-1].children.push(n):t.push(b("p",[n])):t.push(n);return t}function ue(e,t,n,o,r,i,s){const l=[];if(n&&l.push(n),e.hasNestedTasks){const c=o.findIndex(D);if(c!==-1){const a=[];for(let p=0;p<o.length;p++)D(o[p])&&a.push(p);const u=a[a.length-1],d=o.slice(0,c),m=o.slice(c).filter(D),k=[],y=[],_=[];for(let p=c;p<o.length;p++){const f=o[p];if(!D(f)){if(p<u){k.push(f);continue}if(ae(f)){_.push(f);continue}y.push(f)}}if(k.length>0&&(r.messages??(r.messages=[])).push({type:"warning",reason:`Dropped ${k.length} non-task node(s) between task directives in ${e.type}.`,category:"dropped-content-between-tasks",position:k[0].position?.start}),d.length>0){const p=w(d.map(f=>i(f,r)).filter(f=>f!==null));p.length>0&&l.push(b("introduction",p))}for(const p of m){const f=s(p,r);f&&l.push(f)}if(y.length>0){const p=w(y.map(f=>i(f,r)).filter(f=>f!==null));p.length>0&&l.push(b("conclusion",p))}for(const p of _){const f=s(p,r);f&&l.push(f)}}else P(l,e,o,r,i,s)}else P(l,e,o,r,i,s);return b(e.type,l,t)}function P(e,t,n,o,r,i){if(t.requiresStatement){const s=[],l=[];for(const c of n)if(c.type==="containerDirective"&&F.has(c.name)){const a=i(c,o);a&&l.push(a)}else s.push(c);if(s.length>0){const c=w(s.map(a=>r(a,o)).filter(a=>a!==null));c.length>0&&e.push(b("statement",c))}e.push(...l)}else{const s=w(n.map(l=>r(l,o)).filter(l=>l!==null));e.push(...s)}}function V(e){return{type:"text",value:e}}function h(e,t,n){return{type:"element",name:e,attributes:n??{},children:t}}function g(e,t,n){return h(e,[V(t)],n)}function Z(e){return{type:"comment",value:e.replace(/--/g,"- -")}}function O(e,t){const n=e?.position,o=n?.start?.offset,r=n?.end?.offset;return t.source&&o!=null&&r!=null?t.source.slice(o,r):""}function X(e,t,n){return h("TODO",[Z(`todo: ${t}`),g("pre",n)],{type:e})}function pe(e,t,n){return h("TODO",[Z(`todo: ${t}`),g("c",n)],{type:e})}function N(e){const t=[];for(const n of e)n.name==="ul"||n.name==="ol"?t.length>0&&t[t.length-1]?.name==="p"?t[t.length-1].children.push(n):t.push(h("p",[n])):t.push(n);return t}function q(e,t,n){return fe(e,t,n).tree}function fe(e,t,n){const o=[],r={ancestors:[],depth:0,messages:o,source:t,topLevelDivision:n?.topLevelDivision??"chapter",topLevelAttributes:n?.topLevelAttributes,topLevelAttributesApplied:n?.topLevelAttributes?{done:!1}:void 0},i=e.children;if($.isTitlelessDivisionType(r.topLevelDivision)){const l=K(r),c=N(T(i,{...r,depth:1},!0));return{tree:{type:"root",children:[h(r.topLevelDivision,c,l)]},messages:o}}return{tree:{type:"root",children:T(i,r)},messages:o}}function T(e,t,n=!1){let o=7;for(const a of e)a.type==="heading"&&(o=Math.min(o,a.depth));if(o===7)return C(e,t,n);const r=[];let i=null,s=[],l=[];const c=()=>{i&&(r.push(he(i,l,t)),i=null,l=[])};for(const a of e)a.type==="heading"&&a.depth===o?(!i&&s.length>0&&(r.push(...C(s,t,n)),s=[]),c(),i=a,l=[]):i?l.push(a):s.push(a);return!i&&s.length>0&&r.push(...C(s,t,n)),c(),r}function C(e,t,n=!1){const o=[];for(let r=0;r<e.length;r+=1){const i=e[r],s=E(i,t);if(s!==null){if(s.name==="p"&&s.children.length===1&&s.children[0].name==="md"){const l=s.children[0],c=o[o.length-1],a=r+1<e.length?E(e[r+1],t):null,u=a?.name==="p"?a.children:null;if(c?.name==="p")c.children.push(l),u&&(c.children.push(...u),r+=1);else{const d=[l];u&&(d.push(...u),r+=1),o.push(h("p",d))}continue}if((s.name==="ul"||s.name==="ol")&&o.length>0){const l=o[o.length-1];if(l?.name==="p"){l.children.push(s);continue}}o.push(s)}}return n?N(o):o}function he(e,t,n){const o=$.divisionTypeAtRelativeDepth(n.topLevelDivision,e.depth),r=h("title",x(e.children,n)),i=me(e,n),s=T(t,{...n,depth:n.depth+1},!0),l=N(s);return h(o,[r,...l],i)}function de(e){const t=e.data;return t?.id?{"xml:id":t.id}:void 0}function me(e,t){const n=de(e),o=K(t);if(!(!n&&!o))return{...o,...n}}function K(e){if(e.depth!==0)return;const t=e.topLevelAttributesApplied;if(!(!e.topLevelAttributes||!t||t.done))return t.done=!0,e.topLevelAttributes}const ge={paragraph:(e,t)=>Y(e,t),blockquote:(e,t)=>ye(e,t),list:(e,t)=>ve(e,t),code:(e,t)=>be(e),containerDirective:(e,t)=>G(e,t)};function E(e,t){const n=ge[e.type];return n?n(e,t):(t.messages&&t.messages.push({type:"warning",reason:`Unknown block type: ${e.type}`,category:"unknown-block-type"}),X("unknown-block-type",`unknown block type "${e.type}"`,O(e,t)))}function Y(e,t){return h("p",x(e.children,t))}function ye(e,t){const n=e.children.filter(o=>o.type==="paragraph").map(o=>{const r={...t,ancestors:[...t.ancestors,e],depth:t.depth+1};return Y(o,r)});return h("blockquote",n)}function ve(e,t){const n=e.children.map(o=>{const r={...t,ancestors:[...t.ancestors,e],depth:t.depth+1};return ke(o,r)});return h(e.ordered?"ol":"ul",n)}function ke(e,t){const n=C(e.children,t);return h("li",n)}function be(e,t){return g("program",e.value,e.lang?{language:e.lang}:void 0)}function xe(e,t){const n=e.value.split(/\\\\|[\r\n]+/).map(o=>o.trim()).filter(o=>o.length>0);return n.length>1?h("md",n.map(o=>g("mrow",o))):g("md",n[0]??"")}function De(e,t){return e.meta==="inline"?g("m",e.value):xe(e)}function G(e,t){const n=ce(e.name);if(!n)return t.messages&&t.messages.push({type:"warning",reason:`Unknown directive: ${e.name}`,category:"unknown-directive"}),X("unknown-directive",`unknown directive "${e.name}"`,O(e,t));const o=we(e),r=e.children,{title:i,body:s}=Ce(r,t),l={...t,ancestors:[...t.ancestors,e],depth:t.depth+1};return ue(n,o,i,s,l,(c,a)=>E(c,a),(c,a)=>G(c,a))}function Ce(e,t){const n=e[0];return n?.type==="paragraph"&&n.data?.directiveLabel===!0?{title:h("title",x(n.children,t)),body:e.slice(1)}:{title:null,body:e}}function we(e){const t=e.attributes??{},n={};for(const[o,r]of Object.entries(t))r!=null&&(n[o==="id"?"xml:id":o]=r);return Object.keys(n).length>0?n:void 0}function Se(e,t){return!t||e.position?.start?.offset===null||e.position?.start?.offset===void 0?"asterisk":t.charAt(e.position.start.offset)==="_"?"underscore":"asterisk"}const Le={text:(e,t)=>V(e.value),emphasis:(e,t)=>{const o=Se(e,t.source)==="underscore"?"term":"em";return h(o,x(e.children,t))},strong:(e,t)=>h("alert",x(e.children,t)),inlineCode:(e,t)=>g("c",e.value),math:(e,t)=>De(e)};function x(e,t){return e.flatMap(n=>Ie(n,t)).filter(n=>n!==null)}function Ie(e,t){const n=Le[e.type];if(!n)return t.messages&&t.messages.push({type:"warning",reason:`Unknown inline type: ${e.type}`,category:"unknown-inline-type"}),pe("unknown-inline-type",`unknown inline type "${e.type}"`,O(e,t));const o={...t,ancestors:[...t.ancestors,e]};return n(e,o)}const qe=[{open:"$$",close:"$$",isDisplay:!0},{open:"\\[",close:"\\]",isDisplay:!0},{open:"$",close:"$",isDisplay:!1},{open:"\\(",close:"\\)",isDisplay:!1}],J="PTX_MATH_TOKEN_",I=new RegExp(`${J}(\\d+)`,"g");function Q(e,t){let n=null;for(const o of qe){const r=e.indexOf(o.open,t);if(r===-1)continue;const i=e.indexOf(o.close,r+o.open.length);if(i!==-1&&!(o.open==="$"&&(r>0&&e[r-1]==="$"||r+1<e.length&&e[r+1]==="$"))&&(!n||r<n.index)){const s=e.substring(r+o.open.length,i);n={index:r,pattern:o,content:s}}}return n}function Te(e,t){let n=t;for(;n<e.length;){const o=e.indexOf("`",n);if(o===-1)return null;let r=0,i=o;for(;i<e.length&&e[i]==="`";)r++,i++;const s="`".repeat(r);let l=i;for(;l<e.length;){const c=e.indexOf(s,l);if(c===-1)break;const a=c+r;if(a>=e.length||e[a]!=="`")return{start:o,end:a};l=c+1}n=o+r}return null}function Ee(e){const t=new Map;let n="",o=0,r=0;for(;o<e.length;){const i=Te(e,o),s=Q(e,o);if(i&&(!s||i.start<s.index)){n+=e.substring(o,i.end),o=i.end;continue}if(!s){n+=e.substring(o);break}n+=e.substring(o,s.index);const l=`${J}${r}`;n+=l,t.set(l,{type:"math",value:s.content,meta:s.pattern.isDisplay?"display":"inline"}),o=s.index+s.pattern.open.length+s.content.length+s.pattern.close.length,r+=1}return{markdown:n,tokens:t}}function Ae(e){const t=[];let n=0;for(;n<e.length;){const o=Q(e,n);if(!o){n<e.length&&t.push({type:"text",value:e.substring(n)});break}o.index>n&&t.push({type:"text",value:e.substring(n,o.index)}),t.push({type:"math",value:o.content,meta:o.pattern.isDisplay?"display":"inline"}),n=o.index+o.pattern.open.length+o.content.length+o.pattern.close.length}return t.length===0?[{type:"text",value:e}]:t}function Me(e,t){const n=[];let o=0;I.lastIndex=0;let r=I.exec(e);for(;r;){const i=r.index,s=r[0];i>o&&n.push({type:"text",value:e.substring(o,i)});const l=t.get(s);l?n.push(l):n.push({type:"text",value:s}),o=i+s.length,r=I.exec(e)}return o<e.length&&n.push({type:"text",value:e.substring(o)}),n.length===0?[{type:"text",value:e}]:n}function ee(e){H.visit(e,"paragraph",t=>{const n=t.children||[],o=[];for(const r of n)if(r.type==="text"){const i=Ae(r.value);o.push(...i)}else o.push(r);t.children=o})}function $e(e,t){H.visit(e,"paragraph",n=>{const o=n.children||[],r=[];for(const i of o)if(i.type==="text"){const s=Me(i.value,t);r.push(...s)}else r.push(i);n.children=r})}const Fe=()=>e=>{ee(e)};function Oe(e){const t=e.trim();if(!t.startsWith(":"))return null;let n=0;for(let i=0;i<t.length&&t[i]===":";i++)n++;if(n<3)return null;const o=t.slice(n).trim(),r=o.match(/^([a-zA-Z0-9_-]+)(\[[^\]]*\])?(\{[^}]*\})?$/);return o===""?{colons:n,label:null,lineIndex:-1,isOpen:!1}:r?{colons:n,label:r[0],lineIndex:-1,isOpen:!0}:null}function Ne(e){const t=[],n=[];for(const o of e)if(o.isOpen){const r={colons:o.colons,finalColons:o.colons,label:o.label,openLineIndex:o.lineIndex,closeLineIndex:null,children:[],parent:null};if(t.length>0){const i=t[t.length-1];r.parent=i,i.children.push(r)}else n.push(r);t.push(r)}else{const r=t[t.length-1];r&&r.colons===o.colons&&(r.closeLineIndex=o.lineIndex,t.pop())}return n}function te(e){if(e.children.length===0)e.finalColons=e.colons;else{const t=Math.max(...e.children.map(te));e.finalColons=Math.max(e.colons,t+1)}return e.finalColons}function _e(e,t,n){const o=e.slice(),r=[],i=t.slice();for(;i.length>0;){const s=i.shift();r.push(s),i.push(...s.children)}for(const s of r){if(s.openLineIndex>=0){const l=o[s.openLineIndex],c=l.match(/^:+/)?.[0].length||3,a=l.slice(c);o[s.openLineIndex]=":".repeat(s.finalColons)+a}s.closeLineIndex!==null&&s.closeLineIndex>=0&&(o[s.closeLineIndex]=":".repeat(s.finalColons))}return o}function Pe(e){const t=e.split(`
2
+ `),n=[];let o=!1,r=null;for(let l=0;l<t.length;l++){const c=t[l],u=c.trim().match(/^(`{3,}|~{3,})/);if(u){const m=u[1];o?r&&m[0]===r[0]&&m.length>=r.length&&(o=!1,r=null):(o=!0,r=m);continue}if(o)continue;const d=Oe(c);d&&n.push({...d,lineIndex:l})}if(n.length===0)return e;const i=Ne(n);for(const l of i)te(l);return _e(t,i).join(`
3
+ `)}function Re(e){const t=e.trim();if(!t.endsWith(":"))return null;const n=t.slice(0,-1);if(!/^[a-zA-Z]/.test(n))return null;const o=n.match(/^([a-zA-Z][a-zA-Z0-9_-]*)(.*)$/);if(!o)return null;const[,r,i]=o;return i&&!/^(\[[^\]]*\]|\{[^}]*\})*$/.test(i)||!L[r.toLowerCase()]?null:n}function A(e){let t=0;for(let n=0;n<e.length;n++)if(e[n]===" ")t+=1;else if(e[n]===" ")t+=4;else break;return t}function je(e,t){const n=A(e[t]);for(let o=t+1;o<e.length;o++)if(!ne(e[o]))return A(e[o])>n;return!1}function ne(e){return e.trim()===""}function Be(e,t){let n=0,o=0;for(;o<e.length&&n<t;)if(e[o]===" ")n++,o++;else if(e[o]===" ")n+=4,o++;else break;return e.slice(o)}function ze(e){const t=e.split(`
4
+ `),n=[],o={level:0,openDirectives:[],inCodeFence:!1,codeFenceMarker:null};for(let r=0;r<t.length;r++){const i=t[r],s=i.trim(),l=A(i),c=s.match(/^(`{3,}|~{3,})/);if(c){const u=c[1];o.inCodeFence?o.codeFenceMarker&&s.startsWith(o.codeFenceMarker)&&(o.inCodeFence=!1,o.codeFenceMarker=null):(o.inCodeFence=!0,o.codeFenceMarker=u),n.push(i);continue}if(o.inCodeFence){n.push(i);continue}if(ne(i)){n.push("");continue}const a=Re(s);if(a&&je(t,r)){for(;o.openDirectives.length>0&&!(o.openDirectives[o.openDirectives.length-1].indentLevel<l);){const y=o.openDirectives.pop();y&&n.push(":".repeat(y.colonCount))}const u=a.match(/^([a-zA-Z][a-zA-Z0-9_-]*)(.*)/),d=u?u[1].toLowerCase()+(u[2]||""):a,m=o.openDirectives.length*1+3;n.push(":".repeat(m)+d),o.openDirectives.push({label:d,indentLevel:l,colonCount:m,bodyBaseIndent:-1}),o.level=l}else{for(;o.openDirectives.length>0&&l<=o.openDirectives[o.openDirectives.length-1].indentLevel;){const u=o.openDirectives.pop();u&&n.push(":".repeat(u.colonCount))}if(o.openDirectives.length>0){const u=o.openDirectives[o.openDirectives.length-1];u.bodyBaseIndent<0&&(u.bodyBaseIndent=l),n.push(Be(i,u.bodyBaseIndent))}else n.push(i);o.level=l}}for(;o.openDirectives.length>0;){const r=o.openDirectives.pop();r&&n.push(":".repeat(r.colonCount))}return n.join(`
5
+ `)}const We=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/,Ue=/^division:\s*(\S+)\s*$/m,He=/^xmlid:\s*(\S+)\s*$/m,Ve=/^label:\s*(\S+)\s*$/m,Ze=/^component:\s*(\S+)\s*$/m;function Xe(e){const t=e.match(We);if(!t)return{body:e};const n=t[1],o=e.slice(t[0].length),r=n.match(Ue)?.[1],i=r&&$.isTopLevelDivisionType(r)?r:void 0,s={},l=n.match(He)?.[1],c=n.match(Ve)?.[1],a=n.match(Ze)?.[1];return l&&(s["xml:id"]=l),c&&(s.label=c),a&&(s.component=a),{division:i,attributes:Object.keys(s).length>0?s:void 0,body:o}}const oe=function(e){return function(n,o){if(typeof o?.value=="string"){const r=Xe(o.value),i=e?.topLevelDivision??r.division??"chapter",s=e?.topLevelAttributes??r.attributes,l=ze(r.body),c=Pe(l),a=Ee(c),d=z.unified().data("micromarkExtensions",[{disable:{null:["codeIndented"]}}]).use(W).use(U).parse(a.markdown);return $e(d,a.tokens),q(d,a.markdown,{topLevelDivision:i,topLevelAttributes:s})}return ee(n),q(n,void 0,{topLevelDivision:e?.topLevelDivision??"chapter",topLevelAttributes:e?.topLevelAttributes})}},Ke=/["&'<>`]/g,Ye=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ge=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Je=/[|\\{}()[\]^$+*?.]/g,R=new WeakMap;function Qe(e,t){if(e=e.replace(t.subset?et(t.subset):Ke,o),t.subset||t.escapeOnly)return e;return e.replace(Ye,n).replace(Ge,o);function n(r,i,s){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,s.charCodeAt(i+2),t)}function o(r,i,s){return t.format(r.charCodeAt(0),s.charCodeAt(i+1),t)}}function et(e){let t=R.get(e);return t||(t=tt(e),R.set(e,t)),t}function tt(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(Je,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}function nt(e){return"&#x"+e.toString(16).toUpperCase()+";"}function ot(e,t){return Qe(e,Object.assign({format:nt},t))}const rt=/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g;function v(e,t,n){const o=it(e);return n?o.replace(n,r):r(o);function r(i){return ot(i,{subset:t})}}function it(e){return String(e||"").replace(rt,"")}const st=/]]>/g,lt=[">"];function ct(e){return"<![CDATA["+v(e.value,lt,st)+"]]>"}function at(e){return"<!--"+v(e.value,["-"])+"-->"}const ut=[" ",`
6
+ `," ",'"',"&","'","/","<","=",">"];function S(e){return v(e,ut)}function j(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let o=0,r=n.indexOf(t);for(;r!==-1;)o++,r=n.indexOf(t,r+t.length);return o}function M(e,t){const n=String(e);let o=t.options.quote||'"';if(t.options.quoteSmart){const r=o==='"'?"'":'"';j(n,o)>j(n,r)&&(o=r)}return o+v(n,["<","&",o])+o}function pt(e,t){const n=S(e.name),o=e.public,r=e.system;let i="<!DOCTYPE";return n!==""&&(i+=" "+n),o?i+=" PUBLIC "+M(o,t):r&&(i+=" SYSTEM"),r&&(i+=" "+M(r,t)),i+">"}const ft={}.hasOwnProperty;function ht(e,t){const n=S(e.name),o=se(e,t),r=e.attributes||{},i=o?!1:t.options.closeEmptyElements,s=[];let l;for(l in r)if(ft.call(r,l)){const c=r[l];c!=null&&s.push(S(l)+"="+M(c,t))}return"<"+n+(s.length===0?"":" "+s.join(" "))+(i?(t.options.tightClose?"":" ")+"/":"")+">"+o+(i?"":"</"+n+">")}const dt=/\?>/g,mt=[">"];function gt(e){const t=S(e.name)||"x",n=v(e.value,mt,dt);return"<?"+t+(n?" "+n:"")+"?>"}const yt=["&","<"];function re(e){return v(e.value,yt)}function vt(e,t){return t.options.allowDangerousXml?e.value:re(e)}const kt={}.hasOwnProperty,B={cdata:ct,comment:at,doctype:pt,element:ht,instruction:gt,raw:vt,root:se,text:re};function ie(e,t){const n=e&&e.type;if(!n)throw new Error("Expected node, not `"+e+"`");if(!kt.call(B,n))throw new Error("Cannot compile unknown node `"+n+"`");const o=B[n];return o(e,t)}function se(e,t){const n=e&&e.children||[];let o=-1;const r=[];for(;++o<n.length;)r[o]=ie(n[o],t);return r.join("")}function bt(e,t){const n={options:{}};if(typeof n.options.quote=="string"&&n.options.quote!=='"'&&n.options.quote!=="'")throw new Error("Invalid quote `"+n.options.quote+"`, expected `'` or `\"`");const o=Array.isArray(e)?{type:"root",children:e}:e;return ie(o,n)}function xt(e,t){const n=z.unified().use(W).use(U).use(oe,t),o=n.parse(e),r=n.runSync(o,{value:e});return bt(r.children)}exports.DIRECTIVE_MAP=le;exports.PROOF_SOLUTION_NAMES=F;exports.markdownToPretext=xt;exports.mdastToPtxast=q;exports.remarkMath=Fe;exports.remarkPretext=oe;