-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
2 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 |
---|---|---|
@@ -1,3 +1,16 @@ | ||
# remark-attribute-list | ||
|
||
[![](https://github.com/cm-ayf/remark-attribute-list/actions/workflows/ci.yml/badge.svg)](https://github.com/cm-ayf/remark-attribute-list/actions) | ||
|
||
Remark plugin to parse Attribute List Definitions and Inline Attribute Lists from Kramdown. | ||
|
||
## Install | ||
|
||
This package is ESM only. In Node.js, install with npm: | ||
|
||
```sh | ||
npm install remark-attribute-list | ||
``` | ||
|
||
## Use | ||
|
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,40 @@ | ||
import test from 'node:test'; | ||
import process from 'node:process'; | ||
import assert from 'node:assert'; | ||
import {fileURLToPath} from 'node:url'; | ||
import remarkParse from 'remark-parse'; | ||
import {unified} from 'unified'; | ||
import remarkRehype from 'remark-rehype'; | ||
import rehypeStringify from 'rehype-stringify'; | ||
import {read, write} from 'to-vfile'; | ||
import remarkAttributeList from '../dist/index.js'; | ||
|
||
const processor = unified() | ||
.use(remarkParse) | ||
.use(remarkAttributeList) | ||
.use(remarkRehype) | ||
.use(rehypeStringify); | ||
|
||
await test('integration', async () => { | ||
const inputUrl = new URL('integration/input.md', import.meta.url); | ||
const outputUrl = new URL('integration/output.html', import.meta.url); | ||
|
||
const input = await read(inputUrl); | ||
const actual = await processor.process(input); | ||
/** @type {import("vfile").VFile} */ | ||
let output; | ||
|
||
try { | ||
if ('UPDATE' in process.env) { | ||
throw new Error('Updating…'); | ||
} | ||
|
||
output = await read(outputUrl); | ||
} catch { | ||
output = actual; | ||
output.path = fileURLToPath(outputUrl); | ||
await write(output); | ||
} | ||
|
||
assert.strictEqual(actual.value, output.value.toString()); | ||
}); |
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,6 @@ | ||
# Title | ||
{:#title} | ||
|
||
{:outlink:target="blank" rel="noopener noreferrer"} | ||
|
||
See [GitHub](https://github.com/){:outlink} for more information. |
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,2 @@ | ||
<h1 id="title">Title</h1> | ||
<p>See <a href="https://github.com/" target="blank" rel="noopener noreferrer">GitHub</a> for more information.</p> |