-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
␡ Enable strikethrough as markdownit extension (#1427)
Co-authored-by: Rowan Cockett <rowanc1@gmail.com>
- Loading branch information
Showing
5 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"myst-parser": patch | ||
--- | ||
|
||
Enable strikethrough as markdownit extension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { visit } from 'unist-util-visit'; | ||
import { mystParse } from '../src'; | ||
import type { GenericParent } from 'myst-common'; | ||
|
||
function stripPositions(tree: GenericParent) { | ||
visit(tree, (node) => { | ||
delete node.position; | ||
}); | ||
return tree; | ||
} | ||
|
||
describe('strikethrough', () => { | ||
it('strikethrough in paragraph', () => { | ||
const content = 'A ~~div~~ paragraph!'; | ||
expect(stripPositions(mystParse(content))).toEqual({ | ||
type: 'root', | ||
children: [ | ||
{ | ||
type: 'paragraph', | ||
children: [{ type: 'text', value: 'A ~~div~~ paragraph!' }], | ||
}, | ||
], | ||
}); | ||
expect(stripPositions(mystParse(content, { extensions: { strikethrough: true } }))).toEqual({ | ||
type: 'root', | ||
children: [ | ||
{ | ||
type: 'paragraph', | ||
children: [ | ||
{ type: 'text', value: 'A ' }, | ||
{ | ||
type: 'delete', | ||
children: [{ type: 'text', value: 'div' }], | ||
}, | ||
{ type: 'text', value: ' paragraph!' }, | ||
], | ||
}, | ||
], | ||
}); | ||
}); | ||
}); |