Skip to content

Commit b613cb5

Browse files
committed
remove inline
1 parent 8b2aba2 commit b613cb5

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

demo/default.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,14 @@
5555
if (renderer === "markdown-it") {
5656
return markdownit({ "html": true }).render(markdown);
5757
} else if (renderer === "micromark") {
58+
// See lib/micromark-parse.mjs
59+
const micromarkDirectiveNoInline = {
60+
...micromark.directive()
61+
};
62+
delete micromarkDirectiveNoInline.text;
5863
const parseOptions = {
5964
"extensions": [
60-
micromark.directive(),
65+
micromarkDirectiveNoInline,
6166
micromark.gfmAutolinkLiteral(),
6267
micromark.gfmFootnote(),
6368
micromark.gfmTable(),

lib/micromark-parse.mjs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,28 @@ import { isHtmlFlowComment } from "../helpers/micromark-helpers.cjs";
1313
import { flatTokensSymbol, htmlFlowSymbol, newLineRe } from "../helpers/shared.cjs";
1414

1515
/** @typedef {import("micromark-util-types").Event} Event */
16+
/** @typedef {import("micromark-util-types").Extension} Extension */
1617
/** @typedef {import("micromark-util-types").ParseOptions} MicromarkParseOptions */
1718
/** @typedef {import("micromark-util-types").State} State */
1819
/** @typedef {import("micromark-util-types").Token} Token */
1920
/** @typedef {import("micromark-util-types").Tokenizer} Tokenizer */
2021
/** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
2122
/** @typedef {import("./micromark-types.d.mts")} */
2223

24+
/**
25+
* Gets a modified micromark-extension-directive without support for inline directives.
26+
*
27+
* @see {@link https://github.com/DavidAnson/markdownlint/issues/2080}
28+
* @returns {Extension} Modified implementation.
29+
*/
30+
function directiveNoInline() {
31+
const extension = {
32+
...directive()
33+
};
34+
delete extension.text;
35+
return extension;
36+
}
37+
2338
/**
2439
* Gets the Markdown text for a Micromark token.
2540
*
@@ -51,7 +66,7 @@ export function getEvents(
5166
) {
5267
// Customize extensions list to add useful extensions
5368
const extensions = [
54-
directive(),
69+
directiveNoInline(),
5570
gfmAutolinkLiteral(),
5671
gfmFootnote(),
5772
gfmTable(),

test/markdownlint-test-micromark.mjs.snapshot

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)