Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ location of your modules.
<script type="importmap">
{
"imports": {
"markdown-it": "/path/to/modules/markdown-it/index.mjs",
"markdown-it": "/path/to/modules/markdown-it/dist/browser/markdown-it.esm.min.mjs",
"markdown-it-math": "/path/to/modules/markdown-it-math/index.js",
"mathup": "/path/to/modules/mathup.js",
"temml": "/path/to/modules/temml.mjs"
Expand Down
14 changes: 1 addition & 13 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,12 @@
<script type="importmap">
{
"imports": {
"markdown-it": "../node_modules/markdown-it/index.mjs",
"markdown-it": "../node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs",
"markdown-it-math": "../index.js",
"mathup": "../node_modules/mathup/dist/module/mathup.js",
"mathup/": "../node_modules/mathup/dist/",
"temml": "../node_modules/temml/dist/temml.mjs",
"temml/": "../node_modules/temml/dist/"
},
"scopes": {
"../node_modules/linkify-it/": {
"uc.micro": "../node_modules/uc.micro/index.mjs"
},
"../node_modules/markdown-it/": {
"entities": "../node_modules/entities/lib/esm/index.js",
"linkify-it": "../node_modules/linkify-it/index.mjs",
"mdurl": "../node_modules/mdurl/index.mjs",
"punycode.js": "../node_modules/punycode/punycode.es6.js",
"uc.micro": "../node_modules/uc.micro/index.mjs"
}
}
}
</script>
Expand Down
10 changes: 7 additions & 3 deletions demo/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @import { Delimiter } from "../index.js"
*/

import markdownIt from "markdown-it";
import markdownItMath from "markdown-it-math";
import temml from "temml";
Expand Down Expand Up @@ -49,7 +53,7 @@ let renderer = rendererControl.value === "temml" ? "temml" : "mathml";

/**
* @param {unknown} thing
* @returns {thing is string | import("../index.js").Delimiter[]}
* @returns {thing is string | Delimiter[]}
*/
function isValidDelimiters(thing) {
if (typeof thing === "string") {
Expand All @@ -76,7 +80,7 @@ function isValidDelimiters(thing) {
return true;
}

/** @type {string | import("../index.js").Delimiter[] | undefined} */
/** @type {string | Delimiter[] | undefined} */
let inlineDelimiters;
try {
const value = JSON.parse(inlineDelimitersInput.value);
Expand All @@ -87,7 +91,7 @@ try {
// pass
}

/** @type {string | import("../index.js").Delimiter[] | undefined} */
/** @type {string | Delimiter[] | undefined} */
let blockDelimiters;
try {
const value = JSON.parse(blockDelimitersInput.value);
Expand Down
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import plugin from "./src/plugin.js";

/**
* @import { MarkdownIt } from "markdown-it";
* @import { Options as MathupOptions } from "mathup"
* @import { PluginOptions } from "./src/plugin.js"
*/
Expand All @@ -12,12 +13,14 @@ const mathup = await import("mathup").then(

/**
* @typedef {PluginOptions & { mathupOptions?: MathupOptions }} MarkdownItMathOptions
* @param {MarkdownIt} md
* @param {MarkdownItMathOptions} options
* @returns {void}
*/

/** @type {import("markdown-it").PluginWithOptions<MarkdownItMathOptions>} */
export default function markdownItMath(md, { mathupOptions, ...options } = {}) {
if (!mathup) {
return plugin(md, options);
plugin(md, options);
return;
}

let { blockRenderer, inlineRenderer } = options;
Expand All @@ -31,7 +34,7 @@ export default function markdownItMath(md, { mathupOptions, ...options } = {}) {
mathup(src, { ...mathupOptions, display: "block" }).toString();
}

return plugin(md, {
plugin(md, {
...options,
inlineRenderer,
blockRenderer,
Expand Down
Loading