Skip to content

Commit ea5b165

Browse files
committed
🐛 Use colonFence from myst-extras
1 parent a156577 commit ea5b165

File tree

5 files changed

+28
-144
lines changed

5 files changed

+28
-144
lines changed

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"eslint-plugin-prettier": "^4.0.0",
7777
"jest": "^27.5.1",
7878
"markdown-it": "^12.3.2",
79+
"markdown-it-myst-extras": "^0.2.0",
7980
"npm-run-all": "^4.1.5",
8081
"postcss": "^8.4.6",
8182
"postcss-cli": "^9.1.0",

src/colonFence.ts

Lines changed: 0 additions & 137 deletions
This file was deleted.

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
IDirectiveData
1010
} from "./directives"
1111
import statePlugin from "./state/plugin"
12-
import { colonFencePlugin } from "./colonFence"
1312

1413
export { rolesDefault, rolePlugin, Role }
1514
export { directivesDefault, directivePlugin, Directive, directiveOptions }
@@ -19,13 +18,11 @@ export type { IRoleData, IRoleOptions, IDirectiveData, IDirectiveOptions }
1918
/** Allowed options for docutils plugin */
2019
export interface IOptions extends IDirectiveOptions, IRoleOptions {
2120
// TODO new token render rules
22-
colonFences: boolean
2321
}
2422

2523
/** Default options for docutils plugin */
2624
const OptionDefaults: IOptions = {
2725
parseRoles: true,
28-
colonFences: true,
2926
replaceFences: true,
3027
rolesAfter: "inline",
3128
directivesAfter: "block",
@@ -39,7 +36,6 @@ const OptionDefaults: IOptions = {
3936
export function docutilsPlugin(md: MarkdownIt, options?: IOptions): void {
4037
const fullOptions = { ...OptionDefaults, ...options }
4138

42-
if (fullOptions.colonFences) md.use(colonFencePlugin)
4339
md.use(rolePlugin, fullOptions)
4440
md.use(directivePlugin, fullOptions)
4541
md.use(statePlugin, fullOptions)

tests/colonFences.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
/* eslint-disable jest/valid-title */
22
import MarkdownIt from "markdown-it"
3+
import { colonFencePlugin } from "markdown-it-myst-extras"
34
import docutils_plugin from "../src"
45
import readFixtures from "./readFixtures"
56

7+
// We have to test compatibility with colonFences here!
8+
69
describe("Parses colonFences", () => {
710
test("colon fences parse", () => {
8-
const mdit = MarkdownIt().use(docutils_plugin)
11+
const mdit = MarkdownIt().use(colonFencePlugin).use(docutils_plugin)
912
const parse = mdit.parse(`:::{tip}\nThis is a tip in a fence!\n:::`, {})
1013
expect(parse[0].type).toBe("parsed_directive_open")
1114
})
1215
test("colon fences render", () => {
13-
const mdit = MarkdownIt().use(docutils_plugin)
16+
const mdit = MarkdownIt().use(colonFencePlugin).use(docutils_plugin)
1417
const rendered = mdit.render(`:::{tip}\nfence\n:::`)
1518
expect(rendered.trim()).toEqual(
1619
'<aside class="admonition tip">\n<header class="admonition-title">Tip</header>\n<p>fence</p>\n</aside>'
@@ -20,7 +23,7 @@ describe("Parses colonFences", () => {
2023

2124
describe("Parses fenced directives", () => {
2225
readFixtures("directives.fence").forEach(([name, text, expected]) => {
23-
const mdit = MarkdownIt().use(docutils_plugin)
26+
const mdit = MarkdownIt().use(colonFencePlugin).use(docutils_plugin)
2427
const rendered = mdit.render(text)
2528
it(name, () => expect(rendered.trim()).toEqual((expected || "").trim()))
2629
})

0 commit comments

Comments
 (0)