0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00
Files
homebrewery/tests/markdown/marked-extensions.test.js
David Bolack 96d973528c Updated and reworked to handle more definition*
Updated to allow multiple definition terms and definitions per term

<Term>::<definition>
<Term>::<definition1>::<definition2>
::<definition3>

```
**Example** ::
::V3 uses HTML *definition lists* to create "lists" with hanging indents.
::Three
I'm a term::Four

**<u>Hello</u>**::I\'m a different
::List
:
```
2023-12-20 22:57:37 -06:00

31 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* eslint-disable max-lines */
const Markdown = require('naturalcrit/markdown.js');
describe('Dictionary Terms', ()=>{
test('Single Definition', function() {
const source = 'My term :: My First Definition\n\n';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><div><dt>My term</dt><dd>My First Definition</dd></div></dl>');
});
test('Two Definitions', function() {
const source = 'My term :: My First Definition :: My Second Definition\n\n';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><div><dt>My term</dt><dd>My First Definition</dd>\n<dd>My Second Definition</dd></div></dl>');
});
test('Three Definitions', function() {
const source = 'My term :: My First Definition :: My Second Definition :: My Third Definition\n\n';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><div><dt>My term</dt><dd>My First Definition</dd>\n<dd>My Second Definition</dd>\n<dd>My Third Definition</dd></div></dl>');
});
test('Multiline Definitions', function() {
const source = '**Example** :: V3 uses HTML *definition lists* to create "lists" with hanging indents.\n::Three\n::Four\n\nHello::I\'m a different\n::List\n\n';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><div><dt><strong>Example</strong></dt><dd>V3 uses HTML <em>definition lists</em> to create “lists” with hanging indents.</dd>\n<dd>Three</dd>\n<dd>Four</dd></div></dl><dl><div><dt>Hello</dt><dd>I\m a different</dd>\n<dd>List</dd></div></dl>');
});
});