This commit is contained in:
parent
c0324c0bc2
commit
cbfa885984
42 changed files with 3701 additions and 547 deletions
19
posthtml-djot/test/expected/basic.html
Normal file
19
posthtml-djot/test/expected/basic.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<h1>Heading 1</h1>
|
||||
|
||||
|
||||
<p>Paragraph with some text</p>
|
||||
|
||||
|
||||
<div>
|
||||
<ul>
|
||||
<li>List item 1</li>
|
||||
<li>List item 2</li>
|
||||
<li>List item 3</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<blockquote>
|
||||
<p>A quote</p>
|
||||
</blockquote>
|
||||
</section>
|
3
posthtml-djot/test/expected/change-tag.html
Normal file
3
posthtml-djot/test/expected/change-tag.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<section>
|
||||
<h1>A markdown heading</h1>
|
||||
</section>
|
5
posthtml-djot/test/expected/code.html
Normal file
5
posthtml-djot/test/expected/code.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<h1>Heading</h1>
|
||||
<pre><code class="language-js">function () {
|
||||
console.log("Hello")
|
||||
}
|
||||
</code></pre>
|
1
posthtml-djot/test/expected/importing-inline.html
Normal file
1
posthtml-djot/test/expected/importing-inline.html
Normal file
|
@ -0,0 +1 @@
|
|||
Hello <em>there</em>
|
2
posthtml-djot/test/expected/importing.html
Normal file
2
posthtml-djot/test/expected/importing.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
<h1>Hello there</h1>
|
||||
<h2>Imported content should be above me</h2>
|
1
posthtml-djot/test/expected/md-options.html
Normal file
1
posthtml-djot/test/expected/md-options.html
Normal file
|
@ -0,0 +1 @@
|
|||
<p><a href="https://example.com">https://example.com</a></p>
|
1
posthtml-djot/test/expected/md-plugin.html
Normal file
1
posthtml-djot/test/expected/md-plugin.html
Normal file
|
@ -0,0 +1 @@
|
|||
<p>You can use emojis 😃</p>
|
17
posthtml-djot/test/fixtures/basic.html
vendored
Executable file
17
posthtml-djot/test/fixtures/basic.html
vendored
Executable file
|
@ -0,0 +1,17 @@
|
|||
<md>
|
||||
# Heading 1
|
||||
</md>
|
||||
|
||||
<markdown>
|
||||
Paragraph with some text
|
||||
</markdown>
|
||||
|
||||
<div md>
|
||||
- List item 1
|
||||
- List item 2
|
||||
- List item 3
|
||||
</div>
|
||||
|
||||
<section markdown>
|
||||
> A quote
|
||||
</section>
|
3
posthtml-djot/test/fixtures/change-tag.html
vendored
Normal file
3
posthtml-djot/test/fixtures/change-tag.html
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
<md tag="section">
|
||||
# A markdown heading
|
||||
</md>
|
9
posthtml-djot/test/fixtures/code.html
vendored
Normal file
9
posthtml-djot/test/fixtures/code.html
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
<md>
|
||||
# Heading
|
||||
|
||||
```js
|
||||
function () {
|
||||
console.log("Hello")
|
||||
}
|
||||
```
|
||||
</md>
|
1
posthtml-djot/test/fixtures/importing-inline.html
vendored
Normal file
1
posthtml-djot/test/fixtures/importing-inline.html
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<md src="test/fixtures/test-inline.md" inline></md>
|
3
posthtml-djot/test/fixtures/importing.html
vendored
Normal file
3
posthtml-djot/test/fixtures/importing.html
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
<md src="test/fixtures/test.md">
|
||||
## Imported content should be above me
|
||||
</md>
|
3
posthtml-djot/test/fixtures/md-options.html
vendored
Normal file
3
posthtml-djot/test/fixtures/md-options.html
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
<md>
|
||||
https://example.com
|
||||
</md>
|
3
posthtml-djot/test/fixtures/md-plugin.html
vendored
Normal file
3
posthtml-djot/test/fixtures/md-plugin.html
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
<md>
|
||||
You can use emojis :)
|
||||
</md>
|
1
posthtml-djot/test/fixtures/test-inline.md
vendored
Normal file
1
posthtml-djot/test/fixtures/test-inline.md
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Hello _there_
|
1
posthtml-djot/test/fixtures/test.md
vendored
Normal file
1
posthtml-djot/test/fixtures/test.md
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
# Hello there
|
59
posthtml-djot/test/test.js
Normal file
59
posthtml-djot/test/test.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
import path from 'node:path'
|
||||
import {readFileSync} from 'node:fs'
|
||||
import {fileURLToPath} from 'node:url'
|
||||
import plugin from '../lib/index.js'
|
||||
import {test, expect} from 'vitest'
|
||||
import posthtml from 'posthtml'
|
||||
import {light as emoji} from 'markdown-it-emoji'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const fixture = file => readFileSync(path.join(__dirname, 'fixtures', `${file}.html`), 'utf8').trim()
|
||||
const expected = file => readFileSync(path.join(__dirname, 'expected', `${file}.html`), 'utf8').trim()
|
||||
|
||||
const clean = html => html.replace(/[^\S\r\n]+$/gm, '').trim()
|
||||
|
||||
const process = (_t, name, options, log = false) => {
|
||||
return posthtml([plugin(options)])
|
||||
.process(fixture(name))
|
||||
.then(result => log ? console.log(result.html) : clean(result.html))
|
||||
.then(html => expect(html).toEqual(expected(name)))
|
||||
}
|
||||
|
||||
test('Basic', t => {
|
||||
return process(t, 'basic')
|
||||
})
|
||||
|
||||
test('Fenced code block', t => {
|
||||
return process(t, 'code')
|
||||
})
|
||||
|
||||
test('Custom tag', t => {
|
||||
return process(t, 'change-tag')
|
||||
})
|
||||
|
||||
test('Render markdown in imported file', t => {
|
||||
return process(t, 'importing')
|
||||
})
|
||||
|
||||
test('Render markdown inline from imported file', t => {
|
||||
return process(t, 'importing-inline')
|
||||
})
|
||||
|
||||
test('Uses markdown-it plugins', t => {
|
||||
return process(t, 'md-plugin', {
|
||||
plugins: [
|
||||
{
|
||||
plugin: emoji
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
test('Uses markdown-it options', t => {
|
||||
return process(t, 'md-options', {
|
||||
markdownit: {
|
||||
linkify: true
|
||||
}
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue