mystmd 1.1.35__py3-none-any.whl → 1.1.37__py3-none-any.whl
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.
- {mystmd-1.1.35.dist-info → mystmd-1.1.37.dist-info}/METADATA +1 -1
- mystmd-1.1.37.dist-info/RECORD +9 -0
- mystmd_py/myst.cjs +514 -215
- mystmd-1.1.35.dist-info/RECORD +0 -9
- {mystmd-1.1.35.dist-info → mystmd-1.1.37.dist-info}/LICENSE +0 -0
- {mystmd-1.1.35.dist-info → mystmd-1.1.37.dist-info}/WHEEL +0 -0
- {mystmd-1.1.35.dist-info → mystmd-1.1.37.dist-info}/entry_points.txt +0 -0
- {mystmd-1.1.35.dist-info → mystmd-1.1.37.dist-info}/top_level.txt +0 -0
mystmd_py/myst.cjs
CHANGED
@@ -145290,7 +145290,7 @@ var require_node_loaders = __commonJS({
|
|
145290
145290
|
var Loader = require_loader();
|
145291
145291
|
var _require = require_precompiled_loader();
|
145292
145292
|
var PrecompiledLoader = _require.PrecompiledLoader;
|
145293
|
-
var
|
145293
|
+
var chokidar3;
|
145294
145294
|
var FileSystemLoader = /* @__PURE__ */ function(_Loader) {
|
145295
145295
|
_inheritsLoose(FileSystemLoader2, _Loader);
|
145296
145296
|
function FileSystemLoader2(searchPaths, opts) {
|
@@ -145310,12 +145310,12 @@ var require_node_loaders = __commonJS({
|
|
145310
145310
|
}
|
145311
145311
|
if (opts.watch) {
|
145312
145312
|
try {
|
145313
|
-
|
145313
|
+
chokidar3 = require_chokidar();
|
145314
145314
|
} catch (e2) {
|
145315
145315
|
throw new Error("watch requires chokidar to be installed");
|
145316
145316
|
}
|
145317
145317
|
var paths = _this.searchPaths.filter(fs42.existsSync);
|
145318
|
-
var watcher =
|
145318
|
+
var watcher = chokidar3.watch(paths);
|
145319
145319
|
watcher.on("all", function(event, fullname) {
|
145320
145320
|
fullname = path39.resolve(fullname);
|
145321
145321
|
if (event === "change" && fullname in _this.pathsToNames) {
|
@@ -145364,11 +145364,11 @@ var require_node_loaders = __commonJS({
|
|
145364
145364
|
_this2.noCache = !!opts.noCache;
|
145365
145365
|
if (opts.watch) {
|
145366
145366
|
try {
|
145367
|
-
|
145367
|
+
chokidar3 = require_chokidar();
|
145368
145368
|
} catch (e2) {
|
145369
145369
|
throw new Error("watch requires chokidar to be installed");
|
145370
145370
|
}
|
145371
|
-
_this2.watcher =
|
145371
|
+
_this2.watcher = chokidar3.watch();
|
145372
145372
|
_this2.watcher.on("change", function(fullname) {
|
145373
145373
|
_this2.emit("update", _this2.pathsToNames[fullname], fullname);
|
145374
145374
|
});
|
@@ -199098,7 +199098,7 @@ var {
|
|
199098
199098
|
} = import_index.default;
|
199099
199099
|
|
199100
199100
|
// src/version.ts
|
199101
|
-
var version = "1.1.
|
199101
|
+
var version = "1.1.37";
|
199102
199102
|
var version_default = version;
|
199103
199103
|
|
199104
199104
|
// ../myst-cli/dist/build/build.js
|
@@ -200635,13 +200635,26 @@ var ExportFormats;
|
|
200635
200635
|
|
200636
200636
|
// ../myst-frontmatter/dist/exports/validators.js
|
200637
200637
|
var EXPORT_KEY_OBJECT = {
|
200638
|
-
required: [
|
200639
|
-
optional: ["template", "output", "id", "name", "renderer", "articles", "sub_articles"],
|
200638
|
+
required: [],
|
200639
|
+
optional: ["format", "template", "output", "id", "name", "renderer", "articles", "sub_articles"],
|
200640
200640
|
alias: {
|
200641
200641
|
article: "articles",
|
200642
200642
|
sub_article: "sub_articles"
|
200643
200643
|
}
|
200644
200644
|
};
|
200645
|
+
var EXT_TO_FORMAT = {
|
200646
|
+
".pdf": ExportFormats.pdf,
|
200647
|
+
".tex": ExportFormats.tex,
|
200648
|
+
".doc": ExportFormats.docx,
|
200649
|
+
".docx": ExportFormats.docx,
|
200650
|
+
".md": ExportFormats.md,
|
200651
|
+
".zip": ExportFormats.meca,
|
200652
|
+
".meca": ExportFormats.meca,
|
200653
|
+
".xml": ExportFormats.xml,
|
200654
|
+
".jats": ExportFormats.xml,
|
200655
|
+
".typ": ExportFormats.typst,
|
200656
|
+
".typst": ExportFormats.typst
|
200657
|
+
};
|
200645
200658
|
var RESERVED_EXPORT_KEYS = [
|
200646
200659
|
...EXPORT_KEY_OBJECT.required,
|
200647
200660
|
...EXPORT_KEY_OBJECT.optional,
|
@@ -200669,10 +200682,26 @@ function validateExportFormat(input3, opts) {
|
|
200669
200682
|
}
|
200670
200683
|
function validateExport(input3, opts) {
|
200671
200684
|
if (typeof input3 === "string") {
|
200672
|
-
|
200673
|
-
|
200674
|
-
|
200675
|
-
|
200685
|
+
let format2;
|
200686
|
+
let output3;
|
200687
|
+
if (input3.includes(".")) {
|
200688
|
+
Object.entries(EXT_TO_FORMAT).forEach(([ext2, fmt]) => {
|
200689
|
+
if (input3 === ext2) {
|
200690
|
+
format2 = fmt;
|
200691
|
+
} else if (input3.endsWith(ext2)) {
|
200692
|
+
output3 = input3;
|
200693
|
+
}
|
200694
|
+
});
|
200695
|
+
if (!format2 && !output3) {
|
200696
|
+
output3 = input3;
|
200697
|
+
}
|
200698
|
+
}
|
200699
|
+
if (!format2 && !output3) {
|
200700
|
+
format2 = validateExportFormat(input3, opts);
|
200701
|
+
if (!format2)
|
200702
|
+
return void 0;
|
200703
|
+
}
|
200704
|
+
input3 = { format: format2, output: output3 };
|
200676
200705
|
}
|
200677
200706
|
const value = validateObjectKeys(input3, EXPORT_KEY_OBJECT, {
|
200678
200707
|
...opts,
|
@@ -200681,42 +200710,59 @@ function validateExport(input3, opts) {
|
|
200681
200710
|
});
|
200682
200711
|
if (value === void 0)
|
200683
200712
|
return void 0;
|
200684
|
-
|
200685
|
-
|
200686
|
-
|
200687
|
-
const output2 = { ...value, format };
|
200713
|
+
let format;
|
200714
|
+
let output2;
|
200715
|
+
let template;
|
200688
200716
|
if (value.template === null) {
|
200689
|
-
|
200717
|
+
template = null;
|
200690
200718
|
} else if (defined(value.template)) {
|
200691
|
-
|
200719
|
+
template = validateString(value.template, incrementOptions("template", opts));
|
200692
200720
|
}
|
200693
200721
|
if (defined(value.output)) {
|
200694
|
-
output2
|
200722
|
+
output2 = validateString(value.output, incrementOptions("output", opts));
|
200723
|
+
}
|
200724
|
+
if (defined(value.format)) {
|
200725
|
+
format = validateExportFormat(value.format, incrementOptions("format", opts));
|
200726
|
+
if (!format)
|
200727
|
+
return void 0;
|
200728
|
+
} else if (output2) {
|
200729
|
+
Object.entries(EXT_TO_FORMAT).forEach(([ext2, fmt]) => {
|
200730
|
+
if (output2 === null || output2 === void 0 ? void 0 : output2.endsWith(ext2))
|
200731
|
+
format = fmt;
|
200732
|
+
});
|
200733
|
+
if (!format) {
|
200734
|
+
return validationError(`unable to infer export format from export: ${output2}`, opts);
|
200735
|
+
}
|
200736
|
+
} else {
|
200737
|
+
return validationError("unable to determine export format", opts);
|
200695
200738
|
}
|
200739
|
+
if (format === void 0 && template === void 0)
|
200740
|
+
return void 0;
|
200741
|
+
const validExport = { ...value, format, output: output2, template };
|
200696
200742
|
if (defined(value.articles)) {
|
200697
200743
|
const articles = validateList(value.articles, { coerce: true, ...incrementOptions("articles", opts) }, (item, ind) => validateString(item, incrementOptions(`articles.${ind}`, opts)));
|
200698
|
-
if ((articles === null || articles === void 0 ? void 0 : articles.length) && articles.length > 1 && ![ExportFormats.pdf, ExportFormats.tex, ExportFormats.pdftex].includes(
|
200699
|
-
if (
|
200744
|
+
if ((articles === null || articles === void 0 ? void 0 : articles.length) && articles.length > 1 && validExport.format && ![ExportFormats.pdf, ExportFormats.tex, ExportFormats.pdftex].includes(validExport.format)) {
|
200745
|
+
if (validExport.format === ExportFormats.xml && !defined(value.sub_articles)) {
|
200700
200746
|
validationError("multiple articles are not supported for 'jats' export - instead specify one article with additional sub_articles", opts);
|
200701
200747
|
} else {
|
200702
200748
|
validationError("multiple articles are only supported for 'tex' and 'pdf' exports", opts);
|
200703
200749
|
}
|
200704
|
-
|
200750
|
+
validExport.articles = [articles[0]];
|
200705
200751
|
} else {
|
200706
|
-
|
200752
|
+
validExport.articles = articles;
|
200707
200753
|
}
|
200708
200754
|
}
|
200709
200755
|
if (defined(value.sub_articles)) {
|
200710
|
-
if (
|
200756
|
+
if (validExport.format !== ExportFormats.xml) {
|
200711
200757
|
validationError("sub_articles are only supported for 'jats' export", opts);
|
200712
|
-
|
200758
|
+
validExport.sub_articles = void 0;
|
200713
200759
|
} else {
|
200714
|
-
|
200760
|
+
validExport.sub_articles = validateList(value.sub_articles, { coerce: true, ...incrementOptions("sub_articles", opts) }, (file, ind) => {
|
200715
200761
|
return validateString(file, incrementOptions(`sub_articles.${ind}`, opts));
|
200716
200762
|
});
|
200717
200763
|
}
|
200718
200764
|
}
|
200719
|
-
return
|
200765
|
+
return validExport;
|
200720
200766
|
}
|
200721
200767
|
|
200722
200768
|
// ../myst-frontmatter/dist/funding/validators.js
|
@@ -240762,6 +240808,8 @@ function blockToFigureTransform(mdast2, opts) {
|
|
240762
240808
|
function codeTransform(mdast2, file, opts) {
|
240763
240809
|
const code7 = selectAll("code", mdast2);
|
240764
240810
|
code7.forEach((node3) => {
|
240811
|
+
if (node3.lang === "")
|
240812
|
+
return;
|
240765
240813
|
if (!node3.lang) {
|
240766
240814
|
if (!(opts === null || opts === void 0 ? void 0 : opts.lang)) {
|
240767
240815
|
fileWarn(file, "Language is not defined for code block", {
|
@@ -242235,12 +242283,15 @@ function getFrontmatter(file, tree, opts = { removeYaml: true, removeHeading: tr
|
|
242235
242283
|
var selectors_exports = {};
|
242236
242284
|
__export(selectors_exports, {
|
242237
242285
|
selectAffiliation: () => selectAffiliation,
|
242286
|
+
selectAllDependencies: () => selectAllDependencies,
|
242238
242287
|
selectCurrentProjectConfig: () => selectCurrentProjectConfig,
|
242239
242288
|
selectCurrentProjectFile: () => selectCurrentProjectFile,
|
242240
242289
|
selectCurrentProjectPath: () => selectCurrentProjectPath,
|
242241
242290
|
selectCurrentSiteConfig: () => selectCurrentSiteConfig,
|
242242
242291
|
selectCurrentSiteFile: () => selectCurrentSiteFile,
|
242243
242292
|
selectCurrentSitePath: () => selectCurrentSitePath,
|
242293
|
+
selectDependentFiles: () => selectDependentFiles,
|
242294
|
+
selectFileDependencies: () => selectFileDependencies,
|
242244
242295
|
selectFileInfo: () => selectFileInfo,
|
242245
242296
|
selectFileWarnings: () => selectFileWarnings,
|
242246
242297
|
selectFileWarningsByRule: () => selectFileWarningsByRule,
|
@@ -242329,6 +242380,26 @@ function selectFileInfo(state, path39) {
|
|
242329
242380
|
dataUrl
|
242330
242381
|
};
|
242331
242382
|
}
|
242383
|
+
function selectFileDependencies(state, path39) {
|
242384
|
+
var _a6, _b;
|
242385
|
+
return (_b = (_a6 = state.local.watch.files[(0, import_node_path4.resolve)(path39)]) === null || _a6 === void 0 ? void 0 : _a6.localDependencies) !== null && _b !== void 0 ? _b : [];
|
242386
|
+
}
|
242387
|
+
function selectAllDependencies(state, projectPath) {
|
242388
|
+
return Object.entries(state.local.watch.files).filter(([file]) => !projectPath || file.startsWith((0, import_node_path4.resolve)(projectPath))).map(([, value]) => {
|
242389
|
+
var _a6;
|
242390
|
+
return (_a6 = value.localDependencies) !== null && _a6 !== void 0 ? _a6 : [];
|
242391
|
+
}).flat();
|
242392
|
+
}
|
242393
|
+
function selectDependentFiles(state, path39) {
|
242394
|
+
const dependentFiles = [];
|
242395
|
+
Object.entries(state.local.watch.files).forEach(([key2, value]) => {
|
242396
|
+
var _a6;
|
242397
|
+
if ((_a6 = value.localDependencies) === null || _a6 === void 0 ? void 0 : _a6.includes((0, import_node_path4.resolve)(path39))) {
|
242398
|
+
dependentFiles.push(key2);
|
242399
|
+
}
|
242400
|
+
});
|
242401
|
+
return dependentFiles;
|
242402
|
+
}
|
242332
242403
|
function selectPageSlug(state, projectPath, path39) {
|
242333
242404
|
const project = selectLocalProject(state, projectPath);
|
242334
242405
|
if (!project)
|
@@ -242423,6 +242494,14 @@ var watch = (0, import_toolkit.createSlice)({
|
|
242423
242494
|
const { path: path39, sha256 = null } = action.payload;
|
242424
242495
|
state.files[(0, import_node_path5.resolve)(path39)] = { ...state.files[(0, import_node_path5.resolve)(path39)], sha256 };
|
242425
242496
|
},
|
242497
|
+
addLocalDependency(state, action) {
|
242498
|
+
var _a6;
|
242499
|
+
const { path: path39, dependency } = action.payload;
|
242500
|
+
const existingDeps = [...(_a6 = state.files[(0, import_node_path5.resolve)(path39)].localDependencies) !== null && _a6 !== void 0 ? _a6 : []];
|
242501
|
+
if (!existingDeps.includes(dependency)) {
|
242502
|
+
state.files[(0, import_node_path5.resolve)(path39)].localDependencies = [...existingDeps, dependency];
|
242503
|
+
}
|
242504
|
+
},
|
242426
242505
|
updateFileInfo(state, action) {
|
242427
242506
|
const { path: path39, sha256, title, short_title, description, date, thumbnail, thumbnailOptimized, banner, bannerOptimized, tags, url, dataUrl } = action.payload;
|
242428
242507
|
const resolvedPath = (0, import_node_path5.resolve)(path39);
|
@@ -282832,8 +282911,7 @@ var codeDirective = {
|
|
282832
282911
|
var codeCellDirective = {
|
282833
282912
|
name: "code-cell",
|
282834
282913
|
arg: {
|
282835
|
-
type: String
|
282836
|
-
required: true
|
282914
|
+
type: String
|
282837
282915
|
},
|
282838
282916
|
options: {
|
282839
282917
|
tags: {
|
@@ -282844,25 +282922,25 @@ var codeCellDirective = {
|
|
282844
282922
|
type: String
|
282845
282923
|
},
|
282846
282924
|
run(data, vfile2) {
|
282847
|
-
var _a6, _b, _c, _d2;
|
282925
|
+
var _a6, _b, _c, _d2, _e;
|
282848
282926
|
const code7 = {
|
282849
282927
|
type: "code",
|
282850
282928
|
lang: data.arg,
|
282851
282929
|
executable: true,
|
282852
|
-
value: data.body
|
282930
|
+
value: (_a6 = data.body) !== null && _a6 !== void 0 ? _a6 : ""
|
282853
282931
|
};
|
282854
282932
|
let tags;
|
282855
|
-
if (typeof ((
|
282933
|
+
if (typeof ((_b = data.options) === null || _b === void 0 ? void 0 : _b.tags) === "string") {
|
282856
282934
|
try {
|
282857
282935
|
tags = js_yaml_default.load(data.options.tags);
|
282858
282936
|
} catch (error) {
|
282859
282937
|
fileError(vfile2, "Could not load tags for code-cell directive", {
|
282860
|
-
node: (
|
282938
|
+
node: (_c = select('mystDirectiveOption[name="tags"]', data.node)) !== null && _c !== void 0 ? _c : data.node,
|
282861
282939
|
source: "code-cell:tags",
|
282862
282940
|
ruleId: RuleId.directiveOptionsCorrect
|
282863
282941
|
});
|
282864
282942
|
}
|
282865
|
-
} else if (((
|
282943
|
+
} else if (((_d2 = data.options) === null || _d2 === void 0 ? void 0 : _d2.tags) && Array.isArray(data.options.tags)) {
|
282866
282944
|
tags = data.options.tags;
|
282867
282945
|
}
|
282868
282946
|
if (tags && Array.isArray(tags) && tags.every((t2) => typeof t2 === "string")) {
|
@@ -282871,12 +282949,25 @@ var codeCellDirective = {
|
|
282871
282949
|
}
|
282872
282950
|
} else if (tags) {
|
282873
282951
|
fileWarn(vfile2, "tags in code-cell directive must be a list of strings", {
|
282874
|
-
node: (
|
282952
|
+
node: (_e = select('mystDirectiveOption[name="tags"]', data.node)) !== null && _e !== void 0 ? _e : data.node,
|
282875
282953
|
source: "code-cell:tags",
|
282876
282954
|
ruleId: RuleId.directiveOptionsCorrect
|
282877
282955
|
});
|
282878
282956
|
}
|
282879
|
-
|
282957
|
+
const output2 = {
|
282958
|
+
type: "output",
|
282959
|
+
id: nanoid(),
|
282960
|
+
data: []
|
282961
|
+
};
|
282962
|
+
const block5 = {
|
282963
|
+
type: "block",
|
282964
|
+
meta: void 0,
|
282965
|
+
children: [code7, output2],
|
282966
|
+
data: {
|
282967
|
+
type: "notebook-code"
|
282968
|
+
}
|
282969
|
+
};
|
282970
|
+
return [block5];
|
282880
282971
|
}
|
282881
282972
|
};
|
282882
282973
|
|
@@ -283394,7 +283485,7 @@ var tableDirective = {
|
|
283394
283485
|
type: "myst",
|
283395
283486
|
required: true
|
283396
283487
|
},
|
283397
|
-
run(data
|
283488
|
+
run(data) {
|
283398
283489
|
var _a6, _b;
|
283399
283490
|
const children = [];
|
283400
283491
|
if (data.arg) {
|
@@ -283403,13 +283494,6 @@ var tableDirective = {
|
|
283403
283494
|
children: [{ type: "paragraph", children: data.arg }]
|
283404
283495
|
});
|
283405
283496
|
}
|
283406
|
-
const body3 = data.body;
|
283407
|
-
if (!select("table", { type: "root", children: body3 })) {
|
283408
|
-
fileError(vfile2, "table directive does not include a markdown table in the body", {
|
283409
|
-
node: data.node,
|
283410
|
-
ruleId: RuleId.directiveBodyCorrect
|
283411
|
-
});
|
283412
|
-
}
|
283413
283497
|
children.push(...data.body);
|
283414
283498
|
const { label, identifier } = normalizeLabel((_a6 = data.options) === null || _a6 === void 0 ? void 0 : _a6.label) || {};
|
283415
283499
|
const container4 = {
|
@@ -283846,15 +283930,10 @@ var refRole = {
|
|
283846
283930
|
const match3 = REF_PATTERN.exec(body3);
|
283847
283931
|
const [, modified, rawLabel] = match3 !== null && match3 !== void 0 ? match3 : [];
|
283848
283932
|
const { label, identifier } = normalizeLabel(rawLabel !== null && rawLabel !== void 0 ? rawLabel : body3) || {};
|
283849
|
-
|
283850
|
-
|
283851
|
-
|
283852
|
-
|
283853
|
-
identifier,
|
283854
|
-
label,
|
283855
|
-
children: modified ? [{ type: "text", value: modified.trim() }] : void 0
|
283856
|
-
}
|
283857
|
-
];
|
283933
|
+
const crossRef = { type: "crossReference", kind: data.name, identifier, label };
|
283934
|
+
if (modified)
|
283935
|
+
crossRef.children = [{ type: "text", value: modified.trim() }];
|
283936
|
+
return [crossRef];
|
283858
283937
|
}
|
283859
283938
|
};
|
283860
283939
|
|
@@ -283876,13 +283955,10 @@ var docRole = {
|
|
283876
283955
|
note: `For {doc}\`${body3}\` use [${modified || ""}](${url})`,
|
283877
283956
|
ruleId: RuleId.roleBodyCorrect
|
283878
283957
|
});
|
283879
|
-
|
283880
|
-
|
283881
|
-
|
283882
|
-
|
283883
|
-
children: modified ? [{ type: "text", value: modified.trim() }] : void 0
|
283884
|
-
}
|
283885
|
-
];
|
283958
|
+
const link4 = { type: "link", url };
|
283959
|
+
if (modified)
|
283960
|
+
link4.children = [{ type: "text", value: modified.trim() }];
|
283961
|
+
return [link4];
|
283886
283962
|
}
|
283887
283963
|
};
|
283888
283964
|
|
@@ -283899,15 +283975,15 @@ var downloadRole = {
|
|
283899
283975
|
const match3 = REF_PATTERN3.exec(body3);
|
283900
283976
|
const [, modified, rawLabel] = match3 !== null && match3 !== void 0 ? match3 : [];
|
283901
283977
|
const url = rawLabel !== null && rawLabel !== void 0 ? rawLabel : body3;
|
283902
|
-
|
283903
|
-
|
283904
|
-
|
283905
|
-
|
283906
|
-
|
283907
|
-
|
283908
|
-
|
283909
|
-
}
|
283910
|
-
];
|
283978
|
+
const link4 = {
|
283979
|
+
type: "link",
|
283980
|
+
url,
|
283981
|
+
static: true
|
283982
|
+
// Indicate that this should be treated as a static download
|
283983
|
+
};
|
283984
|
+
if (modified)
|
283985
|
+
link4.children = [{ type: "text", value: modified.trim() }];
|
283986
|
+
return [link4];
|
283911
283987
|
}
|
283912
283988
|
};
|
283913
283989
|
|
@@ -283932,14 +284008,14 @@ var termRole = {
|
|
283932
284008
|
ruleId: RuleId.roleBodyCorrect
|
283933
284009
|
});
|
283934
284010
|
}
|
283935
|
-
|
283936
|
-
|
283937
|
-
|
283938
|
-
|
283939
|
-
|
283940
|
-
|
283941
|
-
}
|
283942
|
-
];
|
284011
|
+
const crossRef = {
|
284012
|
+
type: "crossReference",
|
284013
|
+
label,
|
284014
|
+
identifier: `term-${identifier}`
|
284015
|
+
};
|
284016
|
+
if (modified)
|
284017
|
+
crossRef.children = [{ type: "text", value: modified.trim() }];
|
284018
|
+
return [crossRef];
|
283943
284019
|
}
|
283944
284020
|
};
|
283945
284021
|
|
@@ -285744,7 +285820,7 @@ var import_node_path15 = __toESM(require("path"), 1);
|
|
285744
285820
|
var import_nbtx = __toESM(require_cjs2(), 1);
|
285745
285821
|
|
285746
285822
|
// ../myst-cli/dist/version.js
|
285747
|
-
var version2 = "1.1.
|
285823
|
+
var version2 = "1.1.37";
|
285748
285824
|
var version_default2 = version2;
|
285749
285825
|
|
285750
285826
|
// ../myst-cli/dist/utils/headers.js
|
@@ -286284,6 +286360,8 @@ async function writeBase64(session, writeFolder, data, contentType) {
|
|
286284
286360
|
const file = `${hash}${ext2}`;
|
286285
286361
|
const filePath = import_node_path15.default.join(writeFolder, file);
|
286286
286362
|
session.log.debug(`Writing binary output file ${justData.length} bytes to ${filePath}`);
|
286363
|
+
if (!import_node_fs10.default.existsSync(writeFolder))
|
286364
|
+
import_node_fs10.default.mkdirSync(writeFolder, { recursive: true });
|
286287
286365
|
import_node_fs10.default.writeFileSync(filePath, justData, {
|
286288
286366
|
encoding: "base64"
|
286289
286367
|
});
|
@@ -286727,12 +286805,6 @@ async function transformDeleteBase64UrlSource(mdast2) {
|
|
286727
286805
|
}
|
286728
286806
|
|
286729
286807
|
// ../myst-cli/dist/process/notebook.js
|
286730
|
-
function createOutputDirective() {
|
286731
|
-
const id = nanoid();
|
286732
|
-
return { myst: `\`\`\`{output}
|
286733
|
-
:id: ${id}
|
286734
|
-
\`\`\``, id };
|
286735
|
-
}
|
286736
286808
|
function blockParent(cell3, children) {
|
286737
286809
|
const type2 = cell3.cell_type === import_nbtx2.CELL_TYPES.code ? NotebookCell.code : NotebookCell.content;
|
286738
286810
|
return { type: "block", meta: JSON.stringify({ type: type2, ...cell3.metadata }), children };
|
@@ -286776,7 +286848,6 @@ async function processNotebook(session, file, content3, opts) {
|
|
286776
286848
|
const language = (_b = (_a6 = metadata === null || metadata === void 0 ? void 0 : metadata.kernelspec) === null || _a6 === void 0 ? void 0 : _a6.language) !== null && _b !== void 0 ? _b : "python";
|
286777
286849
|
log.debug(`Processing Notebook: "${file}"`);
|
286778
286850
|
const cache = castSession(session);
|
286779
|
-
const outputMap = {};
|
286780
286851
|
let end = cells2.length;
|
286781
286852
|
if (cells2 && cells2.length > 1 && (cells2 === null || cells2 === void 0 ? void 0 : cells2[cells2.length - 1].source.length) === 0) {
|
286782
286853
|
end = -1;
|
@@ -286796,34 +286867,34 @@ async function processNotebook(session, file, content3, opts) {
|
|
286796
286867
|
return acc.concat(blockParent(cell3, cellMdast.children));
|
286797
286868
|
}
|
286798
286869
|
if (cell3.cell_type === import_nbtx2.CELL_TYPES.raw) {
|
286799
|
-
const
|
286800
|
-
|
286801
|
-
|
286802
|
-
|
286803
|
-
|
286870
|
+
const raw2 = {
|
286871
|
+
type: "code",
|
286872
|
+
lang: "",
|
286873
|
+
value: (0, import_nbtx2.ensureString)(cell3.source)
|
286874
|
+
};
|
286875
|
+
return acc.concat(blockParent(cell3, [raw2]));
|
286804
286876
|
}
|
286805
286877
|
if (cell3.cell_type === import_nbtx2.CELL_TYPES.code) {
|
286806
|
-
const
|
286807
|
-
|
286808
|
-
|
286809
|
-
|
286810
|
-
|
286878
|
+
const code7 = {
|
286879
|
+
type: "code",
|
286880
|
+
lang: language,
|
286881
|
+
executable: true,
|
286882
|
+
value: (0, import_nbtx2.ensureString)(cell3.source)
|
286883
|
+
};
|
286884
|
+
const output2 = {
|
286885
|
+
type: "output",
|
286886
|
+
id: nanoid(),
|
286887
|
+
data: []
|
286888
|
+
};
|
286811
286889
|
if (cell3.outputs && cell3.outputs.length > 0) {
|
286812
286890
|
const minified = await (0, import_nbtx2.minifyCellOutput)(cell3.outputs, cache.$outputs, { computeHash, maxCharacters: opts === null || opts === void 0 ? void 0 : opts.minifyMaxCharacters });
|
286813
|
-
|
286814
|
-
} else {
|
286815
|
-
outputMap[id] = [];
|
286891
|
+
output2.data = minified;
|
286816
286892
|
}
|
286817
|
-
|
286818
|
-
return acc.concat(blockParent(cell3, [...cellCodeMdast.children, ...cellOutputMdast.children]));
|
286893
|
+
return acc.concat(blockParent(cell3, [code7, output2]));
|
286819
286894
|
}
|
286820
286895
|
return acc;
|
286821
286896
|
}, Promise.resolve([])));
|
286822
|
-
|
286823
|
-
selectAll("output", mdast2).forEach((output2) => {
|
286824
|
-
output2.data = outputMap[output2.id];
|
286825
|
-
});
|
286826
|
-
return mdast2;
|
286897
|
+
return { type: "root", children: items };
|
286827
286898
|
}
|
286828
286899
|
|
286829
286900
|
// ../myst-cli/dist/process/file.js
|
@@ -294079,13 +294150,13 @@ var KIND_TO_EXT = {
|
|
294079
294150
|
};
|
294080
294151
|
var DEFAULT_TEMPLATES = {
|
294081
294152
|
tex: "tex/myst/curvenote",
|
294082
|
-
typst: "typst/myst/
|
294153
|
+
typst: "typst/myst/lapreprint-typst",
|
294083
294154
|
docx: "docx/myst/default",
|
294084
294155
|
site: "site/myst/book-theme"
|
294085
294156
|
};
|
294086
294157
|
var PARTIAL_TEMPLATE_REGEX = /^[a-zA-Z0-9_-]+$/;
|
294087
294158
|
var TEMPLATE_REGEX = /^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$/;
|
294088
|
-
var FULL_TEMPLATE_REGEX = /^(site|tex|docx)\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$/;
|
294159
|
+
var FULL_TEMPLATE_REGEX = /^(site|tex|typst|docx)\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$/;
|
294089
294160
|
function normalizeTemplateName(opts) {
|
294090
294161
|
const { template } = opts;
|
294091
294162
|
const kind = opts.kind;
|
@@ -296128,6 +296199,30 @@ function propagateBlockDataToCode(session, vfile2, mdast2) {
|
|
296128
296199
|
outputNode.visibility = "show";
|
296129
296200
|
});
|
296130
296201
|
}
|
296202
|
+
function transformLiftCodeBlocksInJupytext(mdast2) {
|
296203
|
+
const flattened = mdast2.children.reduce((acc, node3) => {
|
296204
|
+
var _a6, _b;
|
296205
|
+
if (node3.type !== "block" || !node3.children)
|
296206
|
+
return [...acc, node3];
|
296207
|
+
const buriedCodeCells = selectAll("block:has(block)", node3);
|
296208
|
+
if (buriedCodeCells.length === 0)
|
296209
|
+
return [...acc, node3];
|
296210
|
+
const newBlocks = [{ ...node3, children: [] }];
|
296211
|
+
(_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.forEach((child) => {
|
296212
|
+
var _a7, _b2, _c, _d2;
|
296213
|
+
if (child.type === "block" && ((_a7 = child.children) === null || _a7 === void 0 ? void 0 : _a7.length) === 2 && ((_b2 = child.children) === null || _b2 === void 0 ? void 0 : _b2[0].type) === "code" && ((_c = child.children) === null || _c === void 0 ? void 0 : _c[1].type) === "output") {
|
296214
|
+
newBlocks.push(child);
|
296215
|
+
newBlocks.push({ type: "block", children: [] });
|
296216
|
+
return;
|
296217
|
+
}
|
296218
|
+
(_d2 = newBlocks[newBlocks.length - 1].children) === null || _d2 === void 0 ? void 0 : _d2.push(child);
|
296219
|
+
});
|
296220
|
+
if (((_b = newBlocks[newBlocks.length - 1].children) === null || _b === void 0 ? void 0 : _b.length) === 0)
|
296221
|
+
newBlocks.pop();
|
296222
|
+
return [...acc, ...newBlocks];
|
296223
|
+
}, []);
|
296224
|
+
mdast2.children = flattened;
|
296225
|
+
}
|
296131
296226
|
|
296132
296227
|
// ../myst-cli/dist/transforms/dois.js
|
296133
296228
|
async function getDoiOrgBibtex(log, doiString) {
|
@@ -296281,7 +296376,7 @@ var filter2 = (
|
|
296281
296376
|
);
|
296282
296377
|
|
296283
296378
|
// ../myst-cli/dist/transforms/embed.js
|
296284
|
-
function embedTransform(session, mdast2, dependencies, state) {
|
296379
|
+
function embedTransform(session, mdast2, file, dependencies, state) {
|
296285
296380
|
const embedNodes = selectAll("embed", mdast2);
|
296286
296381
|
embedNodes.forEach((node3) => {
|
296287
296382
|
var _a6, _b, _c, _d2;
|
@@ -296319,12 +296414,16 @@ function embedTransform(session, mdast2, dependencies, state) {
|
|
296319
296414
|
const multiState = state;
|
296320
296415
|
if (!multiState.states)
|
296321
296416
|
return;
|
296322
|
-
const { url, file } = (_b = multiState.resolveStateProvider(normalized.identifier)) !== null && _b !== void 0 ? _b : {};
|
296417
|
+
const { url, file: depFile } = (_b = multiState.resolveStateProvider(normalized.identifier)) !== null && _b !== void 0 ? _b : {};
|
296323
296418
|
if (!url)
|
296324
296419
|
return;
|
296325
296420
|
const source2 = { url, label: (_c = node3.source) === null || _c === void 0 ? void 0 : _c.label };
|
296326
|
-
if (
|
296327
|
-
|
296421
|
+
if (depFile) {
|
296422
|
+
session.store.dispatch(watch.actions.addLocalDependency({
|
296423
|
+
path: file,
|
296424
|
+
dependency: depFile
|
296425
|
+
}));
|
296426
|
+
const { kind, slug, frontmatter, location: location4 } = (_d2 = selectFile(session, depFile)) !== null && _d2 !== void 0 ? _d2 : {};
|
296328
296427
|
if (kind)
|
296329
296428
|
source2.kind = kind;
|
296330
296429
|
if (slug)
|
@@ -296378,6 +296477,10 @@ async function includeFilesTransform(session, baseFile, tree, vfile2) {
|
|
296378
296477
|
});
|
296379
296478
|
return;
|
296380
296479
|
}
|
296480
|
+
session.store.dispatch(watch.actions.addLocalDependency({
|
296481
|
+
path: baseFile,
|
296482
|
+
dependency: fullFile
|
296483
|
+
}));
|
296381
296484
|
return import_node_fs23.default.readFileSync(fullFile).toString();
|
296382
296485
|
};
|
296383
296486
|
const parseContent = (filename, content3) => {
|
@@ -296774,13 +296877,28 @@ function renderExpression(node3, file) {
|
|
296774
296877
|
const result = node3.result;
|
296775
296878
|
if (!result)
|
296776
296879
|
return [];
|
296880
|
+
let content3;
|
296777
296881
|
if (result.status === "ok") {
|
296778
|
-
|
296779
|
-
|
296780
|
-
|
296781
|
-
|
296782
|
-
|
296783
|
-
|
296882
|
+
Object.entries(result.data).forEach(([mimeType, value]) => {
|
296883
|
+
if (content3) {
|
296884
|
+
return;
|
296885
|
+
} else if (mimeType.startsWith("image/")) {
|
296886
|
+
content3 = [
|
296887
|
+
{
|
296888
|
+
type: "image",
|
296889
|
+
url: `data:${mimeType}${BASE64_HEADER_SPLIT}${value}`
|
296890
|
+
}
|
296891
|
+
];
|
296892
|
+
} else if (mimeType === "text/latex") {
|
296893
|
+
content3 = [{ type: "inlineMath", value: processLatex(value) }];
|
296894
|
+
} else if (mimeType === "text/html") {
|
296895
|
+
content3 = [{ type: "html", value }];
|
296896
|
+
} else if (mimeType === "text/plain") {
|
296897
|
+
content3 = [{ type: "text", value }];
|
296898
|
+
}
|
296899
|
+
});
|
296900
|
+
if (content3)
|
296901
|
+
return content3;
|
296784
296902
|
fileWarn(file, "Unrecognized mime bundle for inline content", {
|
296785
296903
|
node: node3,
|
296786
296904
|
ruleId: RuleId.inlineExpressionRenders
|
@@ -296789,6 +296907,7 @@ function renderExpression(node3, file) {
|
|
296789
296907
|
return [];
|
296790
296908
|
}
|
296791
296909
|
function transformInlineExpressions(mdast2, file) {
|
296910
|
+
blockMetadataTransform(mdast2, file);
|
296792
296911
|
const blocks2 = selectAll("block", mdast2).filter((node3) => {
|
296793
296912
|
var _a6, _b;
|
296794
296913
|
return ((_a6 = node3.data) === null || _a6 === void 0 ? void 0 : _a6.type) === NotebookCell.content && ((_b = node3.data) === null || _b === void 0 ? void 0 : _b[metadataSection]);
|
@@ -296798,14 +296917,14 @@ function transformInlineExpressions(mdast2, file) {
|
|
296798
296917
|
var _a6;
|
296799
296918
|
const userExpressions = (_a6 = node3.data) === null || _a6 === void 0 ? void 0 : _a6[metadataSection];
|
296800
296919
|
const inlineNodes = selectAll("inlineExpression", node3);
|
296801
|
-
inlineNodes.forEach((
|
296802
|
-
const data = findExpression(userExpressions,
|
296920
|
+
inlineNodes.forEach((inlineExpression3) => {
|
296921
|
+
const data = findExpression(userExpressions, inlineExpression3.value);
|
296803
296922
|
if (!data)
|
296804
296923
|
return;
|
296805
296924
|
count2 += 1;
|
296806
|
-
|
296807
|
-
|
296808
|
-
|
296925
|
+
inlineExpression3.identifier = `eval-${count2}`;
|
296926
|
+
inlineExpression3.result = data.result;
|
296927
|
+
inlineExpression3.children = renderExpression(inlineExpression3, file);
|
296809
296928
|
});
|
296810
296929
|
});
|
296811
296930
|
}
|
@@ -296878,9 +296997,9 @@ async function transformMdast(session, opts) {
|
|
296878
296997
|
importMdastFromJson(session, file, mdast2);
|
296879
296998
|
await includeFilesTransform(session, file, mdast2, vfile2);
|
296880
296999
|
liftCodeMetadataToBlock(session, vfile2, mdast2);
|
296881
|
-
const pipe = unified().use(reconstructHtmlPlugin).use(htmlPlugin, { htmlHandlers }).use(basicTransformationsPlugin, {
|
297000
|
+
const pipe = unified().use(reconstructHtmlPlugin).use(inlineExpressionsPlugin).use(htmlPlugin, { htmlHandlers }).use(basicTransformationsPlugin, {
|
296882
297001
|
parser: (content3) => parseMyst(session, content3, file)
|
296883
|
-
}).use(
|
297002
|
+
}).use(inlineMathSimplificationPlugin).use(mathPlugin, { macros: frontmatter.math }).use(glossaryPlugin, { state }).use(abbreviationPlugin, { abbreviations: frontmatter.abbreviations }).use(enumerateTargetsPlugin, { state }).use(joinGatesPlugin);
|
296884
297003
|
(_c = session.plugins) === null || _c === void 0 ? void 0 : _c.transforms.forEach((t2) => {
|
296885
297004
|
if (t2.stage !== "document")
|
296886
297005
|
return;
|
@@ -296912,13 +297031,16 @@ async function transformMdast(session, opts) {
|
|
296912
297031
|
await unified().use(codePlugin, { lang: (_d2 = frontmatter === null || frontmatter === void 0 ? void 0 : frontmatter.kernelspec) === null || _d2 === void 0 ? void 0 : _d2.language }).use(footnotesPlugin).run(mdast2, vfile2);
|
296913
297032
|
transformImagesToEmbed(mdast2);
|
296914
297033
|
transformImagesWithoutExt(session, mdast2, file, { imageExtensions });
|
297034
|
+
const isJupytext = frontmatter.kernelspec || frontmatter.jupytext;
|
297035
|
+
if (isJupytext)
|
297036
|
+
transformLiftCodeBlocksInJupytext(mdast2);
|
296915
297037
|
const sha256 = selectors_exports.selectFileInfo(store.getState(), file).sha256;
|
296916
297038
|
const useSlug = pageSlug !== index4;
|
296917
297039
|
const url = projectSlug ? `/${projectSlug}/${useSlug ? pageSlug : ""}` : `/${useSlug ? pageSlug : ""}`;
|
296918
297040
|
const dataUrl = projectSlug ? `/${projectSlug}/${pageSlug}.json` : `/${pageSlug}.json`;
|
296919
297041
|
updateFileInfoFromFrontmatter(session, file, frontmatter, url, dataUrl);
|
296920
297042
|
const data = {
|
296921
|
-
kind:
|
297043
|
+
kind: isJupytext ? SourceFileKind.Notebook : kind,
|
296922
297044
|
file,
|
296923
297045
|
location: location4,
|
296924
297046
|
sha256,
|
@@ -296963,7 +297085,7 @@ async function postProcessMdast(session, { file, checkLinks, pageReferenceStates
|
|
296963
297085
|
selector: LINKS_SELECTOR
|
296964
297086
|
});
|
296965
297087
|
resolveReferencesTransform(mdast2, state.file, { state });
|
296966
|
-
embedTransform(session, mdast2, dependencies, state);
|
297088
|
+
embedTransform(session, mdast2, file, dependencies, state);
|
296967
297089
|
const pipe = unified();
|
296968
297090
|
(_a6 = session.plugins) === null || _a6 === void 0 ? void 0 : _a6.transforms.forEach((t2) => {
|
296969
297091
|
if (t2.stage !== "project")
|
@@ -297381,18 +297503,39 @@ async function fileProcessor(session, file, eventType, siteProject, serverReload
|
|
297381
297503
|
session.log.warn(`\u26A0\uFE0F No local project path for file: ${file}`);
|
297382
297504
|
return;
|
297383
297505
|
}
|
297506
|
+
const projectPath = siteProject.path;
|
297384
297507
|
const pageSlug = selectors_exports.selectPageSlug(session.store.getState(), siteProject.path, file);
|
297385
|
-
|
297508
|
+
const dependencies = selectors_exports.selectDependentFiles(session.store.getState(), file);
|
297509
|
+
if (!pageSlug && dependencies.length === 0) {
|
297386
297510
|
session.log.warn(`\u26A0\uFE0F File is not in project: ${file}`);
|
297387
297511
|
return;
|
297388
297512
|
}
|
297389
|
-
|
297390
|
-
|
297391
|
-
|
297392
|
-
|
297393
|
-
|
297394
|
-
|
297395
|
-
|
297513
|
+
if (pageSlug) {
|
297514
|
+
await fastProcessFile(session, {
|
297515
|
+
file,
|
297516
|
+
projectPath,
|
297517
|
+
projectSlug: siteProject.slug,
|
297518
|
+
pageSlug,
|
297519
|
+
...opts
|
297520
|
+
});
|
297521
|
+
}
|
297522
|
+
if (dependencies.length) {
|
297523
|
+
session.log.info(`\u{1F504} Updating dependent pages`);
|
297524
|
+
await Promise.all([
|
297525
|
+
dependencies.map((dep) => {
|
297526
|
+
const depSlug = selectors_exports.selectPageSlug(session.store.getState(), projectPath, dep);
|
297527
|
+
if (!depSlug)
|
297528
|
+
return void 0;
|
297529
|
+
return fastProcessFile(session, {
|
297530
|
+
file: dep,
|
297531
|
+
projectPath,
|
297532
|
+
projectSlug: siteProject.slug,
|
297533
|
+
pageSlug: depSlug,
|
297534
|
+
...opts
|
297535
|
+
});
|
297536
|
+
})
|
297537
|
+
]);
|
297538
|
+
}
|
297396
297539
|
serverReload();
|
297397
297540
|
}
|
297398
297541
|
function watchProcessor(operation, session, siteProject, serverReload, opts) {
|
@@ -297421,10 +297564,11 @@ function watchProcessor(operation, session, siteProject, serverReload, opts) {
|
|
297421
297564
|
};
|
297422
297565
|
}
|
297423
297566
|
function watchContent(session, serverReload, opts) {
|
297424
|
-
const
|
297567
|
+
const state = session.store.getState();
|
297568
|
+
const siteConfig = selectors_exports.selectCurrentSiteConfig(state);
|
297425
297569
|
if (!(siteConfig === null || siteConfig === void 0 ? void 0 : siteConfig.projects))
|
297426
297570
|
return;
|
297427
|
-
const siteConfigFile = selectors_exports.selectCurrentSiteFile(
|
297571
|
+
const siteConfigFile = selectors_exports.selectCurrentSiteFile(state);
|
297428
297572
|
const localProjects = siteConfig.projects.filter((proj) => {
|
297429
297573
|
return Boolean(proj.path);
|
297430
297574
|
});
|
@@ -297432,7 +297576,8 @@ function watchContent(session, serverReload, opts) {
|
|
297432
297576
|
const ignored = proj.path === "." ? localProjects.filter(({ path: path39 }) => path39 !== ".").map(({ path: path39 }) => (0, import_node_path35.join)(path39, "*")) : [];
|
297433
297577
|
if (siteConfigFile)
|
297434
297578
|
ignored.push(siteConfigFile);
|
297435
|
-
|
297579
|
+
const dependencies = new Set(selectors_exports.selectAllDependencies(state, proj.path));
|
297580
|
+
import_chokidar.default.watch([proj.path, ...dependencies], {
|
297436
297581
|
ignoreInitial: true,
|
297437
297582
|
ignored: ["public", "**/_build/**", "**/.git/**", ...ignored],
|
297438
297583
|
awaitWriteFinish: { stabilityThreshold: 100, pollInterval: 50 }
|
@@ -297658,6 +297803,7 @@ async function buildHtml(session, opts) {
|
|
297658
297803
|
|
297659
297804
|
// ../myst-cli/dist/build/utils/localArticleExport.js
|
297660
297805
|
var import_node_path51 = __toESM(require("path"), 1);
|
297806
|
+
var import_chokidar2 = __toESM(require_chokidar(), 1);
|
297661
297807
|
|
297662
297808
|
// ../myst-cli/dist/build/utils/resolveAndLogErrors.js
|
297663
297809
|
async function resolveAndLogErrors(session, promises, throwOnFailure) {
|
@@ -297784,7 +297930,7 @@ function renderImports(kind, output2, imports, packages, preamble) {
|
|
297784
297930
|
}
|
297785
297931
|
|
297786
297932
|
// ../jtex/dist/version.js
|
297787
|
-
var version3 = "1.0.
|
297933
|
+
var version3 = "1.0.12";
|
297788
297934
|
var version_default3 = version3;
|
297789
297935
|
|
297790
297936
|
// ../jtex/dist/jtex.js
|
@@ -299019,6 +299165,16 @@ var handlers3 = {
|
|
299019
299165
|
} else {
|
299020
299166
|
state.write(`\\qty{${node3.number}}{${(_d2 = (_c = node3.units) === null || _c === void 0 ? void 0 : _c.map((u3) => `\\${u3}`).join("")) !== null && _d2 !== void 0 ? _d2 : ""}}`);
|
299021
299167
|
}
|
299168
|
+
},
|
299169
|
+
inlineExpression(node3, state) {
|
299170
|
+
var _a6;
|
299171
|
+
if ((_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.length) {
|
299172
|
+
state.renderChildren(node3, true);
|
299173
|
+
} else {
|
299174
|
+
state.write("\\texttt{");
|
299175
|
+
state.text(node3.value, false);
|
299176
|
+
state.write("}");
|
299177
|
+
}
|
299022
299178
|
}
|
299023
299179
|
};
|
299024
299180
|
var TexSerializer = class {
|
@@ -299403,14 +299559,14 @@ async function localArticleToTexTemplated(session, file, templateOptions, projec
|
|
299403
299559
|
const state = session.store.getState();
|
299404
299560
|
frontmatter = (_a6 = selectors_exports.selectLocalProjectConfig(state, projectPath !== null && projectPath !== void 0 ? projectPath : ".")) !== null && _a6 !== void 0 ? _a6 : {};
|
299405
299561
|
const { dir, name: name2, ext: ext2 } = import_node_path43.default.parse(output2);
|
299406
|
-
const
|
299562
|
+
const includeFilenames = results.map((result, ind) => {
|
299407
299563
|
var _a7, _b;
|
299408
|
-
const
|
299409
|
-
const includeFile = import_node_path43.default.format({ dir, ext: ext2, base:
|
299564
|
+
const includeFilename = `${name2}-${(_b = (_a7 = content3[ind]) === null || _a7 === void 0 ? void 0 : _a7.slug) !== null && _b !== void 0 ? _b : ind}`;
|
299565
|
+
const includeFile = import_node_path43.default.format({ dir, ext: ext2, base: `${includeFilename}${ext2}` });
|
299410
299566
|
writeFileToFolder(includeFile, result.value);
|
299411
|
-
return
|
299567
|
+
return includeFilename;
|
299412
299568
|
});
|
299413
|
-
texContent =
|
299569
|
+
texContent = includeFilenames.map((base5) => `\\include{${base5}}`).join("\n");
|
299414
299570
|
}
|
299415
299571
|
session.log.info(toc(`\u{1F4D1} Exported TeX in %s, copying to ${output2}`));
|
299416
299572
|
const { preamble, suffix } = generatePreamble(preambleData);
|
@@ -299476,26 +299632,52 @@ var containerHandler2 = (node3, state) => {
|
|
299476
299632
|
state.ensureNewLine();
|
299477
299633
|
const prevState = state.data.isInFigure;
|
299478
299634
|
state.data.isInFigure = true;
|
299479
|
-
const { label } = node3;
|
299480
|
-
const
|
299481
|
-
const
|
299482
|
-
if (
|
299483
|
-
|
299635
|
+
const { label, kind } = node3;
|
299636
|
+
const captions = selectAll("caption,legend", node3);
|
299637
|
+
const imagesAndTables = selectAll("image,table", node3);
|
299638
|
+
if (label === "table10") {
|
299639
|
+
console.log(imagesAndTables);
|
299640
|
+
}
|
299641
|
+
if (imagesAndTables.length !== 1) {
|
299642
|
+
fileWarn(state.file, `Typst best supports figures with single image or table`, {
|
299484
299643
|
node: node3,
|
299485
|
-
source: "myst-to-typst"
|
299644
|
+
source: "myst-to-typst",
|
299645
|
+
note: `Figure "${label !== null && label !== void 0 ? label : "unlabeled"}" may not render correctly`
|
299486
299646
|
});
|
299487
|
-
return;
|
299488
299647
|
}
|
299489
|
-
|
299490
|
-
|
299491
|
-
|
299492
|
-
|
299493
|
-
|
299648
|
+
if (imagesAndTables.length > 1) {
|
299649
|
+
state.write("#figure((\n ");
|
299650
|
+
imagesAndTables.forEach((item) => {
|
299651
|
+
state.renderChildren({ children: [item] });
|
299652
|
+
state.write(",");
|
299653
|
+
});
|
299654
|
+
state.trimEnd();
|
299655
|
+
state.write(").join(),");
|
299656
|
+
} else if (imagesAndTables.length === 1) {
|
299657
|
+
state.write("#figure(\n ");
|
299658
|
+
state.renderChildren({ children: [imagesAndTables[0]] });
|
299659
|
+
state.trimEnd();
|
299660
|
+
state.write(",");
|
299661
|
+
} else {
|
299662
|
+
state.write("#figure([\n ");
|
299663
|
+
state.renderChildren(node3, true);
|
299664
|
+
state.trimEnd();
|
299665
|
+
state.write("],");
|
299666
|
+
}
|
299667
|
+
if (captions.length) {
|
299494
299668
|
state.write("\n caption: [");
|
299495
|
-
state.renderChildren(
|
299669
|
+
state.renderChildren({
|
299670
|
+
children: captions.map((cap2) => cap2.children).filter(Boolean).flat()
|
299671
|
+
}, true);
|
299496
299672
|
state.trimEnd();
|
299497
299673
|
state.write("],");
|
299498
299674
|
}
|
299675
|
+
if (kind) {
|
299676
|
+
state.write(`
|
299677
|
+
kind: "${kind}",`);
|
299678
|
+
state.write(`
|
299679
|
+
supplement: [${kind[0].toUpperCase() + kind.substring(1)}],`);
|
299680
|
+
}
|
299499
299681
|
state.write("\n)");
|
299500
299682
|
if (label)
|
299501
299683
|
state.write(` <${label}>`);
|
@@ -299704,7 +299886,7 @@ function stringToLatexText2(text7) {
|
|
299704
299886
|
return `${s5}$${next.text}$`;
|
299705
299887
|
return s5 + next.text;
|
299706
299888
|
}, "");
|
299707
|
-
const final = replaced.replace(new RegExp(BACKSLASH_SPACE2, "g"), "\\\\ ").replace(new RegExp(BACKSLASH2, "g"), "\\\\").replace(new RegExp(COMMENT, "g"), "\\/\\/").replace(new RegExp(TILDE2, "g"), "
|
299889
|
+
const final = replaced.replace(new RegExp(BACKSLASH_SPACE2, "g"), "\\\\ ").replace(new RegExp(BACKSLASH2, "g"), "\\\\").replace(new RegExp(COMMENT, "g"), "\\/\\/").replace(new RegExp(TILDE2, "g"), "$tilde$");
|
299708
299890
|
return cleanWhitespaceChars2(final, "~");
|
299709
299891
|
}
|
299710
299892
|
function stringToLatexMath2(text7) {
|
@@ -300022,6 +300204,62 @@ var inlineMath3 = (node3, state) => {
|
|
300022
300204
|
var MATH_HANDLERS3 = { math: math5, inlineMath: inlineMath3 };
|
300023
300205
|
var math_default2 = MATH_HANDLERS3;
|
300024
300206
|
|
300207
|
+
// ../myst-to-typst/dist/table.js
|
300208
|
+
function countColumns(table5) {
|
300209
|
+
var _a6, _b;
|
300210
|
+
const firstRow = (_a6 = table5.children) === null || _a6 === void 0 ? void 0 : _a6.find((child) => child.type === "tableRow");
|
300211
|
+
const columns = (_b = firstRow === null || firstRow === void 0 ? void 0 : firstRow.children) === null || _b === void 0 ? void 0 : _b.filter((cell3) => cell3.type === "tableCell").reduce((val, cell3) => {
|
300212
|
+
var _a7;
|
300213
|
+
return val + ((_a7 = cell3.colspan) !== null && _a7 !== void 0 ? _a7 : 1);
|
300214
|
+
}, 0);
|
300215
|
+
return columns;
|
300216
|
+
}
|
300217
|
+
function isHeaderRow(node3) {
|
300218
|
+
var _a6;
|
300219
|
+
if (node3.type !== "tableRow")
|
300220
|
+
return false;
|
300221
|
+
return (_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.filter((child) => child.type === "tableCell").every((child) => child.header);
|
300222
|
+
}
|
300223
|
+
function countHeaderRows(table5) {
|
300224
|
+
var _a6, _b;
|
300225
|
+
const headerRows = (_a6 = table5.children) === null || _a6 === void 0 ? void 0 : _a6.filter((child) => isHeaderRow(child));
|
300226
|
+
return (_b = headerRows === null || headerRows === void 0 ? void 0 : headerRows.length) !== null && _b !== void 0 ? _b : 0;
|
300227
|
+
}
|
300228
|
+
var tableHandler = (node3, state) => {
|
300229
|
+
const command = state.data.isInFigure ? "tablex" : "#tablex";
|
300230
|
+
const columns = countColumns(node3);
|
300231
|
+
if (!columns) {
|
300232
|
+
fileError(state.file, "Unable to count table columns", {
|
300233
|
+
node: node3,
|
300234
|
+
source: "myst-to-typst"
|
300235
|
+
});
|
300236
|
+
return;
|
300237
|
+
}
|
300238
|
+
state.useMacro('#import "@preview/tablex:0.0.7": tablex, cellx');
|
300239
|
+
state.write(`${command}(columns: ${columns}, header-rows: ${countHeaderRows(node3)},
|
300240
|
+
`);
|
300241
|
+
state.renderChildren(node3);
|
300242
|
+
state.write(")\n");
|
300243
|
+
};
|
300244
|
+
var tableRowHandler = (node3, state) => {
|
300245
|
+
state.renderChildren(node3);
|
300246
|
+
};
|
300247
|
+
var tableCellHandler = (node3, state) => {
|
300248
|
+
if (node3.rowspan || node3.colspan) {
|
300249
|
+
state.write("cellx(");
|
300250
|
+
if (node3.rowspan) {
|
300251
|
+
state.write(`rowspan: ${node3.rowspan}, `);
|
300252
|
+
}
|
300253
|
+
if (node3.colspan) {
|
300254
|
+
state.write(`colspan: ${node3.colspan}, `);
|
300255
|
+
}
|
300256
|
+
state.write(")");
|
300257
|
+
}
|
300258
|
+
state.write("[");
|
300259
|
+
state.renderChildren(node3);
|
300260
|
+
state.write("],");
|
300261
|
+
};
|
300262
|
+
|
300025
300263
|
// ../myst-to-typst/dist/index.js
|
300026
300264
|
var admonition2 = `#let admonition(body, heading: none, color: blue) = {
|
300027
300265
|
let stroke = (left: 2pt + color.darken(20%))
|
@@ -300053,6 +300291,17 @@ var blockquote3 = `#let blockquote(node, color: gray) = {
|
|
300053
300291
|
block(width: 100%, inset: 8pt, stroke: stroke)[#node]
|
300054
300292
|
}`;
|
300055
300293
|
var INDENT = " ";
|
300294
|
+
var linkHandler = (node3, state) => {
|
300295
|
+
const href = node3.url;
|
300296
|
+
state.write('#link("');
|
300297
|
+
state.write(hrefToLatexText2(href));
|
300298
|
+
state.write('")');
|
300299
|
+
if (node3.children.length && node3.children[0].value !== href) {
|
300300
|
+
state.write("[");
|
300301
|
+
state.renderChildren(node3, true);
|
300302
|
+
state.write("]");
|
300303
|
+
}
|
300304
|
+
};
|
300056
300305
|
var handlers4 = {
|
300057
300306
|
text(node3, state) {
|
300058
300307
|
state.text(node3.value);
|
@@ -300121,10 +300370,10 @@ var handlers4 = {
|
|
300121
300370
|
state.renderChildren(node3, true);
|
300122
300371
|
state.write("\n");
|
300123
300372
|
},
|
300124
|
-
|
300125
|
-
|
300126
|
-
|
300127
|
-
|
300373
|
+
thematicBreak(node3, state) {
|
300374
|
+
state.write("#line(length: 100%, stroke: gray)");
|
300375
|
+
state.closeBlock(node3);
|
300376
|
+
},
|
300128
300377
|
...math_default2,
|
300129
300378
|
mystRole(node3, state) {
|
300130
300379
|
state.renderChildren(node3, true);
|
@@ -300189,18 +300438,7 @@ ${node3.value}
|
|
300189
300438
|
abbreviation(node3, state) {
|
300190
300439
|
state.renderChildren(node3, true);
|
300191
300440
|
},
|
300192
|
-
link
|
300193
|
-
var _a6;
|
300194
|
-
const href = node3.url;
|
300195
|
-
state.write('#link("');
|
300196
|
-
state.write(hrefToLatexText2(href));
|
300197
|
-
state.write('")');
|
300198
|
-
if (((_a6 = node3.children[0]) === null || _a6 === void 0 ? void 0 : _a6.value) !== href) {
|
300199
|
-
state.write("[");
|
300200
|
-
state.renderChildren(node3, true);
|
300201
|
-
state.write("]");
|
300202
|
-
}
|
300203
|
-
},
|
300441
|
+
link: linkHandler,
|
300204
300442
|
admonition(node3, state) {
|
300205
300443
|
state.useMacro(admonition2);
|
300206
300444
|
state.ensureNewLine();
|
@@ -300229,7 +300467,9 @@ ${node3.value}
|
|
300229
300467
|
admonitionTitle() {
|
300230
300468
|
return;
|
300231
300469
|
},
|
300232
|
-
|
300470
|
+
table: tableHandler,
|
300471
|
+
tableRow: tableRowHandler,
|
300472
|
+
tableCell: tableCellHandler,
|
300233
300473
|
image(node3, state) {
|
300234
300474
|
const { width: nodeWidth, url: nodeSrc, align } = node3;
|
300235
300475
|
const src = nodeSrc;
|
@@ -300240,6 +300480,7 @@ ${node3.value}
|
|
300240
300480
|
},
|
300241
300481
|
container: containerHandler2,
|
300242
300482
|
caption: captionHandler2,
|
300483
|
+
legend: captionHandler2,
|
300243
300484
|
captionNumber: () => void 0,
|
300244
300485
|
crossReference(node3, state) {
|
300245
300486
|
const id = node3.identifier;
|
@@ -300249,7 +300490,12 @@ ${node3.value}
|
|
300249
300490
|
state.renderChildren(node3, true, " ");
|
300250
300491
|
},
|
300251
300492
|
cite(node3, state) {
|
300252
|
-
|
300493
|
+
var _a6;
|
300494
|
+
if (node3.protocol === "doi" || ((_a6 = node3.label) === null || _a6 === void 0 ? void 0 : _a6.startsWith("https://doi.org"))) {
|
300495
|
+
linkHandler(node3, state);
|
300496
|
+
} else {
|
300497
|
+
state.write(`@${node3.label}`);
|
300498
|
+
}
|
300253
300499
|
},
|
300254
300500
|
embed(node3, state) {
|
300255
300501
|
state.renderChildren(node3, true);
|
@@ -300344,7 +300590,7 @@ var TypstSerializer = class {
|
|
300344
300590
|
if (!inline)
|
300345
300591
|
this.closeBlock(node3);
|
300346
300592
|
}
|
300347
|
-
renderEnvironment(node3, env5
|
300593
|
+
renderEnvironment(node3, env5) {
|
300348
300594
|
this.file.result += `#${env5}[
|
300349
300595
|
`;
|
300350
300596
|
this.renderChildren(node3, true);
|
@@ -301111,6 +301357,14 @@ var mystDirective2 = (state, node3) => {
|
|
301111
301357
|
var mystRole2 = (state, node3) => {
|
301112
301358
|
state.renderChildren(node3);
|
301113
301359
|
};
|
301360
|
+
var inlineExpression = (state, node3, parent2) => {
|
301361
|
+
var _a6;
|
301362
|
+
if ((_a6 = node3.children) === null || _a6 === void 0 ? void 0 : _a6.length) {
|
301363
|
+
state.renderChildren(node3);
|
301364
|
+
} else {
|
301365
|
+
inlineCode3(state, { ...node3, type: "inlineCode" }, parent2);
|
301366
|
+
}
|
301367
|
+
};
|
301114
301368
|
var defaultHandlers = {
|
301115
301369
|
text: text5,
|
301116
301370
|
paragraph: paragraph2,
|
@@ -301153,7 +301407,8 @@ var defaultHandlers = {
|
|
301153
301407
|
cite,
|
301154
301408
|
citeGroup,
|
301155
301409
|
embed: embed2,
|
301156
|
-
include: include2
|
301410
|
+
include: include2,
|
301411
|
+
inlineExpression
|
301157
301412
|
};
|
301158
301413
|
|
301159
301414
|
// ../myst-to-docx/dist/serializer.js
|
@@ -302639,8 +302894,8 @@ function tableTransform(mdast2) {
|
|
302639
302894
|
const head2 = { type: "tableHead", children: [] };
|
302640
302895
|
const body3 = { type: "tableBody", children: [] };
|
302641
302896
|
table5.children.forEach((tr3) => {
|
302642
|
-
const
|
302643
|
-
if (
|
302897
|
+
const isHeaderRow2 = tr3.children.reduce((h4, v) => h4 && !!v.header, true);
|
302898
|
+
if (isHeaderRow2 && body3.children.length === 0) {
|
302644
302899
|
head2.children.push(tr3);
|
302645
302900
|
} else {
|
302646
302901
|
body3.children.push(tr3);
|
@@ -302946,7 +303201,7 @@ function affiliationIdTransform(frontmatters, idPrefix) {
|
|
302946
303201
|
}
|
302947
303202
|
|
302948
303203
|
// ../myst-to-jats/dist/inlineExpression.js
|
302949
|
-
var
|
303204
|
+
var inlineExpression2 = (node3, state) => {
|
302950
303205
|
const { identifier, value } = node3;
|
302951
303206
|
state.renderInline(node3, "xref", {
|
302952
303207
|
"ref-type": "custom",
|
@@ -303508,7 +303763,7 @@ var handlers5 = {
|
|
303508
303763
|
state.closeNode();
|
303509
303764
|
state.closeNode();
|
303510
303765
|
},
|
303511
|
-
inlineExpression
|
303766
|
+
inlineExpression: inlineExpression2
|
303512
303767
|
};
|
303513
303768
|
function createText2(text7) {
|
303514
303769
|
return { type: "text", text: escapeForXML2(text7) };
|
@@ -303832,7 +304087,7 @@ function writeJats(file, content3, opts) {
|
|
303832
304087
|
}
|
303833
304088
|
|
303834
304089
|
// ../myst-cli/dist/build/jats/single.js
|
303835
|
-
async function runJatsExport(session, exportOptions, projectPath, clean3, extraLinkTransformers) {
|
304090
|
+
async function runJatsExport(session, sourceFile, exportOptions, projectPath, clean3, extraLinkTransformers) {
|
303836
304091
|
const toc = tic();
|
303837
304092
|
const { output: output2, articles, sub_articles } = exportOptions;
|
303838
304093
|
const article = articles[0];
|
@@ -303886,6 +304141,7 @@ async function runJatsExport(session, exportOptions, projectPath, clean3, extraL
|
|
303886
304141
|
logMessagesFromVFile(session, jats);
|
303887
304142
|
session.log.info(toc(`\u{1F4D1} Exported JATS in %s, copying to ${output2}`));
|
303888
304143
|
writeFileToFolder(output2, jats.result);
|
304144
|
+
return { tempFolders: [] };
|
303889
304145
|
}
|
303890
304146
|
|
303891
304147
|
// ../myst-cli/dist/build/pdf/single.js
|
@@ -304274,7 +304530,7 @@ function writeMecaManifest(manifestItems, mecaFolder) {
|
|
304274
304530
|
const manifest = createManifestXml(manifestItems);
|
304275
304531
|
import_node_fs34.default.writeFileSync(import_node_path49.default.join(mecaFolder, "manifest.xml"), manifest);
|
304276
304532
|
}
|
304277
|
-
async function runMecaExport(session, exportOptions, projectPath, clean3, extraLinkTransformers) {
|
304533
|
+
async function runMecaExport(session, sourceFile, exportOptions, projectPath, clean3, extraLinkTransformers) {
|
304278
304534
|
const toc = tic();
|
304279
304535
|
const { output: output2, articles } = exportOptions;
|
304280
304536
|
const article = articles === null || articles === void 0 ? void 0 : articles[0];
|
@@ -304292,7 +304548,7 @@ async function runMecaExport(session, exportOptions, projectPath, clean3, extraL
|
|
304292
304548
|
});
|
304293
304549
|
if (jatsExports.length === 0 && article) {
|
304294
304550
|
const jatsOutput = import_node_path49.default.join(mecaFolder, "article.xml");
|
304295
|
-
await runJatsExport(session, { ...exportOptions, output: jatsOutput }, projectPath, clean3, extraLinkTransformers);
|
304551
|
+
await runJatsExport(session, sourceFile, { ...exportOptions, output: jatsOutput }, projectPath, clean3, extraLinkTransformers);
|
304296
304552
|
addManifestItem(manifestItems, "article-metadata", mecaFolder, jatsOutput);
|
304297
304553
|
const jatsFiles = import_node_path49.default.join(mecaFolder, "files");
|
304298
304554
|
if (import_node_fs34.default.existsSync(jatsFiles)) {
|
@@ -304324,8 +304580,8 @@ To resolve this, run: myst build --all`, {
|
|
304324
304580
|
const jatsFiles = import_node_path49.default.join(import_node_path49.default.dirname(jatsOutput), "files");
|
304325
304581
|
if (import_node_fs34.default.existsSync(jatsFiles)) {
|
304326
304582
|
import_node_fs34.default.readdirSync(jatsFiles).forEach((file) => {
|
304327
|
-
const
|
304328
|
-
const fileDest = copyFileToFolder(session,
|
304583
|
+
const src = import_node_path49.default.join(jatsFiles, file);
|
304584
|
+
const fileDest = copyFileToFolder(session, src, import_node_path49.default.join(mecaFolder, "files"), fileCopyErrorLogFn);
|
304329
304585
|
addManifestItem(manifestItems, "article-supporting-file", mecaFolder, fileDest);
|
304330
304586
|
});
|
304331
304587
|
}
|
@@ -304389,6 +304645,7 @@ To resolve this, run: myst build --all`, {
|
|
304389
304645
|
zip2.writeZip(output2);
|
304390
304646
|
logMessagesFromVFile(session, vfile2);
|
304391
304647
|
session.log.info(toc(`\u{1F910} MECA output copied and zipped to ${output2} in %s`));
|
304648
|
+
return { tempFolders: [] };
|
304392
304649
|
}
|
304393
304650
|
|
304394
304651
|
// ../myst-cli/dist/build/md/index.js
|
@@ -308417,8 +308674,8 @@ function container3(node3, _, state, info) {
|
|
308417
308674
|
const listNodes = selectAll("tableRow", tableNode).map((row2) => {
|
308418
308675
|
const cells2 = selectAll("tableCell", row2);
|
308419
308676
|
if (inHeader) {
|
308420
|
-
const
|
308421
|
-
if (
|
308677
|
+
const isHeaderRow2 = cells2.map((cell3) => cell3.header).reduce((val, allHeaders) => val ? allHeaders : false, true);
|
308678
|
+
if (isHeaderRow2) {
|
308422
308679
|
headerRows += 1;
|
308423
308680
|
} else {
|
308424
308681
|
inHeader = false;
|
@@ -308764,7 +309021,7 @@ function writeMd(file, node3, frontmatter) {
|
|
308764
309021
|
}
|
308765
309022
|
|
308766
309023
|
// ../myst-cli/dist/build/md/index.js
|
308767
|
-
async function runMdExport(session, exportOptions, projectPath, clean3, extraLinkTransformers) {
|
309024
|
+
async function runMdExport(session, sourceFile, exportOptions, projectPath, clean3, extraLinkTransformers) {
|
308768
309025
|
const toc = tic();
|
308769
309026
|
const { output: output2, articles } = exportOptions;
|
308770
309027
|
const article = articles[0];
|
@@ -308790,47 +309047,82 @@ async function runMdExport(session, exportOptions, projectPath, clean3, extraLin
|
|
308790
309047
|
logMessagesFromVFile(session, mdOut);
|
308791
309048
|
session.log.info(toc(`\u{1F4D1} Exported MD in %s, copying to ${output2}`));
|
308792
309049
|
writeFileToFolder(output2, mdOut.result);
|
309050
|
+
return { tempFolders: [] };
|
308793
309051
|
}
|
308794
309052
|
|
308795
309053
|
// ../myst-cli/dist/build/utils/localArticleExport.js
|
309054
|
+
async function runExportAndWatch(watch2, exportFn, session, $file, exportOptions, projectPath, clean3) {
|
309055
|
+
let results = await exportFn(session, $file, exportOptions, projectPath, clean3);
|
309056
|
+
if (watch2) {
|
309057
|
+
const watchedFiles = /* @__PURE__ */ new Set([
|
309058
|
+
$file,
|
309059
|
+
...exportOptions.articles,
|
309060
|
+
...exportOptions.articles.map((article) => {
|
309061
|
+
return selectors_exports.selectFileDependencies(session.store.getState(), article);
|
309062
|
+
}).flat()
|
309063
|
+
]);
|
309064
|
+
import_chokidar2.default.watch([...watchedFiles], {
|
309065
|
+
awaitWriteFinish: { stabilityThreshold: 100, pollInterval: 50 }
|
309066
|
+
}).on("change", async (eventType, modifiedFile) => {
|
309067
|
+
const { reloading } = selectors_exports.selectReloadingState(session.store.getState());
|
309068
|
+
if (reloading) {
|
309069
|
+
session.store.dispatch(watch.actions.markReloadRequested(true));
|
309070
|
+
return;
|
309071
|
+
}
|
309072
|
+
session.store.dispatch(watch.actions.markReloading(true));
|
309073
|
+
session.log.debug(`File modified: "${modifiedFile}" (${eventType})`);
|
309074
|
+
while (selectors_exports.selectReloadingState(session.store.getState()).reloadRequested) {
|
309075
|
+
session.store.dispatch(watch.actions.markReloadRequested(false));
|
309076
|
+
results = await exportFn(session, $file, exportOptions, projectPath, clean3);
|
309077
|
+
}
|
309078
|
+
session.store.dispatch(watch.actions.markReloading(false));
|
309079
|
+
results = await exportFn(session, $file, exportOptions, projectPath, clean3);
|
309080
|
+
});
|
309081
|
+
}
|
309082
|
+
return results;
|
309083
|
+
}
|
308796
309084
|
async function _localArticleExport(session, exportOptionsList, opts) {
|
308797
|
-
const { clean: clean3, projectPath } = opts;
|
309085
|
+
const { clean: clean3, projectPath, watch: watch2 } = opts;
|
308798
309086
|
const errors3 = await resolveAndLogErrors(session, exportOptionsList.map(async (exportOptionsWithFile) => {
|
308799
309087
|
var _a6;
|
308800
309088
|
const { $file, $project, ...exportOptions } = exportOptionsWithFile;
|
308801
309089
|
const { format, output: output2 } = exportOptions;
|
308802
309090
|
const sessionClone = session.clone();
|
308803
309091
|
const fileProjectPath = (_a6 = projectPath !== null && projectPath !== void 0 ? projectPath : $project) !== null && _a6 !== void 0 ? _a6 : findCurrentProjectAndLoad(sessionClone, import_node_path51.default.dirname($file));
|
308804
|
-
let exportResults;
|
308805
309092
|
if (fileProjectPath) {
|
308806
309093
|
await loadProjectFromDisk(sessionClone, fileProjectPath);
|
308807
309094
|
}
|
309095
|
+
let exportFn;
|
308808
309096
|
if (format === ExportFormats.tex) {
|
308809
309097
|
if (import_node_path51.default.extname(output2) === ".zip") {
|
308810
|
-
|
309098
|
+
exportFn = runTexZipExport;
|
308811
309099
|
} else {
|
308812
|
-
|
309100
|
+
exportFn = runTexExport;
|
308813
309101
|
}
|
308814
309102
|
} else if (format === ExportFormats.typst) {
|
308815
309103
|
if (import_node_path51.default.extname(output2) === ".zip") {
|
308816
|
-
|
309104
|
+
exportFn = runTypstZipExport;
|
308817
309105
|
} else {
|
308818
|
-
|
309106
|
+
exportFn = runTypstExport;
|
308819
309107
|
}
|
308820
309108
|
} else if (format === ExportFormats.docx) {
|
308821
|
-
|
309109
|
+
exportFn = runWordExport;
|
308822
309110
|
} else if (format === ExportFormats.xml) {
|
308823
|
-
|
309111
|
+
exportFn = runJatsExport;
|
308824
309112
|
} else if (format === ExportFormats.md) {
|
308825
|
-
|
309113
|
+
exportFn = runMdExport;
|
308826
309114
|
} else if (format === ExportFormats.meca) {
|
308827
|
-
|
309115
|
+
exportFn = runMecaExport;
|
308828
309116
|
} else {
|
308829
309117
|
const keepTexAndLogs = format === ExportFormats.pdftex;
|
308830
|
-
|
308831
|
-
|
308832
|
-
|
309118
|
+
exportFn = async (fnSession, fnFile, fnOpts, fnPath, fnClean) => {
|
309119
|
+
const texExportOptions = texExportOptionsFromPdf(fnSession, fnOpts, keepTexAndLogs, fnClean);
|
309120
|
+
const results = await runTexExport(fnSession, fnFile, texExportOptions, fnPath, fnClean);
|
309121
|
+
await createPdfGivenTexExport(fnSession, texExportOptions, output2, keepTexAndLogs, fnClean, results.hasGlossaries);
|
309122
|
+
return results;
|
309123
|
+
};
|
308833
309124
|
}
|
309125
|
+
await runExportAndWatch(!!watch2, exportFn, sessionClone, $file, exportOptions, fileProjectPath, clean3);
|
308834
309126
|
}), opts.throwOnFailure);
|
308835
309127
|
return errors3;
|
308836
309128
|
}
|
@@ -308933,7 +309225,7 @@ function extToKind(ext2) {
|
|
308933
309225
|
return ext2;
|
308934
309226
|
}
|
308935
309227
|
async function build(session, files, opts) {
|
308936
|
-
const { site, all: all10 } = opts;
|
309228
|
+
const { site, all: all10, watch: watch2 } = opts;
|
308937
309229
|
const performSiteBuild = all10 || files.length === 0 && exportSite(session, opts);
|
308938
309230
|
const exportOptionsList = await collectAllBuildExportOptions(session, files, opts);
|
308939
309231
|
const exportLogList = exportOptionsList.map((exportOptions) => {
|
@@ -308957,7 +309249,7 @@ exports:
|
|
308957
309249
|
} else {
|
308958
309250
|
session.log.info(`\u{1F4EC} Performing exports:
|
308959
309251
|
${exportLogList.join("\n ")}`);
|
308960
|
-
await localArticleExport(session, exportOptionsList, {});
|
309252
|
+
await localArticleExport(session, exportOptionsList, { watch: watch2 });
|
308961
309253
|
}
|
308962
309254
|
if (!performSiteBuild)
|
308963
309255
|
return;
|
@@ -308967,6 +309259,9 @@ exports:
|
|
308967
309259
|
session.log.debug(`To build a site, first run 'myst init --site'`);
|
308968
309260
|
} else {
|
308969
309261
|
session.log.info(`\u{1F30E} Building MyST site`);
|
309262
|
+
if (watch2) {
|
309263
|
+
session.log.warn(`Site content will not be watched and updated; use 'myst start' instead`);
|
309264
|
+
}
|
308970
309265
|
if (opts.html) {
|
308971
309266
|
await buildHtml(session, opts);
|
308972
309267
|
} else {
|
@@ -316252,6 +316547,9 @@ function makeProjectOption(description) {
|
|
316252
316547
|
function makeAllOption(description) {
|
316253
316548
|
return new Option("-a, --all", description).default(false);
|
316254
316549
|
}
|
316550
|
+
function makeWatchOption() {
|
316551
|
+
return new Option("--watch", "Watch modified files and re-build on change").default(false);
|
316552
|
+
}
|
316255
316553
|
function makeNamedExportOption(description) {
|
316256
316554
|
return new Option("-o, --output <output>", description);
|
316257
316555
|
}
|
@@ -316312,7 +316610,7 @@ function makeYesOption() {
|
|
316312
316610
|
|
316313
316611
|
// src/build.ts
|
316314
316612
|
function makeBuildCLI(program3) {
|
316315
|
-
const command = new Command("build").description("Build PDF, LaTeX, Word and website exports from MyST files").argument("[files...]", "list of files to export").addOption(makePdfOption("Build PDF output")).addOption(makeTexOption("Build LaTeX outputs")).addOption(makeTypstOption("Build Typst outputs")).addOption(makeDocxOption("Build Docx output")).addOption(makeMdOption("Build MD output")).addOption(makeJatsOption("Build JATS xml output")).addOption(makeMecaOptions("Build MECA zip output")).addOption(makeSiteOption("Build MyST site content")).addOption(makeHtmlOption("Build static HTML site content")).addOption(makeAllOption("Build all exports")).addOption(makeNamedExportOption("Output file for the export")).addOption(makeForceOption()).addOption(makeCheckLinksOption()).addOption(makeStrictOption()).action(clirun2(Session, build, program3));
|
316613
|
+
const command = new Command("build").description("Build PDF, LaTeX, Word and website exports from MyST files").argument("[files...]", "list of files to export").addOption(makePdfOption("Build PDF output")).addOption(makeTexOption("Build LaTeX outputs")).addOption(makeTypstOption("Build Typst outputs")).addOption(makeDocxOption("Build Docx output")).addOption(makeMdOption("Build MD output")).addOption(makeJatsOption("Build JATS xml output")).addOption(makeMecaOptions("Build MECA zip output")).addOption(makeSiteOption("Build MyST site content")).addOption(makeHtmlOption("Build static HTML site content")).addOption(makeAllOption("Build all exports")).addOption(makeWatchOption()).addOption(makeNamedExportOption("Output file for the export")).addOption(makeForceOption()).addOption(makeCheckLinksOption()).addOption(makeStrictOption()).action(clirun2(Session, build, program3));
|
316316
316614
|
return command;
|
316317
316615
|
}
|
316318
316616
|
|
@@ -316861,19 +317159,20 @@ function makeStartCLI(program3) {
|
|
316861
317159
|
// src/templates.ts
|
316862
317160
|
var import_node_fs39 = __toESM(require("fs"), 1);
|
316863
317161
|
var import_node_path57 = require("path");
|
316864
|
-
var allTemplates = [TemplateKind.tex, TemplateKind.docx, TemplateKind.site];
|
317162
|
+
var allTemplates = [TemplateKind.tex, TemplateKind.typst, TemplateKind.docx, TemplateKind.site];
|
316865
317163
|
function getKindFromName(name2) {
|
316866
317164
|
var _a6;
|
316867
|
-
return ((_a6 = name2.match(/^(tex|docx|site)\//)) == null ? void 0 : _a6[1]) ?? void 0;
|
317165
|
+
return ((_a6 = name2.match(/^(tex|typst|docx|site)\//)) == null ? void 0 : _a6[1]) ?? void 0;
|
316868
317166
|
}
|
316869
317167
|
function getKind(session, kinds) {
|
316870
317168
|
if (!kinds)
|
316871
317169
|
return void 0;
|
316872
|
-
const { pdf, tex, docx, site } = kinds;
|
317170
|
+
const { pdf, tex, typst, docx, site } = kinds;
|
316873
317171
|
if (pdf)
|
316874
|
-
session.log.warn('PDF templates
|
317172
|
+
session.log.warn('PDF templates may use either "tex" or "typst"');
|
316875
317173
|
const flags = {
|
316876
317174
|
[TemplateKind.tex]: (tex || pdf) ?? false,
|
317175
|
+
[TemplateKind.typst]: (typst || pdf) ?? false,
|
316877
317176
|
[TemplateKind.docx]: docx ?? false,
|
316878
317177
|
[TemplateKind.site]: site ?? false
|
316879
317178
|
};
|
@@ -316922,8 +317221,8 @@ async function listTemplatesCLI(session, name2, opts) {
|
|
316922
317221
|
template.id = name2;
|
316923
317222
|
session.log.debug(toc(`Found ${template.id} template in %s`));
|
316924
317223
|
session.log.info(
|
316925
|
-
`${source_default6.bold.green((template.title ?? "").padEnd(
|
316926
|
-
template.id.replace(/^(tex|site|docx)\//, "").replace(/^myst\//, "")
|
317224
|
+
`${source_default6.bold.green((template.title ?? "").padEnd(30))}${source_default6.bold.blueBright(
|
317225
|
+
template.id.replace(/^(tex|typst|site|docx)\//, "").replace(/^myst\//, "")
|
316927
317226
|
)}`
|
316928
317227
|
);
|
316929
317228
|
session.log.info(
|
@@ -316982,8 +317281,8 @@ Options:`));
|
|
316982
317281
|
var _a7;
|
316983
317282
|
session.log.info(
|
316984
317283
|
`
|
316985
|
-
${source_default6.bold.green((template.title ?? "").padEnd(
|
316986
|
-
template.id.replace(/^tex\//, "").replace(/^myst\//, "")
|
317284
|
+
${source_default6.bold.green((template.title ?? "").padEnd(30))}${source_default6.bold.blueBright(
|
317285
|
+
template.id.replace(/^(tex|typst|site|docx)\//, "").replace(/^myst\//, "")
|
316987
317286
|
)}
|
316988
317287
|
Description: ${source_default6.dim(template.description ?? "")}
|
316989
317288
|
Tags: ${source_default6.dim(
|
@@ -316993,11 +317292,11 @@ Tags: ${source_default6.dim(
|
|
316993
317292
|
});
|
316994
317293
|
}
|
316995
317294
|
function makeDownloadCLI(program3) {
|
316996
|
-
const command = new Command("download").description("Download a public template to a path").argument("<template>", "The template URL or name").argument("[path]", "A folder to download and unzip the template to").addOption(makePdfOption("Download PDF template")).addOption(makeTexOption("Download LaTeX template")).addOption(makeDocxOption("Download Docx template")).addOption(makeSiteOption("Download Site template")).addOption(makeForceOption()).action(clirun2(Session, downloadTemplateCLI, program3));
|
317295
|
+
const command = new Command("download").description("Download a public template to a path").argument("<template>", "The template URL or name").argument("[path]", "A folder to download and unzip the template to").addOption(makePdfOption("Download PDF template")).addOption(makeTexOption("Download LaTeX template")).addOption(makeTypstOption("Download Typst template")).addOption(makeDocxOption("Download Docx template")).addOption(makeSiteOption("Download Site template")).addOption(makeForceOption()).action(clirun2(Session, downloadTemplateCLI, program3));
|
316997
317296
|
return command;
|
316998
317297
|
}
|
316999
317298
|
function makeListCLI(program3) {
|
317000
|
-
const command = new Command("list").description("List, filter or lookup details on public templates").argument("[name]", "The optional name to list about a specific template").addOption(makePdfOption("List PDF templates")).addOption(makeTexOption("List LaTeX templates")).addOption(makeDocxOption("List Docx templates")).addOption(makeSiteOption("List Site templates")).option(
|
317299
|
+
const command = new Command("list").description("List, filter or lookup details on public templates").argument("[name]", "The optional name to list about a specific template").addOption(makePdfOption("List PDF templates")).addOption(makeTexOption("List LaTeX templates")).addOption(makeTypstOption("List Typst templates")).addOption(makeDocxOption("List Docx templates")).addOption(makeSiteOption("List Site templates")).option(
|
317001
317300
|
"--tag <tag>",
|
317002
317301
|
"Any tags to filter the list by multiple tags can be joined with a comma."
|
317003
317302
|
).action(clirun2(Session, listTemplatesCLI, program3));
|