diff --git a/.changeset/sixty-peas-do.md b/.changeset/sixty-peas-do.md new file mode 100644 index 000000000..deb90f89c --- /dev/null +++ b/.changeset/sixty-peas-do.md @@ -0,0 +1,6 @@ +--- +"myst-cli": patch +"mystmd": patch +--- + +Fix imports of plugins on Windows diff --git a/packages/myst-cli/src/plugins.ts b/packages/myst-cli/src/plugins.ts index fbe9e4a7b..0c9a117e3 100644 --- a/packages/myst-cli/src/plugins.ts +++ b/packages/myst-cli/src/plugins.ts @@ -1,4 +1,5 @@ import fs from 'node:fs'; +import { pathToFileURL } from 'node:url'; import type { ISession } from './session/types.js'; import { selectors } from './store/index.js'; import { RuleId, plural, type MystPlugin, type ValidatedMystPlugin } from 'myst-common'; @@ -97,8 +98,9 @@ export async function loadPlugins(session: ISession): Promise { + child.class = child.class ? `${child.class} red` : 'red'; + }); + return children; + }, +}; + +const plugin = { name: 'Example role', roles: [redRole] }; + +export default plugin; diff --git a/packages/mystmd/tests/exports.yml b/packages/mystmd/tests/exports.yml index 6f569e964..09e7c05af 100644 --- a/packages/mystmd/tests/exports.yml +++ b/packages/mystmd/tests/exports.yml @@ -190,6 +190,13 @@ cases: content: outputs/basic-site-config.json - path: basic-site/_build/site/myst.xref.json content: outputs/basic-site-myst.xref.json + - title: Basic plugin build + cwd: basic-plugin + command: myst build + outputs: + - path: basic-plugin/_build/site/content/index.json + # Keys and file hashes are removed from this output file + content: outputs/basic-plugin-content.json - title: XRef site build cwd: site-xrefs command: myst build diff --git a/packages/mystmd/tests/outputs/basic-plugin-content.json b/packages/mystmd/tests/outputs/basic-plugin-content.json new file mode 100644 index 000000000..1dba3d730 --- /dev/null +++ b/packages/mystmd/tests/outputs/basic-plugin-content.json @@ -0,0 +1,127 @@ +{ + "kind": "Article", + "sha256": "900eec73ecdfd1641367698dab8e7727ce2a81122ba0cd641c61c4f0f3b30694", + "slug": "index", + "location": "/index.md", + "dependencies": [], + "frontmatter": { + "title": "Basic Test", + "github": "https://github.com/jupyter-book/mystmd", + "keywords": [], + "exports": [ + { + "format": "md", + "filename": "index.md", + "url": "/index-827a0078d531c946c69925141436e783.md" + } + ] + }, + "mdast": { + "type": "root", + "children": [ + { + "type": "block", + "children": [ + { + "type": "heading", + "depth": 2, + "position": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "children": [ + { + "type": "text", + "value": "Lorem Ipsum", + "position": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 1 + } + } + } + ], + "identifier": "lorem-ipsum", + "label": "Lorem Ipsum", + "html_id": "lorem-ipsum", + "implicit": true + }, + { + "type": "paragraph", + "position": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "children": [ + { + "type": "text", + "value": "Set ", + "position": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "text", + "value": "this text", + "position": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "class": "red" + }, + { + "type": "text", + "value": " to a class of red.", + "position": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 1 + } + } + } + ] + } + ] + } + ] + }, + "references": { + "cite": { + "order": [], + "data": {} + } + } +}