Migrate to djot
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Isaac Mills 2025-07-16 11:45:32 -06:00
parent c0324c0bc2
commit cbfa885984
Signed by: fnmain
GPG key ID: B67D7410F33A0F61
42 changed files with 3701 additions and 547 deletions

View 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>

View file

@ -0,0 +1,3 @@
<section>
<h1>A markdown heading</h1>
</section>

View file

@ -0,0 +1,5 @@
<h1>Heading</h1>
<pre><code class="language-js">function () {
console.log(&quot;Hello&quot;)
}
</code></pre>

View file

@ -0,0 +1 @@
Hello <em>there</em>

View file

@ -0,0 +1,2 @@
<h1>Hello there</h1>
<h2>Imported content should be above me</h2>

View file

@ -0,0 +1 @@
<p><a href="https://example.com">https://example.com</a></p>

View file

@ -0,0 +1 @@
<p>You can use emojis 😃</p>

17
posthtml-djot/test/fixtures/basic.html vendored Executable file
View 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>

View file

@ -0,0 +1,3 @@
<md tag="section">
# A markdown heading
</md>

9
posthtml-djot/test/fixtures/code.html vendored Normal file
View file

@ -0,0 +1,9 @@
<md>
# Heading
```js
function () {
console.log("Hello")
}
```
</md>

View file

@ -0,0 +1 @@
<md src="test/fixtures/test-inline.md" inline></md>

View file

@ -0,0 +1,3 @@
<md src="test/fixtures/test.md">
## Imported content should be above me
</md>

View file

@ -0,0 +1,3 @@
<md>
https://example.com
</md>

View file

@ -0,0 +1,3 @@
<md>
You can use emojis :)
</md>

View file

@ -0,0 +1 @@
Hello _there_

1
posthtml-djot/test/fixtures/test.md vendored Normal file
View file

@ -0,0 +1 @@
# Hello there

View 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
}
})
})