@hyperbook/markdown 0.44.1 → 0.46.0
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/assets/client.js +32 -27
- package/dist/assets/directive-collapsible/style.css +19 -23
- package/dist/assets/directive-tabs/client.js +31 -27
- package/dist/assets/directive-tabs/style.css +95 -12
- package/dist/assets/directive-typst/client.js +631 -0
- package/dist/assets/directive-typst/style.css +466 -0
- package/dist/assets/prism/prism-typst.js +182 -0
- package/dist/assets/shell.css +55 -22
- package/dist/assets/store.js +2 -1
- package/dist/assets/uzip/uzip.js +1538 -0
- package/dist/index.js +548 -89
- package/dist/index.js.map +4 -4
- package/dist/locales/de.json +21 -1
- package/dist/locales/en.json +21 -1
- package/dist/remarkDirectiveTypst.d.ts +5 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -61265,6 +61265,7 @@ function remarkDirectiveTabs_default(ctx) {
|
|
|
61265
61265
|
if (!tabsId) {
|
|
61266
61266
|
tabsId = hash(node3);
|
|
61267
61267
|
}
|
|
61268
|
+
const instanceId = hash(node3);
|
|
61268
61269
|
registerDirective(
|
|
61269
61270
|
file,
|
|
61270
61271
|
"tabs",
|
|
@@ -61291,8 +61292,23 @@ function remarkDirectiveTabs_default(ctx) {
|
|
|
61291
61292
|
}
|
|
61292
61293
|
tabTitleElements.push({
|
|
61293
61294
|
type: "element",
|
|
61294
|
-
tagName: "
|
|
61295
|
+
tagName: "input",
|
|
61295
61296
|
properties: {
|
|
61297
|
+
type: "radio",
|
|
61298
|
+
name: `tabs-${instanceId}`,
|
|
61299
|
+
id: `tab-${instanceId}-${tabId}`,
|
|
61300
|
+
"data-tab-id": tabId,
|
|
61301
|
+
"data-tabs-id": tabsId,
|
|
61302
|
+
class: "tab-input",
|
|
61303
|
+
checked: first
|
|
61304
|
+
},
|
|
61305
|
+
children: []
|
|
61306
|
+
});
|
|
61307
|
+
tabTitleElements.push({
|
|
61308
|
+
type: "element",
|
|
61309
|
+
tagName: "label",
|
|
61310
|
+
properties: {
|
|
61311
|
+
for: `tab-${instanceId}-${tabId}`,
|
|
61296
61312
|
"data-tab-id": tabId,
|
|
61297
61313
|
"data-tabs-id": tabsId,
|
|
61298
61314
|
class: "tab" + (first ? " active" : "")
|
|
@@ -61312,7 +61328,15 @@ function remarkDirectiveTabs_default(ctx) {
|
|
|
61312
61328
|
});
|
|
61313
61329
|
first = false;
|
|
61314
61330
|
}
|
|
61331
|
+
const radioInputs = [];
|
|
61332
|
+
const labelElements = [];
|
|
61333
|
+
for (let i = 0; i < tabTitleElements.length; i += 2) {
|
|
61334
|
+
radioInputs.push(tabTitleElements[i]);
|
|
61335
|
+
labelElements.push(tabTitleElements[i + 1]);
|
|
61336
|
+
}
|
|
61315
61337
|
data.hChildren = [
|
|
61338
|
+
...radioInputs,
|
|
61339
|
+
// Radio inputs as direct children
|
|
61316
61340
|
{
|
|
61317
61341
|
type: "element",
|
|
61318
61342
|
tagName: "div",
|
|
@@ -61320,7 +61344,8 @@ function remarkDirectiveTabs_default(ctx) {
|
|
|
61320
61344
|
class: "tabs",
|
|
61321
61345
|
"data-tabs-id": tabsId
|
|
61322
61346
|
},
|
|
61323
|
-
children:
|
|
61347
|
+
children: labelElements
|
|
61348
|
+
// Only labels in tabs div
|
|
61324
61349
|
},
|
|
61325
61350
|
...tabContentElements
|
|
61326
61351
|
];
|
|
@@ -61488,7 +61513,27 @@ var en_default = {
|
|
|
61488
61513
|
"webide-reset": "Reset",
|
|
61489
61514
|
"webide-reset-prompt": "Are you sure you want to reset the code?",
|
|
61490
61515
|
"webide-copy": "Copy",
|
|
61491
|
-
"webide-download": "Download"
|
|
61516
|
+
"webide-download": "Download",
|
|
61517
|
+
"typst-code": "Typst",
|
|
61518
|
+
"typst-reset": "Reset",
|
|
61519
|
+
"typst-reset-prompt": "Are you sure you want to reset the code?",
|
|
61520
|
+
"typst-download-pdf": "Download PDF",
|
|
61521
|
+
"typst-pdf-error": "Error exporting PDF",
|
|
61522
|
+
"typst-download-project": "Download Project",
|
|
61523
|
+
"typst-loading": "Loading Typst...",
|
|
61524
|
+
"typst-add-source-file": "Add source file",
|
|
61525
|
+
"typst-add-binary-file": "Add binary file",
|
|
61526
|
+
"typst-source": "Source",
|
|
61527
|
+
"typst-binary": "Binary",
|
|
61528
|
+
"typst-add": "Add",
|
|
61529
|
+
"typst-delete-file": "Delete file",
|
|
61530
|
+
"typst-delete-confirm": "Delete",
|
|
61531
|
+
"typst-filename-prompt": "Enter filename (e.g., helper.typ):",
|
|
61532
|
+
"typst-filename-error": "Filename must end with .typ or .typst",
|
|
61533
|
+
"typst-filename-exists": "File already exists",
|
|
61534
|
+
"typst-file-replace": "Replace existing file?",
|
|
61535
|
+
"typst-binary-files": "Binary Files",
|
|
61536
|
+
"typst-no-binary-files": "No binary files"
|
|
61492
61537
|
};
|
|
61493
61538
|
|
|
61494
61539
|
// locales/de.json
|
|
@@ -61547,7 +61592,27 @@ var de_default = {
|
|
|
61547
61592
|
"webide-reset": "Zur\xFCcksetzen",
|
|
61548
61593
|
"webide-reset-prompt": "Sind Sie sicher, dass Sie den Code zur\xFCcksetzen m\xF6chten?",
|
|
61549
61594
|
"webide-copy": "Kopieren",
|
|
61550
|
-
"webide-download": "Herunterladen"
|
|
61595
|
+
"webide-download": "Herunterladen",
|
|
61596
|
+
"typst-code": "Typst",
|
|
61597
|
+
"typst-reset": "Zur\xFCcksetzen",
|
|
61598
|
+
"typst-reset-prompt": "Sind Sie sicher, dass Sie den Code zur\xFCcksetzen m\xF6chten?",
|
|
61599
|
+
"typst-download-pdf": "PDF herunterladen",
|
|
61600
|
+
"typst-pdf-error": "Fehler beim PDF-Export",
|
|
61601
|
+
"typst-download-project": "Projekt herunterladen",
|
|
61602
|
+
"typst-loading": "Typst wird geladen...",
|
|
61603
|
+
"typst-add-source-file": "Quelldatei hinzuf\xFCgen",
|
|
61604
|
+
"typst-add-binary-file": "Bin\xE4rdatei hinzuf\xFCgen",
|
|
61605
|
+
"typst-source": "Quelle",
|
|
61606
|
+
"typst-binary": "Bin\xE4r",
|
|
61607
|
+
"typst-add": "Hinzuf\xFCgen",
|
|
61608
|
+
"typst-delete-file": "Datei l\xF6schen",
|
|
61609
|
+
"typst-delete-confirm": "L\xF6schen",
|
|
61610
|
+
"typst-filename-prompt": "Dateiname eingeben (z.B. helper.typ):",
|
|
61611
|
+
"typst-filename-error": "Dateiname muss auf .typ oder .typst enden",
|
|
61612
|
+
"typst-filename-exists": "Datei existiert bereits",
|
|
61613
|
+
"typst-file-replace": "Existierende Datei ersetzen?",
|
|
61614
|
+
"typst-binary-files": "Bin\xE4rdateien",
|
|
61615
|
+
"typst-no-binary-files": "Keine Bin\xE4rdateien"
|
|
61551
61616
|
};
|
|
61552
61617
|
|
|
61553
61618
|
// src/i18n.ts
|
|
@@ -62509,7 +62574,8 @@ var rehypeHtmlStructure_default = (ctx) => () => {
|
|
|
62509
62574
|
type: "element",
|
|
62510
62575
|
tagName: "html",
|
|
62511
62576
|
properties: {
|
|
62512
|
-
lang: config2.language || "es"
|
|
62577
|
+
lang: config2.language || "es",
|
|
62578
|
+
class: "no-js"
|
|
62513
62579
|
},
|
|
62514
62580
|
children: [
|
|
62515
62581
|
{
|
|
@@ -62649,6 +62715,19 @@ var rehypeHtmlStructure_default = (ctx) => () => {
|
|
|
62649
62715
|
}
|
|
62650
62716
|
]
|
|
62651
62717
|
},
|
|
62718
|
+
{
|
|
62719
|
+
type: "element",
|
|
62720
|
+
tagName: "script",
|
|
62721
|
+
properties: {},
|
|
62722
|
+
children: [
|
|
62723
|
+
{
|
|
62724
|
+
type: "raw",
|
|
62725
|
+
value: `
|
|
62726
|
+
// Remove no-js class as soon as JavaScript is available
|
|
62727
|
+
document.documentElement.classList.remove('no-js');`
|
|
62728
|
+
}
|
|
62729
|
+
]
|
|
62730
|
+
},
|
|
62652
62731
|
{
|
|
62653
62732
|
type: "element",
|
|
62654
62733
|
tagName: "script",
|
|
@@ -62727,6 +62806,15 @@ window.Prism.manual = true;`
|
|
|
62727
62806
|
},
|
|
62728
62807
|
children: []
|
|
62729
62808
|
},
|
|
62809
|
+
{
|
|
62810
|
+
type: "element",
|
|
62811
|
+
tagName: "script",
|
|
62812
|
+
properties: {
|
|
62813
|
+
src: makeUrl(["prism", "prism-typst.js"], "assets"),
|
|
62814
|
+
defer: true
|
|
62815
|
+
},
|
|
62816
|
+
children: []
|
|
62817
|
+
},
|
|
62730
62818
|
{
|
|
62731
62819
|
type: "element",
|
|
62732
62820
|
tagName: "link",
|
|
@@ -62979,69 +63067,7 @@ var makeNavigationPageElement = (ctx, page) => {
|
|
|
62979
63067
|
};
|
|
62980
63068
|
var makeNavigationSectionElement = (ctx, section) => {
|
|
62981
63069
|
const { virtual, isEmpty, href, name, pages, sections, expanded } = section;
|
|
62982
|
-
const children = [];
|
|
62983
63070
|
let isExpanded = ctx.navigation.current?.href?.startsWith(href || "") || expanded;
|
|
62984
|
-
if (!virtual) {
|
|
62985
|
-
if (isEmpty) {
|
|
62986
|
-
children.push({
|
|
62987
|
-
type: "element",
|
|
62988
|
-
tagName: "div",
|
|
62989
|
-
properties: {
|
|
62990
|
-
class: [
|
|
62991
|
-
"collapsible",
|
|
62992
|
-
"name",
|
|
62993
|
-
"empty",
|
|
62994
|
-
ctx.navigation.current?.href === href ? "active" : "",
|
|
62995
|
-
isExpanded ? "expanded" : ""
|
|
62996
|
-
].join(" ")
|
|
62997
|
-
},
|
|
62998
|
-
children: [
|
|
62999
|
-
{
|
|
63000
|
-
type: "element",
|
|
63001
|
-
tagName: "span",
|
|
63002
|
-
properties: {
|
|
63003
|
-
class: "label"
|
|
63004
|
-
},
|
|
63005
|
-
children: [
|
|
63006
|
-
{
|
|
63007
|
-
type: "text",
|
|
63008
|
-
value: name
|
|
63009
|
-
}
|
|
63010
|
-
]
|
|
63011
|
-
}
|
|
63012
|
-
]
|
|
63013
|
-
});
|
|
63014
|
-
} else {
|
|
63015
|
-
children.push({
|
|
63016
|
-
type: "element",
|
|
63017
|
-
tagName: "div",
|
|
63018
|
-
properties: {
|
|
63019
|
-
class: [
|
|
63020
|
-
"collapsible",
|
|
63021
|
-
"name",
|
|
63022
|
-
ctx.navigation.current?.href === href ? "active" : "",
|
|
63023
|
-
isExpanded ? "expanded" : ""
|
|
63024
|
-
].join(" ")
|
|
63025
|
-
},
|
|
63026
|
-
children: [
|
|
63027
|
-
{
|
|
63028
|
-
type: "element",
|
|
63029
|
-
tagName: "a",
|
|
63030
|
-
properties: {
|
|
63031
|
-
href: ctx.makeUrl(href || "", "book"),
|
|
63032
|
-
class: "label"
|
|
63033
|
-
},
|
|
63034
|
-
children: [
|
|
63035
|
-
{
|
|
63036
|
-
type: "text",
|
|
63037
|
-
value: name
|
|
63038
|
-
}
|
|
63039
|
-
]
|
|
63040
|
-
}
|
|
63041
|
-
]
|
|
63042
|
-
});
|
|
63043
|
-
}
|
|
63044
|
-
}
|
|
63045
63071
|
const pagesElements = pages.filter((page) => !page.hide).map((page) => makeNavigationPageElement(ctx, page));
|
|
63046
63072
|
const linksElements = [];
|
|
63047
63073
|
if (pagesElements.length > 0) {
|
|
@@ -63056,22 +63082,86 @@ var makeNavigationSectionElement = (ctx, section) => {
|
|
|
63056
63082
|
}
|
|
63057
63083
|
const sectionElements = sections.filter((s3) => !s3.hide).map((s3) => makeNavigationSectionElement(ctx, s3));
|
|
63058
63084
|
linksElements.push(...sectionElements);
|
|
63059
|
-
|
|
63060
|
-
|
|
63061
|
-
|
|
63062
|
-
|
|
63063
|
-
|
|
63064
|
-
|
|
63065
|
-
|
|
63066
|
-
|
|
63085
|
+
if (virtual) {
|
|
63086
|
+
return {
|
|
63087
|
+
type: "element",
|
|
63088
|
+
tagName: "div",
|
|
63089
|
+
properties: {
|
|
63090
|
+
class: "virtual-section"
|
|
63091
|
+
},
|
|
63092
|
+
children: [
|
|
63093
|
+
{
|
|
63094
|
+
type: "element",
|
|
63095
|
+
tagName: "div",
|
|
63096
|
+
properties: {
|
|
63097
|
+
class: "links"
|
|
63098
|
+
},
|
|
63099
|
+
children: linksElements
|
|
63100
|
+
}
|
|
63101
|
+
]
|
|
63102
|
+
};
|
|
63103
|
+
}
|
|
63104
|
+
const summaryChildren = [];
|
|
63105
|
+
if (isEmpty) {
|
|
63106
|
+
summaryChildren.push({
|
|
63107
|
+
type: "element",
|
|
63108
|
+
tagName: "span",
|
|
63109
|
+
properties: {
|
|
63110
|
+
class: "label"
|
|
63111
|
+
},
|
|
63112
|
+
children: [
|
|
63113
|
+
{
|
|
63114
|
+
type: "text",
|
|
63115
|
+
value: name
|
|
63116
|
+
}
|
|
63117
|
+
]
|
|
63118
|
+
});
|
|
63119
|
+
} else {
|
|
63120
|
+
summaryChildren.push({
|
|
63121
|
+
type: "element",
|
|
63122
|
+
tagName: "a",
|
|
63123
|
+
properties: {
|
|
63124
|
+
href: ctx.makeUrl(href || "", "book"),
|
|
63125
|
+
class: "label"
|
|
63126
|
+
},
|
|
63127
|
+
children: [
|
|
63128
|
+
{
|
|
63129
|
+
type: "text",
|
|
63130
|
+
value: name
|
|
63131
|
+
}
|
|
63132
|
+
]
|
|
63133
|
+
});
|
|
63134
|
+
}
|
|
63067
63135
|
return {
|
|
63068
63136
|
type: "element",
|
|
63069
|
-
tagName: "
|
|
63137
|
+
tagName: "details",
|
|
63070
63138
|
properties: {
|
|
63071
63139
|
"data-id": `_nav:${href}`,
|
|
63072
|
-
class:
|
|
63140
|
+
class: [
|
|
63141
|
+
"section",
|
|
63142
|
+
ctx.navigation.current?.href === href ? "active" : "",
|
|
63143
|
+
isEmpty ? "empty" : ""
|
|
63144
|
+
].join(" "),
|
|
63145
|
+
open: isExpanded
|
|
63073
63146
|
},
|
|
63074
|
-
children
|
|
63147
|
+
children: [
|
|
63148
|
+
{
|
|
63149
|
+
type: "element",
|
|
63150
|
+
tagName: "summary",
|
|
63151
|
+
properties: {
|
|
63152
|
+
class: "name"
|
|
63153
|
+
},
|
|
63154
|
+
children: summaryChildren
|
|
63155
|
+
},
|
|
63156
|
+
{
|
|
63157
|
+
type: "element",
|
|
63158
|
+
tagName: "div",
|
|
63159
|
+
properties: {
|
|
63160
|
+
class: "links"
|
|
63161
|
+
},
|
|
63162
|
+
children: linksElements
|
|
63163
|
+
}
|
|
63164
|
+
]
|
|
63075
63165
|
};
|
|
63076
63166
|
};
|
|
63077
63167
|
var makeNavigationElements = (ctx) => {
|
|
@@ -64338,10 +64428,8 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
|
|
|
64338
64428
|
return [
|
|
64339
64429
|
{
|
|
64340
64430
|
type: "element",
|
|
64341
|
-
tagName: "
|
|
64342
|
-
properties: {
|
|
64343
|
-
class: "collapsible"
|
|
64344
|
-
},
|
|
64431
|
+
tagName: "summary",
|
|
64432
|
+
properties: {},
|
|
64345
64433
|
children: [
|
|
64346
64434
|
{
|
|
64347
64435
|
type: "text",
|
|
@@ -64353,7 +64441,7 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
|
|
|
64353
64441
|
type: "element",
|
|
64354
64442
|
tagName: "div",
|
|
64355
64443
|
properties: {
|
|
64356
|
-
class: "
|
|
64444
|
+
class: "content"
|
|
64357
64445
|
},
|
|
64358
64446
|
children: element5.children.flatMap(transformCollapsible)
|
|
64359
64447
|
}
|
|
@@ -64376,7 +64464,7 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
|
|
|
64376
64464
|
expectContainerDirective(node3, file, name);
|
|
64377
64465
|
registerDirective(file, name, [], ["style.css"], []);
|
|
64378
64466
|
node3.attributes = {};
|
|
64379
|
-
data.hName = "
|
|
64467
|
+
data.hName = "details";
|
|
64380
64468
|
data.hProperties = {
|
|
64381
64469
|
class: "directive-collapsible",
|
|
64382
64470
|
"data-id": id
|
|
@@ -64388,10 +64476,8 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
|
|
|
64388
64476
|
data.hChildren = [
|
|
64389
64477
|
{
|
|
64390
64478
|
type: "element",
|
|
64391
|
-
tagName: "
|
|
64392
|
-
properties: {
|
|
64393
|
-
class: "collapsible"
|
|
64394
|
-
},
|
|
64479
|
+
tagName: "summary",
|
|
64480
|
+
properties: {},
|
|
64395
64481
|
children: [
|
|
64396
64482
|
{
|
|
64397
64483
|
type: "text",
|
|
@@ -64403,7 +64489,7 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
|
|
|
64403
64489
|
type: "element",
|
|
64404
64490
|
tagName: "div",
|
|
64405
64491
|
properties: {
|
|
64406
|
-
class: "
|
|
64492
|
+
class: "content"
|
|
64407
64493
|
},
|
|
64408
64494
|
children: collapsibleContent
|
|
64409
64495
|
}
|
|
@@ -78918,6 +79004,378 @@ var remarkDirectiveTextinput_default = (ctx) => () => {
|
|
|
78918
79004
|
};
|
|
78919
79005
|
};
|
|
78920
79006
|
|
|
79007
|
+
// src/remarkDirectiveTypst.ts
|
|
79008
|
+
function htmlEntities4(str) {
|
|
79009
|
+
return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
79010
|
+
}
|
|
79011
|
+
var remarkDirectiveTypst_default = (ctx) => () => {
|
|
79012
|
+
const name = "typst";
|
|
79013
|
+
return (tree, file) => {
|
|
79014
|
+
visit(tree, function(node3) {
|
|
79015
|
+
if (isDirective(node3) && node3.name === name) {
|
|
79016
|
+
const {
|
|
79017
|
+
height = "auto",
|
|
79018
|
+
id = hash(node3),
|
|
79019
|
+
mode = "preview"
|
|
79020
|
+
} = node3.attributes || {};
|
|
79021
|
+
const data = node3.data || (node3.data = {});
|
|
79022
|
+
expectContainerDirective(node3, file, name);
|
|
79023
|
+
registerDirective(file, name, ["client.js"], ["style.css"], []);
|
|
79024
|
+
requestJS(file, ["code-input", "code-input.min.js"]);
|
|
79025
|
+
requestCSS(file, ["code-input", "code-input.min.css"]);
|
|
79026
|
+
requestJS(file, ["code-input", "auto-close-brackets.min.js"]);
|
|
79027
|
+
requestJS(file, ["code-input", "indent.min.js"]);
|
|
79028
|
+
requestJS(file, ["uzip", "uzip.js"]);
|
|
79029
|
+
const sourceFiles = [];
|
|
79030
|
+
const binaryFiles = [];
|
|
79031
|
+
for (const child of node3.children) {
|
|
79032
|
+
if (child.type === "text") {
|
|
79033
|
+
const text9 = child.value;
|
|
79034
|
+
const fileMatches = text9.matchAll(
|
|
79035
|
+
/@file\s+dest="([^"]+)"\s+src="([^"]+)"/g
|
|
79036
|
+
);
|
|
79037
|
+
for (const match of fileMatches) {
|
|
79038
|
+
const dest = match[1];
|
|
79039
|
+
const src = match[2];
|
|
79040
|
+
const url = ctx.makeUrl(
|
|
79041
|
+
src,
|
|
79042
|
+
"public",
|
|
79043
|
+
ctx.navigation.current || void 0
|
|
79044
|
+
);
|
|
79045
|
+
binaryFiles.push({ dest, url });
|
|
79046
|
+
}
|
|
79047
|
+
const sourceMatches = text9.matchAll(
|
|
79048
|
+
/@source\s+dest="([^"]+)"\s+src="([^"]+)"/g
|
|
79049
|
+
);
|
|
79050
|
+
for (const match of sourceMatches) {
|
|
79051
|
+
const dest = match[1];
|
|
79052
|
+
const src = match[2];
|
|
79053
|
+
const content5 = readFile(src, ctx) || "";
|
|
79054
|
+
sourceFiles.push({ filename: dest, content: content5 });
|
|
79055
|
+
}
|
|
79056
|
+
} else if (child.type === "paragraph") {
|
|
79057
|
+
for (const textNode of child.children) {
|
|
79058
|
+
if (textNode.type === "text") {
|
|
79059
|
+
const text9 = textNode.value;
|
|
79060
|
+
const fileMatches = text9.matchAll(
|
|
79061
|
+
/@file\s+dest="([^"]+)"\s+src="([^"]+)"/g
|
|
79062
|
+
);
|
|
79063
|
+
for (const match of fileMatches) {
|
|
79064
|
+
const dest = match[1];
|
|
79065
|
+
const src = match[2];
|
|
79066
|
+
const url = ctx.makeUrl(
|
|
79067
|
+
src,
|
|
79068
|
+
"public",
|
|
79069
|
+
ctx.navigation.current || void 0
|
|
79070
|
+
);
|
|
79071
|
+
binaryFiles.push({ dest, url });
|
|
79072
|
+
}
|
|
79073
|
+
const sourceMatches = text9.matchAll(
|
|
79074
|
+
/@source\s+dest="([^"]+)"\s+src="([^"]+)"/g
|
|
79075
|
+
);
|
|
79076
|
+
for (const match of sourceMatches) {
|
|
79077
|
+
const dest = match[1];
|
|
79078
|
+
const src = match[2];
|
|
79079
|
+
const content5 = readFile(src, ctx) || "";
|
|
79080
|
+
sourceFiles.push({ filename: dest, content: content5 });
|
|
79081
|
+
}
|
|
79082
|
+
}
|
|
79083
|
+
}
|
|
79084
|
+
}
|
|
79085
|
+
}
|
|
79086
|
+
const codeBlocks = node3.children.filter(
|
|
79087
|
+
(n) => n.type === "code" && (n.lang === "typ" || n.lang === "typst")
|
|
79088
|
+
);
|
|
79089
|
+
if (codeBlocks.length > 0) {
|
|
79090
|
+
for (const codeBlock of codeBlocks) {
|
|
79091
|
+
const filename = codeBlock.meta?.trim() || "main.typ";
|
|
79092
|
+
sourceFiles.push({
|
|
79093
|
+
filename,
|
|
79094
|
+
content: codeBlock.value
|
|
79095
|
+
});
|
|
79096
|
+
}
|
|
79097
|
+
}
|
|
79098
|
+
let mainSource = sourceFiles.find(
|
|
79099
|
+
(f) => f.filename == "main.typ" || f.filename == "main.typst"
|
|
79100
|
+
);
|
|
79101
|
+
if (!mainSource && sourceFiles.length > 0) {
|
|
79102
|
+
mainSource = sourceFiles[0];
|
|
79103
|
+
} else if (!mainSource) {
|
|
79104
|
+
mainSource = { filename: "main.typ", content: "" };
|
|
79105
|
+
}
|
|
79106
|
+
const isEditMode = mode === "edit";
|
|
79107
|
+
const isPreviewMode = mode === "preview" || !isEditMode;
|
|
79108
|
+
data.hName = "div";
|
|
79109
|
+
data.hProperties = {
|
|
79110
|
+
class: ["directive-typst", isPreviewMode ? "preview-only" : ""].join(" ").trim(),
|
|
79111
|
+
"data-id": id,
|
|
79112
|
+
"data-source-files": Buffer.from(
|
|
79113
|
+
JSON.stringify(sourceFiles)
|
|
79114
|
+
).toString("base64"),
|
|
79115
|
+
"data-binary-files": Buffer.from(
|
|
79116
|
+
JSON.stringify(binaryFiles)
|
|
79117
|
+
).toString("base64")
|
|
79118
|
+
};
|
|
79119
|
+
const previewContainer = {
|
|
79120
|
+
type: "element",
|
|
79121
|
+
tagName: "div",
|
|
79122
|
+
properties: {
|
|
79123
|
+
class: "preview-container",
|
|
79124
|
+
style: `height: ${height};`
|
|
79125
|
+
},
|
|
79126
|
+
children: [
|
|
79127
|
+
{
|
|
79128
|
+
type: "element",
|
|
79129
|
+
tagName: "div",
|
|
79130
|
+
properties: {
|
|
79131
|
+
class: "typst-loading"
|
|
79132
|
+
},
|
|
79133
|
+
children: [
|
|
79134
|
+
{
|
|
79135
|
+
type: "element",
|
|
79136
|
+
tagName: "div",
|
|
79137
|
+
properties: {
|
|
79138
|
+
class: "typst-spinner"
|
|
79139
|
+
},
|
|
79140
|
+
children: []
|
|
79141
|
+
},
|
|
79142
|
+
{
|
|
79143
|
+
type: "element",
|
|
79144
|
+
tagName: "span",
|
|
79145
|
+
properties: {},
|
|
79146
|
+
children: [
|
|
79147
|
+
{
|
|
79148
|
+
type: "text",
|
|
79149
|
+
value: i18n.get("typst-loading")
|
|
79150
|
+
}
|
|
79151
|
+
]
|
|
79152
|
+
}
|
|
79153
|
+
]
|
|
79154
|
+
},
|
|
79155
|
+
{
|
|
79156
|
+
type: "element",
|
|
79157
|
+
tagName: "div",
|
|
79158
|
+
properties: {
|
|
79159
|
+
class: "typst-preview"
|
|
79160
|
+
},
|
|
79161
|
+
children: []
|
|
79162
|
+
}
|
|
79163
|
+
]
|
|
79164
|
+
};
|
|
79165
|
+
const downloadButton = {
|
|
79166
|
+
type: "element",
|
|
79167
|
+
tagName: "button",
|
|
79168
|
+
properties: {
|
|
79169
|
+
class: "download-pdf"
|
|
79170
|
+
},
|
|
79171
|
+
children: [
|
|
79172
|
+
{
|
|
79173
|
+
type: "text",
|
|
79174
|
+
value: i18n.get("typst-download-pdf")
|
|
79175
|
+
}
|
|
79176
|
+
]
|
|
79177
|
+
};
|
|
79178
|
+
const downloadProjectButton = {
|
|
79179
|
+
type: "element",
|
|
79180
|
+
tagName: "button",
|
|
79181
|
+
properties: {
|
|
79182
|
+
class: "download-project"
|
|
79183
|
+
},
|
|
79184
|
+
children: [
|
|
79185
|
+
{
|
|
79186
|
+
type: "text",
|
|
79187
|
+
value: i18n.get("typst-download-project")
|
|
79188
|
+
}
|
|
79189
|
+
]
|
|
79190
|
+
};
|
|
79191
|
+
if (isEditMode) {
|
|
79192
|
+
data.hChildren = [
|
|
79193
|
+
previewContainer,
|
|
79194
|
+
{
|
|
79195
|
+
type: "element",
|
|
79196
|
+
tagName: "div",
|
|
79197
|
+
properties: {
|
|
79198
|
+
class: "editor-container"
|
|
79199
|
+
},
|
|
79200
|
+
children: [
|
|
79201
|
+
{
|
|
79202
|
+
type: "element",
|
|
79203
|
+
tagName: "div",
|
|
79204
|
+
properties: {
|
|
79205
|
+
class: "file-tabs"
|
|
79206
|
+
},
|
|
79207
|
+
children: [
|
|
79208
|
+
{
|
|
79209
|
+
type: "element",
|
|
79210
|
+
tagName: "div",
|
|
79211
|
+
properties: {
|
|
79212
|
+
class: "tabs-list"
|
|
79213
|
+
},
|
|
79214
|
+
children: []
|
|
79215
|
+
},
|
|
79216
|
+
{
|
|
79217
|
+
type: "element",
|
|
79218
|
+
tagName: "button",
|
|
79219
|
+
properties: {
|
|
79220
|
+
class: "add-source-file",
|
|
79221
|
+
title: i18n.get("typst-add-source-file")
|
|
79222
|
+
},
|
|
79223
|
+
children: [
|
|
79224
|
+
{
|
|
79225
|
+
type: "text",
|
|
79226
|
+
value: "+"
|
|
79227
|
+
}
|
|
79228
|
+
]
|
|
79229
|
+
}
|
|
79230
|
+
]
|
|
79231
|
+
},
|
|
79232
|
+
{
|
|
79233
|
+
type: "element",
|
|
79234
|
+
tagName: "details",
|
|
79235
|
+
properties: {
|
|
79236
|
+
class: "binary-files-section"
|
|
79237
|
+
},
|
|
79238
|
+
children: [
|
|
79239
|
+
{
|
|
79240
|
+
type: "element",
|
|
79241
|
+
tagName: "summary",
|
|
79242
|
+
properties: {},
|
|
79243
|
+
children: [
|
|
79244
|
+
{
|
|
79245
|
+
type: "element",
|
|
79246
|
+
tagName: "span",
|
|
79247
|
+
properties: {
|
|
79248
|
+
class: "summary-text"
|
|
79249
|
+
},
|
|
79250
|
+
children: [
|
|
79251
|
+
{
|
|
79252
|
+
type: "element",
|
|
79253
|
+
tagName: "span",
|
|
79254
|
+
properties: {
|
|
79255
|
+
class: "summary-indicator"
|
|
79256
|
+
},
|
|
79257
|
+
children: [
|
|
79258
|
+
{
|
|
79259
|
+
type: "text",
|
|
79260
|
+
value: "\u25B6"
|
|
79261
|
+
}
|
|
79262
|
+
]
|
|
79263
|
+
},
|
|
79264
|
+
{
|
|
79265
|
+
type: "text",
|
|
79266
|
+
value: i18n.get("typst-binary-files")
|
|
79267
|
+
}
|
|
79268
|
+
]
|
|
79269
|
+
}
|
|
79270
|
+
]
|
|
79271
|
+
},
|
|
79272
|
+
{
|
|
79273
|
+
type: "element",
|
|
79274
|
+
tagName: "div",
|
|
79275
|
+
properties: {
|
|
79276
|
+
class: "binary-files-list"
|
|
79277
|
+
},
|
|
79278
|
+
children: []
|
|
79279
|
+
},
|
|
79280
|
+
{
|
|
79281
|
+
type: "element",
|
|
79282
|
+
tagName: "div",
|
|
79283
|
+
properties: {
|
|
79284
|
+
class: "binary-files-actions"
|
|
79285
|
+
},
|
|
79286
|
+
children: [
|
|
79287
|
+
{
|
|
79288
|
+
type: "element",
|
|
79289
|
+
tagName: "button",
|
|
79290
|
+
properties: {
|
|
79291
|
+
class: "add-binary-file",
|
|
79292
|
+
title: i18n.get("typst-add-binary-file")
|
|
79293
|
+
},
|
|
79294
|
+
children: [
|
|
79295
|
+
{
|
|
79296
|
+
type: "text",
|
|
79297
|
+
value: "+ " + i18n.get("typst-add")
|
|
79298
|
+
}
|
|
79299
|
+
]
|
|
79300
|
+
}
|
|
79301
|
+
]
|
|
79302
|
+
}
|
|
79303
|
+
]
|
|
79304
|
+
},
|
|
79305
|
+
{
|
|
79306
|
+
type: "element",
|
|
79307
|
+
tagName: "code-input",
|
|
79308
|
+
properties: {
|
|
79309
|
+
class: "editor typst active line-numbers",
|
|
79310
|
+
language: "typst",
|
|
79311
|
+
template: "typst-highlighted"
|
|
79312
|
+
},
|
|
79313
|
+
children: [
|
|
79314
|
+
{
|
|
79315
|
+
type: "raw",
|
|
79316
|
+
value: htmlEntities4(mainSource.content)
|
|
79317
|
+
}
|
|
79318
|
+
]
|
|
79319
|
+
},
|
|
79320
|
+
{
|
|
79321
|
+
type: "element",
|
|
79322
|
+
tagName: "div",
|
|
79323
|
+
properties: {
|
|
79324
|
+
class: "buttons bottom"
|
|
79325
|
+
},
|
|
79326
|
+
children: [
|
|
79327
|
+
{
|
|
79328
|
+
type: "element",
|
|
79329
|
+
tagName: "button",
|
|
79330
|
+
properties: {
|
|
79331
|
+
class: "reset"
|
|
79332
|
+
},
|
|
79333
|
+
children: [
|
|
79334
|
+
{
|
|
79335
|
+
type: "text",
|
|
79336
|
+
value: i18n.get("typst-reset")
|
|
79337
|
+
}
|
|
79338
|
+
]
|
|
79339
|
+
},
|
|
79340
|
+
downloadProjectButton,
|
|
79341
|
+
downloadButton
|
|
79342
|
+
]
|
|
79343
|
+
}
|
|
79344
|
+
]
|
|
79345
|
+
}
|
|
79346
|
+
];
|
|
79347
|
+
} else {
|
|
79348
|
+
data.hChildren = [
|
|
79349
|
+
previewContainer,
|
|
79350
|
+
{
|
|
79351
|
+
type: "element",
|
|
79352
|
+
tagName: "div",
|
|
79353
|
+
properties: {
|
|
79354
|
+
class: "buttons bottom"
|
|
79355
|
+
},
|
|
79356
|
+
children: [downloadProjectButton, downloadButton]
|
|
79357
|
+
},
|
|
79358
|
+
{
|
|
79359
|
+
type: "element",
|
|
79360
|
+
tagName: "textarea",
|
|
79361
|
+
properties: {
|
|
79362
|
+
class: "typst-source hidden",
|
|
79363
|
+
style: "display: none;"
|
|
79364
|
+
},
|
|
79365
|
+
children: [
|
|
79366
|
+
{
|
|
79367
|
+
type: "text",
|
|
79368
|
+
value: mainSource.content
|
|
79369
|
+
}
|
|
79370
|
+
]
|
|
79371
|
+
}
|
|
79372
|
+
];
|
|
79373
|
+
}
|
|
79374
|
+
}
|
|
79375
|
+
});
|
|
79376
|
+
};
|
|
79377
|
+
};
|
|
79378
|
+
|
|
78921
79379
|
// src/process.ts
|
|
78922
79380
|
var remark = (ctx) => {
|
|
78923
79381
|
i18n.init(ctx.config.language || "en");
|
|
@@ -78962,6 +79420,7 @@ var remark = (ctx) => {
|
|
|
78962
79420
|
remarkDirectiveMultievent_default(ctx),
|
|
78963
79421
|
remarkDirectiveLearningmap_default(ctx),
|
|
78964
79422
|
remarkDirectiveTextinput_default(ctx),
|
|
79423
|
+
remarkDirectiveTypst_default(ctx),
|
|
78965
79424
|
remarkCode_default(ctx),
|
|
78966
79425
|
remarkMath,
|
|
78967
79426
|
/* needs to be last directive */
|