This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧪 TEST: add fixtures for directives and roles
Unsure about how best to have admonitions on a single line. See: executablebooks/MyST-Parser#154
- Loading branch information
Showing
9 changed files
with
231 additions
and
14 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,41 @@ | ||
Admonition: | ||
. | ||
```{admonition} This is a title | ||
An example of an admonition with a _title_. | ||
``` | ||
. | ||
<aside class="callout note"><header>This is a title</header> | ||
<p>An example of an admonition with a <em>title</em>.</p> | ||
</aside> | ||
. | ||
|
||
Note: | ||
. | ||
```{note} | ||
An example of an admonition with a _title_. | ||
``` | ||
. | ||
<aside class="callout note"><header>Note</header> | ||
<p>An example of an admonition with a <em>title</em>.</p> | ||
</aside> | ||
. | ||
|
||
Note on split lines: | ||
. | ||
```{note} An example | ||
of an admonition on two lines. | ||
``` | ||
. | ||
<aside class="callout note"><header>Note</header> | ||
<p>An example of an admonition on two lines.</p> | ||
</aside> | ||
. | ||
|
||
[FIX] Note on a single line (see https://github.com/executablebooks/MyST-Parser/issues/154): | ||
. | ||
```{note} An example of an admonition on a single line. | ||
``` | ||
. | ||
<aside class="callout note"><header>Note</header> | ||
</aside> | ||
. |
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,74 @@ | ||
Basic: | ||
. | ||
{abc}`xyz` | ||
. | ||
<p><code class="myst-role">{abc}[xyz]</code></p> | ||
. | ||
|
||
Surrounding Text: | ||
. | ||
a {abc}`xyz` b | ||
. | ||
<p>a <code class="myst-role">{abc}[xyz]</code> b</p> | ||
. | ||
|
||
In Code: | ||
. | ||
`` {abc}`xyz` `` | ||
. | ||
<p><code>{abc}`xyz`</code></p> | ||
. | ||
|
||
|
||
Surrounding Code: | ||
. | ||
`a` {abc}`xyz` `b` | ||
. | ||
<p><code>a</code> <code class="myst-role">{abc}[xyz]</code> <code>b</code></p> | ||
. | ||
|
||
In list: | ||
. | ||
- {abc}`xyz` | ||
. | ||
<ul> | ||
<li><code class="myst-role">{abc}[xyz]</code></li> | ||
</ul> | ||
. | ||
|
||
In Quote: | ||
. | ||
> {abc}`xyz` b | ||
. | ||
<blockquote> | ||
<p><code class="myst-role">{abc}[xyz]</code> b</p> | ||
</blockquote> | ||
. | ||
|
||
Multiple ticks: | ||
. | ||
{abc}``xyz`` | ||
. | ||
<p><code class="myst-role">{abc}[xyz]</code></p> | ||
. | ||
|
||
Unbalanced ticks: | ||
. | ||
{abc}``xyz` | ||
. | ||
<p>{abc}``xyz`</p> | ||
. | ||
|
||
Space in name: | ||
. | ||
{ab c}`xyz` | ||
. | ||
<p>{ab c}<code>xyz</code></p> | ||
. | ||
|
||
Escaped: | ||
. | ||
\{abc}`xyz` | ||
. | ||
<p>{abc}<code>xyz</code></p> | ||
. |
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,34 @@ | ||
Subscript: | ||
. | ||
H{sub}`2`O | ||
. | ||
<p>H<sub>2</sub>O</p> | ||
. | ||
|
||
Superscript: | ||
. | ||
4{sup}`th` of July | ||
. | ||
<p>4<sup>th</sup> of July</p> | ||
. | ||
|
||
Abbr with title: | ||
. | ||
{abbr}`CSS (Cascading Style Sheets)` | ||
. | ||
<p><abbr title="Cascading Style Sheets">CSS</abbr></p> | ||
. | ||
|
||
Abbr without title: | ||
. | ||
{abbr}`CSS` | ||
. | ||
<p><abbr>CSS</abbr></p> | ||
. | ||
|
||
Abbr with poor brackets: | ||
. | ||
{abbr}`CSS (Cascading) Style( Sheets)` | ||
. | ||
<p><abbr title="Sheets">CSS (Cascading) Style</abbr></p> | ||
. |
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
File renamed without changes.
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,16 @@ | ||
import fs from 'fs'; | ||
import MarkdownIt from 'markdown-it'; | ||
import { myst_role_plugin } from '../myst_roles'; | ||
import { myst_directives_plugin } from '../myst_directives'; | ||
|
||
export function getFixtures(name: string) { | ||
const fixtures = fs.readFileSync(`fixtures/${name}.md`).toString(); | ||
return fixtures.split('\n.\n\n').map((s) => s.split('\n.\n')); | ||
} | ||
|
||
export function getTokenizer() { | ||
const tokenizer = MarkdownIt('commonmark', { html: false }); | ||
tokenizer.use(myst_role_plugin); | ||
tokenizer.use(myst_directives_plugin); | ||
return tokenizer; | ||
} |
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,15 @@ | ||
import { getFixtures, getTokenizer } from './build'; | ||
|
||
const tokenizer = getTokenizer(); | ||
|
||
describe('Roles', () => { | ||
getFixtures('roles.generic').forEach(([name, md, html]) => { | ||
it(name, () => expect(tokenizer.render(md)).toEqual(`${html}\n`)); | ||
}); | ||
getFixtures('roles.known').forEach(([name, md, html]) => { | ||
it(name, () => expect(tokenizer.render(md)).toEqual(`${html}\n`)); | ||
}); | ||
getFixtures('directives.known').forEach(([name, md, html]) => { | ||
it(name, () => expect(tokenizer.render(md)).toEqual(`${html}\n`)); | ||
}); | ||
}); |