@dogsbay/format-mkdocs 0.2.0-beta.182 → 0.2.0-beta.184

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.
@@ -227,6 +227,12 @@ function inlineToTemplate(nodes) {
227
227
  }
228
228
  function inlineNodeToTemplate(node) {
229
229
  switch (node.type) {
230
+ case "when":
231
+ // reader-choice text (plans/reader-choices.md): its content, for every value
232
+ return inlineToTemplate(node.children);
233
+ case "choice-value":
234
+ // a reader's looked-up value: the one resolveChoices wrote in
235
+ return node.form === "link" && node.children?.length ? inlineToTemplate(node.children) : escapeTemplate(node.text ?? "");
230
236
  case "text": {
231
237
  let text = escapeTemplate(node.text);
232
238
  if (node.bold)
@@ -270,6 +276,12 @@ function inlineToHtml(nodes) {
270
276
  }
271
277
  function inlineNodeToHtml(node) {
272
278
  switch (node.type) {
279
+ case "when":
280
+ // reader-choice text (plans/reader-choices.md): its content, for every value
281
+ return inlineToHtml(node.children);
282
+ case "choice-value":
283
+ // a reader's looked-up value: the one resolveChoices wrote in
284
+ return node.form === "link" && node.children?.length ? inlineToHtml(node.children) : escapeHtml(node.text ?? "");
273
285
  case "text": {
274
286
  let text = escapeHtml(node.text);
275
287
  if (node.bold)
package/dist/importer.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * Reads a MkDocs project directory (containing mkdocs.yml) and produces
5
5
  * ExportPage[] + NavItem[] — the universal format contract.
6
6
  */
7
+ import { mkdocsTypography } from "./typography.js";
7
8
  import { pagesOutsideNav } from "./nav-coverage.js";
8
9
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
9
10
  import { join, relative, basename, dirname, resolve } from "node:path";
@@ -64,7 +65,10 @@ export async function importMkdocsProject(sourceDir, opts = {}) {
64
65
  if (macrosData && Object.keys(macrosData).length > 0) {
65
66
  pluginOpts.templates = { dataFiles: macrosData };
66
67
  }
67
- const md = new MarkdownIt({ html: true, linkify: true, typographer: true });
68
+ // characters as typed unless the site config asks for smartypants or mkdocs.yml enables smarty
69
+ // (plans/source-typography.md); asciidoctor typography is for Dogsbay-MD sources
70
+ const typographer = opts.typography === "smartypants" || (opts.typography === undefined && mkdocsTypography(config.raw?.markdown_extensions) === "smartypants");
71
+ const md = new MarkdownIt({ html: true, linkify: true, typographer });
68
72
  const mdOpts = {
69
73
  ...pluginOpts,
70
74
  snippets: { root: join(sourceDir, "includes"), autoAppend: ["mkdocs.md"] },
package/dist/index.d.ts CHANGED
@@ -73,3 +73,4 @@ export declare function mkdocsPlugin(md: MarkdownIt, options?: MkdocsPluginOptio
73
73
  * the migrate-mkdocs FastAPI smoke.
74
74
  */
75
75
  export declare function configureFromMkdocs(extensions: unknown): MkdocsPluginOptions;
76
+ export { mkdocsTypography } from "./typography.js";
package/dist/index.js CHANGED
@@ -205,3 +205,4 @@ function normalizeExtensions(raw) {
205
205
  }
206
206
  return [];
207
207
  }
208
+ export { mkdocsTypography } from "./typography.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * How a MkDocs site renders typed characters (plans/source-typography.md): Python-Markdown shows them
3
+ * as typed unless `smarty` is on (curly quotes, `…`, `–`/`—`), which markdown-it's typographer
4
+ * approximates ("smartypants"). `pymdownx.smartsymbols` alone (`(c)`, arrows, fractions, no quotes)
5
+ * has no exact counterpart and maps to nothing; `smarty` with some of its options off still maps to
6
+ * smartypants. `markdown_extensions` is a list (`- smarty`, `- smarty: {…}`) or a mapping.
7
+ */
8
+ export declare function mkdocsTypography(markdownExtensions: unknown): "smartypants" | undefined;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * How a MkDocs site renders typed characters (plans/source-typography.md): Python-Markdown shows them
3
+ * as typed unless `smarty` is on (curly quotes, `…`, `–`/`—`), which markdown-it's typographer
4
+ * approximates ("smartypants"). `pymdownx.smartsymbols` alone (`(c)`, arrows, fractions, no quotes)
5
+ * has no exact counterpart and maps to nothing; `smarty` with some of its options off still maps to
6
+ * smartypants. `markdown_extensions` is a list (`- smarty`, `- smarty: {…}`) or a mapping.
7
+ */
8
+ export function mkdocsTypography(markdownExtensions) {
9
+ const names = Array.isArray(markdownExtensions)
10
+ ? markdownExtensions.flatMap((e) => (typeof e === "string" ? [e] : e && typeof e === "object" ? Object.keys(e) : []))
11
+ : markdownExtensions && typeof markdownExtensions === "object"
12
+ ? Object.keys(markdownExtensions)
13
+ : [];
14
+ return names.some((n) => n === "smarty" || n === "markdown.extensions.smarty") ? "smartypants" : undefined;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/format-mkdocs",
3
- "version": "0.2.0-beta.182",
3
+ "version": "0.2.0-beta.184",
4
4
  "description": "MkDocs format plugin for Dogsbay — import/export MkDocs projects via TreeNode[]",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -46,10 +46,10 @@
46
46
  "markdown-it-deflist": "^3.0.1",
47
47
  "nunjucks": "^3.2.4",
48
48
  "yaml": "^2.9.0",
49
- "@dogsbay/autodoc-python": "0.2.0-beta.182",
50
- "@dogsbay/serialize-core": "0.2.0-beta.182",
51
- "@dogsbay/format-dogsbay-md": "0.2.0-beta.182",
52
- "@dogsbay/types": "0.2.0-beta.182"
49
+ "@dogsbay/autodoc-python": "0.2.0-beta.184",
50
+ "@dogsbay/serialize-core": "0.2.0-beta.184",
51
+ "@dogsbay/format-dogsbay-md": "0.2.0-beta.184",
52
+ "@dogsbay/types": "0.2.0-beta.184"
53
53
  },
54
54
  "repository": {
55
55
  "type": "git",