2023-11-10 22:49:27 -07:00
|
|
|
import { Lexer } from '../../lib/marked.esm.js';
|
|
|
|
import { describe, it } from 'node:test';
|
|
|
|
import assert from 'node:assert';
|
2020-04-02 00:22:40 -05:00
|
|
|
|
2023-11-10 22:49:27 -07:00
|
|
|
function expectTokens({ md, options, tokens = [], links = {}, log = false }) {
|
|
|
|
const lexer = new Lexer(options);
|
2020-04-02 00:22:40 -05:00
|
|
|
const actual = lexer.lex(md);
|
|
|
|
const expected = tokens;
|
|
|
|
expected.links = links;
|
2023-11-10 22:49:27 -07:00
|
|
|
if (log) {
|
|
|
|
console.log(JSON.stringify(
|
|
|
|
actual,
|
|
|
|
(k, v) => v === undefined ? null : v,
|
2024-07-14 18:54:46 -06:00
|
|
|
2,
|
2023-11-10 22:49:27 -07:00
|
|
|
));
|
|
|
|
}
|
|
|
|
assert.deepEqual(actual, expected);
|
2020-04-02 00:22:40 -05:00
|
|
|
}
|
|
|
|
|
2023-11-10 22:49:27 -07:00
|
|
|
function expectInlineTokens({ md, options, tokens, links = {} }) {
|
|
|
|
const lexer = new Lexer(options);
|
2020-04-02 00:22:40 -05:00
|
|
|
lexer.tokens.links = links;
|
|
|
|
const outTokens = [];
|
2020-04-06 23:25:33 -05:00
|
|
|
lexer.inlineTokens(md, outTokens);
|
2023-11-10 22:49:27 -07:00
|
|
|
assert.deepEqual(outTokens, tokens);
|
2020-04-02 00:22:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
describe('Lexer', () => {
|
|
|
|
describe('paragraph', () => {
|
|
|
|
it('space between paragraphs', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: 'paragraph 1\n\nparagraph 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'paragraph',
|
|
|
|
raw: 'paragraph 1',
|
|
|
|
text: 'paragraph 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'paragraph 1', text: 'paragraph 1', escaped: false }],
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
{ type: 'space', raw: '\n\n' },
|
|
|
|
{
|
|
|
|
type: 'paragraph',
|
|
|
|
raw: 'paragraph 2',
|
|
|
|
text: 'paragraph 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'paragraph 2', text: 'paragraph 2', escaped: false }],
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('code', () => {
|
|
|
|
it('indented code', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: ' code',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'code', raw: ' code', text: 'code', codeBlockStyle: 'indented' },
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('fenced code', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '```\ncode\n```',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'code', raw: '```\ncode\n```', text: 'code', lang: '' },
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('fenced code lang', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '```text\ncode\n```',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'code', raw: '```text\ncode\n```', text: 'code', lang: 'text' },
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('headings', () => {
|
|
|
|
it('depth', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
# heading 1
|
|
|
|
|
|
|
|
## heading 2
|
|
|
|
|
|
|
|
### heading 3
|
|
|
|
|
|
|
|
#### heading 4
|
|
|
|
|
|
|
|
##### heading 5
|
|
|
|
|
|
|
|
###### heading 6
|
|
|
|
|
|
|
|
lheading 1
|
|
|
|
==========
|
|
|
|
|
|
|
|
lheading 2
|
|
|
|
----------
|
|
|
|
`,
|
|
|
|
tokens: [
|
2022-01-06 09:31:58 -06:00
|
|
|
{
|
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2022-01-06 09:31:58 -06:00
|
|
|
},
|
2020-04-02 00:22:40 -05:00
|
|
|
{
|
|
|
|
type: 'heading',
|
|
|
|
raw: '# heading 1\n\n',
|
|
|
|
depth: 1,
|
|
|
|
text: 'heading 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'heading 1', text: 'heading 1', escaped: false }],
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'heading',
|
|
|
|
raw: '## heading 2\n\n',
|
|
|
|
depth: 2,
|
|
|
|
text: 'heading 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'heading 2', text: 'heading 2', escaped: false }],
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'heading',
|
|
|
|
raw: '### heading 3\n\n',
|
|
|
|
depth: 3,
|
|
|
|
text: 'heading 3',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'heading 3', text: 'heading 3', escaped: false }],
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'heading',
|
|
|
|
raw: '#### heading 4\n\n',
|
|
|
|
depth: 4,
|
|
|
|
text: 'heading 4',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'heading 4', text: 'heading 4', escaped: false }],
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'heading',
|
|
|
|
raw: '##### heading 5\n\n',
|
|
|
|
depth: 5,
|
|
|
|
text: 'heading 5',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'heading 5', text: 'heading 5', escaped: false }],
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'heading',
|
|
|
|
raw: '###### heading 6\n\n',
|
|
|
|
depth: 6,
|
|
|
|
text: 'heading 6',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'heading 6', text: 'heading 6', escaped: false }],
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'heading',
|
|
|
|
raw: 'lheading 1\n==========\n\n',
|
|
|
|
depth: 1,
|
|
|
|
text: 'lheading 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'lheading 1', text: 'lheading 1', escaped: false }],
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'heading',
|
|
|
|
raw: 'lheading 2\n----------\n',
|
|
|
|
depth: 2,
|
|
|
|
text: 'lheading 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'lheading 2', text: 'lheading 2', escaped: false }],
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not be heading if depth > 6', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '####### heading 7',
|
|
|
|
tokens: [{
|
|
|
|
type: 'paragraph',
|
|
|
|
raw: '####### heading 7',
|
|
|
|
text: '####### heading 7',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '####### heading 7', text: '####### heading 7', escaped: false }],
|
2024-07-14 18:54:46 -06:00
|
|
|
}],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('table', () => {
|
|
|
|
it('pipe table', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
| a | b |
|
|
|
|
|---|---|
|
|
|
|
| 1 | 2 |
|
|
|
|
`,
|
|
|
|
tokens: [{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2022-01-06 09:31:58 -06:00
|
|
|
}, {
|
2020-04-02 00:22:40 -05:00
|
|
|
type: 'table',
|
|
|
|
align: [null, null],
|
|
|
|
raw: '| a | b |\n|---|---|\n| 1 | 2 |\n',
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
header: [
|
|
|
|
{
|
|
|
|
text: 'a',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'a', text: 'a', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'b',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'b', text: 'b', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
|
|
|
},
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
],
|
|
|
|
rows: [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
text: '1',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '1', text: '1', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '2',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '2', text: '2', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
}],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-11-25 08:10:22 +08:00
|
|
|
it('table after para', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
paragraph 1
|
|
|
|
| a | b |
|
|
|
|
|---|---|
|
|
|
|
| 1 | 2 |
|
|
|
|
`,
|
2022-01-06 09:31:58 -06:00
|
|
|
tokens: [{
|
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2022-01-06 09:31:58 -06:00
|
|
|
}, {
|
|
|
|
type: 'paragraph',
|
|
|
|
raw: 'paragraph 1\n',
|
|
|
|
text: 'paragraph 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'paragraph 1', text: 'paragraph 1', escaped: false }],
|
2022-01-06 09:31:58 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'table',
|
|
|
|
align: [null, null],
|
|
|
|
raw: '| a | b |\n|---|---|\n| 1 | 2 |\n',
|
|
|
|
header: [
|
|
|
|
{
|
|
|
|
text: 'a',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'a', text: 'a', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
2022-01-06 09:31:58 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'b',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'b', text: 'b', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
|
|
|
},
|
2022-01-06 09:31:58 -06:00
|
|
|
],
|
|
|
|
rows: [
|
|
|
|
[
|
2021-11-25 08:10:22 +08:00
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
text: '1',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '1', text: '1', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
2021-11-25 08:10:22 +08:00
|
|
|
},
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
text: '2',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '2', text: '2', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2021-11-25 08:10:22 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-02 00:22:40 -05:00
|
|
|
it('align table', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
| a | b | c |
|
|
|
|
|:--|:-:|--:|
|
|
|
|
| 1 | 2 | 3 |
|
|
|
|
`,
|
|
|
|
tokens: [{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2022-01-06 09:31:58 -06:00
|
|
|
}, {
|
2020-04-02 00:22:40 -05:00
|
|
|
type: 'table',
|
|
|
|
align: ['left', 'center', 'right'],
|
|
|
|
raw: '| a | b | c |\n|:--|:-:|--:|\n| 1 | 2 | 3 |\n',
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
header: [
|
|
|
|
{
|
|
|
|
text: 'a',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'a', text: 'a', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: 'left',
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'b',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'b', text: 'b', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: 'center',
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'c',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'c', text: 'c', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: 'right',
|
|
|
|
},
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
],
|
|
|
|
rows: [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
text: '1',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '1', text: '1', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: 'left',
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '2',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '2', text: '2', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: 'center',
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '3',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '3', text: '3', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: 'right',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
}],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('no pipe table', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
a | b
|
|
|
|
--|--
|
|
|
|
1 | 2
|
|
|
|
`,
|
2022-01-06 09:31:58 -06:00
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2022-01-06 09:31:58 -06:00
|
|
|
}, {
|
|
|
|
type: 'table',
|
|
|
|
align: [null, null],
|
|
|
|
raw: 'a | b\n--|--\n1 | 2\n',
|
|
|
|
header: [
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
text: 'a',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'a', text: 'a', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
fix: Refactor table tokens (#2166)
BREAKING CHANGE:
- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.
v2:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": ["a", "b"],
"cells": [["1", "2"]],
"tokens": {
"header": [
[{ "type": "text", "raw": "a", "text": "a" }],
[{ "type": "text", "raw": "b", "text": "b" }]
],
"cells": [[
[{ "type": "text", "raw": "1", "text": "1" }],
[{ "type": "text", "raw": "2", "text": "2" }]
]]
}
}
```
v3:
```json
{
"type": "table",
"align": [null, null],
"raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
"header": [
{
"text": "a",
"tokens": [{ "type": "text", "raw": "a", "text": "a" }]
},
{
"text": "b",
"tokens": [{ "type": "text", "raw": "b", "text": "b" }]
}
],
"rows": [
{
"text": "1",
"tokens": [{ "type": "text", "raw": "1", "text": "1" }]
},
{
"text": "2",
"tokens": [{ "type": "text", "raw": "2", "text": "2" }]
}
]
}
```
2021-08-15 23:02:39 -04:00
|
|
|
},
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
text: 'b',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'b', text: 'b', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
|
|
|
},
|
2022-01-06 09:31:58 -06:00
|
|
|
],
|
|
|
|
rows: [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
text: '1',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '1', text: '1', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
2022-01-06 09:31:58 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '2',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: '2', text: '2', escaped: false }],
|
2024-06-12 01:00:22 -05:00
|
|
|
header: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
align: null,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
}],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('hr', () => {
|
|
|
|
it('hr', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '---',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'hr', raw: '---' },
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('blockquote', () => {
|
|
|
|
it('start, inner-tokens, end', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '> blockquote',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'blockquote',
|
|
|
|
raw: '> blockquote',
|
2020-04-14 13:23:41 -05:00
|
|
|
text: 'blockquote',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [{
|
2023-10-13 14:52:19 -05:00
|
|
|
type: 'paragraph',
|
|
|
|
raw: 'blockquote',
|
|
|
|
text: 'blockquote',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{ type: 'text', raw: 'blockquote', text: 'blockquote', escaped: false },
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
],
|
2023-10-13 14:52:19 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('trim newline in text', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '> blockquote\n',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'blockquote',
|
|
|
|
raw: '> blockquote\n',
|
|
|
|
text: 'blockquote',
|
|
|
|
tokens: [{
|
2020-04-02 00:22:40 -05:00
|
|
|
type: 'paragraph',
|
|
|
|
raw: 'blockquote',
|
|
|
|
text: 'blockquote',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{ type: 'text', raw: 'blockquote', text: 'blockquote', escaped: false },
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
2022-12-07 01:45:09 -06:00
|
|
|
|
|
|
|
it('paragraph token in list', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '- > blockquote',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'list',
|
|
|
|
raw: '- > blockquote',
|
|
|
|
ordered: false,
|
|
|
|
start: '',
|
|
|
|
loose: false,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
|
|
|
raw: '- > blockquote',
|
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: '> blockquote',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'blockquote',
|
|
|
|
raw: '> blockquote',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'paragraph',
|
|
|
|
raw: 'blockquote',
|
|
|
|
text: 'blockquote',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{ type: 'text', raw: 'blockquote', text: 'blockquote', escaped: false },
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
2022-12-07 01:45:09 -06:00
|
|
|
],
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'blockquote',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2022-12-07 01:45:09 -06:00
|
|
|
});
|
|
|
|
});
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('list', () => {
|
|
|
|
it('unordered', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
- item 1
|
|
|
|
- item 2
|
|
|
|
`,
|
|
|
|
tokens: [
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2022-01-06 09:31:58 -06:00
|
|
|
}, {
|
2020-04-02 00:22:40 -05:00
|
|
|
type: 'list',
|
2022-01-06 09:31:58 -06:00
|
|
|
raw: '- item 1\n- item 2\n',
|
2020-04-02 00:22:40 -05:00
|
|
|
ordered: false,
|
|
|
|
start: '',
|
|
|
|
loose: false,
|
|
|
|
items: [
|
|
|
|
{
|
2020-05-04 13:29:28 -05:00
|
|
|
type: 'list_item',
|
2021-02-26 23:51:21 -06:00
|
|
|
raw: '- item 1\n',
|
2020-04-02 00:22:40 -05:00
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
2020-04-14 13:23:41 -05:00
|
|
|
text: 'item 1',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
|
|
|
text: 'item 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'item 1', text: 'item 1', escaped: false }],
|
2024-07-14 18:54:46 -06:00
|
|
|
}],
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
{
|
2020-05-04 13:29:28 -05:00
|
|
|
type: 'list_item',
|
2021-08-09 23:41:45 -04:00
|
|
|
raw: '- item 2',
|
2020-04-02 00:22:40 -05:00
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
2021-02-26 23:51:21 -06:00
|
|
|
text: 'item 2',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
|
|
|
text: 'item 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
tokens: [{ type: 'text', raw: 'item 2', text: 'item 2', escaped: false }],
|
2024-07-14 18:54:46 -06:00
|
|
|
}],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ordered', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
1. item 1
|
|
|
|
2. item 2
|
|
|
|
`,
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-02 00:22:40 -05:00
|
|
|
type: 'list',
|
2022-01-06 09:31:58 -06:00
|
|
|
raw: '1. item 1\n2. item 2\n',
|
2020-04-02 00:22:40 -05:00
|
|
|
ordered: true,
|
|
|
|
start: 1,
|
2023-11-10 22:49:27 -07:00
|
|
|
loose: false,
|
2020-04-02 00:22:40 -05:00
|
|
|
items: [
|
2023-11-10 22:49:27 -07:00
|
|
|
{
|
|
|
|
type: 'list_item',
|
|
|
|
raw: '1. item 1\n',
|
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
|
|
|
raw: '2. item 2',
|
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-06-17 18:28:37 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ordered with parenthesis', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
1) item 1
|
|
|
|
2) item 2
|
|
|
|
`,
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
2020-06-17 18:28:37 +02:00
|
|
|
type: 'list',
|
2022-01-06 09:31:58 -06:00
|
|
|
raw: '1) item 1\n2) item 2\n',
|
2020-06-17 18:28:37 +02:00
|
|
|
ordered: true,
|
|
|
|
start: 1,
|
2023-11-10 22:49:27 -07:00
|
|
|
loose: false,
|
2020-06-17 18:28:37 +02:00
|
|
|
items: [
|
2023-11-10 22:49:27 -07:00
|
|
|
{
|
|
|
|
type: 'list_item',
|
|
|
|
raw: '1) item 1\n',
|
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
|
|
|
raw: '2) item 2',
|
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-02-26 23:51:21 -06:00
|
|
|
it('space after list', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
- item 1
|
|
|
|
- item 2
|
|
|
|
|
|
|
|
paragraph
|
|
|
|
`,
|
|
|
|
tokens: [
|
2022-01-06 09:31:58 -06:00
|
|
|
{
|
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2022-01-06 09:31:58 -06:00
|
|
|
},
|
2021-02-26 23:51:21 -06:00
|
|
|
{
|
|
|
|
type: 'list',
|
2021-08-09 23:41:45 -04:00
|
|
|
raw: '- item 1\n- item 2',
|
2021-02-26 23:51:21 -06:00
|
|
|
ordered: false,
|
|
|
|
start: '',
|
|
|
|
loose: false,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
|
|
|
raw: '- item 1\n',
|
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 1',
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2021-02-26 23:51:21 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
2021-08-09 23:41:45 -04:00
|
|
|
raw: '- item 2',
|
2021-02-26 23:51:21 -06:00
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 2',
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2021-02-26 23:51:21 -06:00
|
|
|
},
|
2023-11-10 22:49:27 -07:00
|
|
|
{
|
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
2021-02-26 23:51:21 -06:00
|
|
|
{
|
|
|
|
type: 'paragraph',
|
2022-01-06 09:31:58 -06:00
|
|
|
raw: 'paragraph\n',
|
2021-02-26 23:51:21 -06:00
|
|
|
text: 'paragraph',
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'paragraph',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'paragraph',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2021-02-26 23:51:21 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-02 00:22:40 -05:00
|
|
|
it('start', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
2. item 1
|
|
|
|
3. item 2
|
|
|
|
`,
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-02 00:22:40 -05:00
|
|
|
type: 'list',
|
2022-01-06 09:31:58 -06:00
|
|
|
raw: '2. item 1\n3. item 2\n',
|
2020-04-02 00:22:40 -05:00
|
|
|
ordered: true,
|
|
|
|
start: 2,
|
2023-11-10 22:49:27 -07:00
|
|
|
loose: false,
|
2020-04-02 00:22:40 -05:00
|
|
|
items: [
|
2023-11-10 22:49:27 -07:00
|
|
|
{
|
|
|
|
type: 'list_item',
|
|
|
|
raw: '2. item 1\n',
|
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
|
|
|
raw: '3. item 2',
|
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('loose', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
- item 1
|
|
|
|
|
|
|
|
- item 2
|
|
|
|
`,
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-02 00:22:40 -05:00
|
|
|
type: 'list',
|
2022-01-06 09:31:58 -06:00
|
|
|
raw: '- item 1\n\n- item 2\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
ordered: false,
|
|
|
|
start: '',
|
2021-02-26 23:51:21 -06:00
|
|
|
loose: true,
|
|
|
|
items: [
|
2023-11-10 22:49:27 -07:00
|
|
|
{
|
|
|
|
type: 'list_item',
|
2022-12-07 01:44:35 -06:00
|
|
|
raw: '- item 1\n\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: true,
|
|
|
|
text: 'item 1\n',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1\n',
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
2022-12-07 01:44:35 -06:00
|
|
|
raw: '- item 2',
|
2023-11-10 22:49:27 -07:00
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: true,
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2022-12-07 01:44:35 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('end loose', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
- item 1
|
|
|
|
- item 2
|
|
|
|
|
|
|
|
item 2a
|
|
|
|
- item 3
|
|
|
|
`,
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
2022-12-07 01:44:35 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
2022-12-07 01:44:35 -06:00
|
|
|
type: 'list',
|
|
|
|
raw: '- item 1\n- item 2\n\n item 2a\n- item 3\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
ordered: false,
|
|
|
|
start: '',
|
2022-12-07 01:44:35 -06:00
|
|
|
loose: true,
|
|
|
|
items: [
|
2023-11-10 22:49:27 -07:00
|
|
|
{
|
|
|
|
type: 'list_item',
|
2022-12-07 01:44:35 -06:00
|
|
|
raw: '- item 1\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: true,
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
2022-12-07 01:44:35 -06:00
|
|
|
raw: '- item 2\n\n item 2a\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: true,
|
|
|
|
text: 'item 2\n\nitem 2a',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2a',
|
|
|
|
text: 'item 2a',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2a',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 2a',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
2022-12-07 01:44:35 -06:00
|
|
|
raw: '- item 3',
|
2023-11-10 22:49:27 -07:00
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: true,
|
|
|
|
text: 'item 3',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 3',
|
|
|
|
text: 'item 3',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 3',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 3',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-01-06 09:31:58 -06:00
|
|
|
it('not loose with spaces', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
- item 1
|
|
|
|
- item 2
|
|
|
|
`,
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'list',
|
|
|
|
raw: '- item 1\n - item 2\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
ordered: false,
|
|
|
|
start: '',
|
2022-01-06 09:31:58 -06:00
|
|
|
loose: false,
|
|
|
|
items: [
|
2023-11-10 22:49:27 -07:00
|
|
|
{
|
|
|
|
type: 'list_item',
|
2022-01-06 09:31:58 -06:00
|
|
|
raw: '- item 1\n - item 2',
|
2023-11-10 22:49:27 -07:00
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
2022-12-07 01:44:35 -06:00
|
|
|
loose: false,
|
2023-11-10 22:49:27 -07:00
|
|
|
text: 'item 1\n- item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1\n',
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'list',
|
2023-11-10 22:49:27 -07:00
|
|
|
raw: '- item 2',
|
|
|
|
ordered: false,
|
|
|
|
start: '',
|
|
|
|
loose: false,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
|
|
|
raw: '- item 2',
|
|
|
|
task: false,
|
|
|
|
checked: undefined,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2022-01-06 09:31:58 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-02 00:22:40 -05:00
|
|
|
it('task', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: `
|
|
|
|
- [ ] item 1
|
|
|
|
- [x] item 2
|
|
|
|
`,
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
2022-01-06 09:31:58 -06:00
|
|
|
type: 'space',
|
2024-07-14 18:54:46 -06:00
|
|
|
raw: '\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-02 00:22:40 -05:00
|
|
|
type: 'list',
|
2022-01-06 09:31:58 -06:00
|
|
|
raw: '- [ ] item 1\n- [x] item 2\n',
|
2023-11-10 22:49:27 -07:00
|
|
|
ordered: false,
|
|
|
|
start: '',
|
|
|
|
loose: false,
|
2020-04-02 00:22:40 -05:00
|
|
|
items: [
|
2023-11-10 22:49:27 -07:00
|
|
|
{
|
|
|
|
type: 'list_item',
|
2021-02-26 23:51:21 -06:00
|
|
|
raw: '- [ ] item 1\n',
|
2020-04-02 00:22:40 -05:00
|
|
|
task: true,
|
2023-11-10 22:49:27 -07:00
|
|
|
checked: false,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
|
|
|
text: 'item 1',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 1',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 1',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'list_item',
|
2021-08-09 23:41:45 -04:00
|
|
|
raw: '- [x] item 2',
|
2020-04-02 00:22:40 -05:00
|
|
|
task: true,
|
2023-11-10 22:49:27 -07:00
|
|
|
checked: true,
|
|
|
|
loose: false,
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
|
|
|
text: 'item 2',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'item 2',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'item 2',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('html', () => {
|
|
|
|
it('div', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '<div>html</div>',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'html',
|
|
|
|
raw: '<div>html</div>',
|
|
|
|
pre: false,
|
2023-05-01 23:31:40 -05:00
|
|
|
block: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
text: '<div>html</div>',
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('pre', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '<pre>html</pre>',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'html',
|
|
|
|
raw: '<pre>html</pre>',
|
|
|
|
pre: true,
|
2023-05-01 23:31:40 -05:00
|
|
|
block: true,
|
2024-07-14 18:54:46 -06:00
|
|
|
text: '<pre>html</pre>',
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('def', () => {
|
|
|
|
it('link', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '[link]: https://example.com',
|
|
|
|
links: {
|
2024-07-14 18:54:46 -06:00
|
|
|
link: { href: 'https://example.com', title: undefined },
|
|
|
|
},
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('title', () => {
|
|
|
|
expectTokens({
|
|
|
|
md: '[link]: https://example.com "title"',
|
|
|
|
links: {
|
2024-07-14 18:54:46 -06:00
|
|
|
link: { href: 'https://example.com', title: 'title' },
|
|
|
|
},
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('inline', () => {
|
2020-04-06 23:25:33 -05:00
|
|
|
describe('inlineTokens', () => {
|
2020-04-02 00:22:40 -05:00
|
|
|
it('escape', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '\\>',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{ type: 'escape', raw: '\\>', text: '>' },
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-11-01 22:03:58 -04:00
|
|
|
it('escaped punctuation inside emphasis', () => {
|
|
|
|
expectInlineTokens({
|
|
|
|
md: '**strong text\\[**\\]',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'strong',
|
|
|
|
raw: '**strong text\\[**',
|
|
|
|
text: 'strong text\\[',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{ type: 'text', raw: 'strong text', text: 'strong text', escaped: false },
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'escape', raw: '\\[', text: '[' },
|
|
|
|
],
|
2022-11-01 22:03:58 -04:00
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'escape', raw: '\\]', text: ']' },
|
|
|
|
],
|
2022-11-01 22:03:58 -04:00
|
|
|
});
|
|
|
|
expectInlineTokens({
|
|
|
|
md: '_em\\<pha\\>sis_',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'em',
|
|
|
|
raw: '_em\\<pha\\>sis_',
|
|
|
|
text: 'em\\<pha\\>sis',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{ type: 'text', raw: 'em', text: 'em', escaped: false },
|
|
|
|
{ type: 'escape', raw: '\\<', text: '<' },
|
|
|
|
{ type: 'text', raw: 'pha', text: 'pha', escaped: false },
|
|
|
|
{ type: 'escape', raw: '\\>', text: '>' },
|
|
|
|
{ type: 'text', raw: 'sis', text: 'sis', escaped: false },
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2022-11-01 22:03:58 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-02 00:22:40 -05:00
|
|
|
it('html', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '<div>html</div>',
|
|
|
|
tokens: [
|
2023-05-01 23:31:40 -05:00
|
|
|
{ type: 'html', raw: '<div>', inLink: false, inRawBlock: false, block: false, text: '<div>' },
|
2024-11-08 19:38:08 -07:00
|
|
|
{ type: 'text', raw: 'html', text: 'html', escaped: false },
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'html', raw: '</div>', inLink: false, inRawBlock: false, block: false, text: '</div>' },
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('link', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '[link](https://example.com)',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'link',
|
|
|
|
raw: '[link](https://example.com)',
|
|
|
|
href: 'https://example.com',
|
|
|
|
title: null,
|
2020-04-14 13:23:41 -05:00
|
|
|
text: 'link',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'link',
|
|
|
|
text: 'link',
|
|
|
|
escaped: false,
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('link title', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '[link](https://example.com "title")',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'link',
|
|
|
|
raw: '[link](https://example.com "title")',
|
|
|
|
href: 'https://example.com',
|
|
|
|
title: 'title',
|
2020-04-14 13:23:41 -05:00
|
|
|
text: 'link',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'link',
|
|
|
|
text: 'link',
|
|
|
|
escaped: false,
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('image', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'image',
|
|
|
|
raw: '',
|
|
|
|
text: 'image',
|
|
|
|
href: 'https://example.com/image.png',
|
2024-07-14 18:54:46 -06:00
|
|
|
title: null,
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('image title', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'image',
|
|
|
|
raw: '',
|
|
|
|
text: 'image',
|
|
|
|
href: 'https://example.com/image.png',
|
2024-07-14 18:54:46 -06:00
|
|
|
title: 'title',
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('reflink', () => {
|
|
|
|
it('reflink', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '[link][]',
|
|
|
|
links: {
|
2024-07-14 18:54:46 -06:00
|
|
|
link: { href: 'https://example.com', title: 'title' },
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'link',
|
|
|
|
raw: '[link][]',
|
|
|
|
href: 'https://example.com',
|
|
|
|
title: 'title',
|
2020-04-14 13:23:41 -05:00
|
|
|
text: 'link',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'link',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'link',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
}],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('nolink', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '[link]',
|
|
|
|
links: {
|
2024-07-14 18:54:46 -06:00
|
|
|
link: { href: 'https://example.com', title: 'title' },
|
2020-04-02 00:22:40 -05:00
|
|
|
},
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'link',
|
|
|
|
raw: '[link]',
|
|
|
|
href: 'https://example.com',
|
|
|
|
title: 'title',
|
2020-04-14 13:23:41 -05:00
|
|
|
text: 'link',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'link',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'link',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
}],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('no def', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '[link]',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: '[link]',
|
|
|
|
text: '[link]',
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('strong', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '**strong**',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'strong',
|
|
|
|
raw: '**strong**',
|
2020-04-14 13:23:41 -05:00
|
|
|
text: 'strong',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'strong',
|
|
|
|
text: 'strong',
|
|
|
|
escaped: false,
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('em', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '*em*',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'em',
|
|
|
|
raw: '*em*',
|
2020-04-14 13:23:41 -05:00
|
|
|
text: 'em',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'em',
|
|
|
|
text: 'em',
|
|
|
|
escaped: false,
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-24 00:39:47 -05:00
|
|
|
describe('codespan', () => {
|
|
|
|
it('code', () => {
|
|
|
|
expectInlineTokens({
|
|
|
|
md: '`code`',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '`code`', text: 'code' },
|
|
|
|
],
|
2020-04-24 00:39:47 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-24 01:00:27 -05:00
|
|
|
it('only spaces not stripped', () => {
|
2020-04-24 00:39:47 -05:00
|
|
|
expectInlineTokens({
|
|
|
|
md: '` `',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '` `', text: ' ' },
|
|
|
|
],
|
2020-04-24 00:39:47 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-24 01:00:27 -05:00
|
|
|
it('beginning space only not stripped', () => {
|
2020-04-24 00:39:47 -05:00
|
|
|
expectInlineTokens({
|
|
|
|
md: '` a`',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '` a`', text: ' a' },
|
|
|
|
],
|
2020-04-24 00:39:47 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-24 01:00:27 -05:00
|
|
|
it('end space only not stripped', () => {
|
2020-04-24 00:39:47 -05:00
|
|
|
expectInlineTokens({
|
|
|
|
md: '`a `',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '`a `', text: 'a ' },
|
|
|
|
],
|
2020-04-24 00:39:47 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-24 01:00:27 -05:00
|
|
|
it('begin and end spaces are stripped', () => {
|
2020-04-24 00:39:47 -05:00
|
|
|
expectInlineTokens({
|
|
|
|
md: '` a `',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '` a `', text: 'a' },
|
|
|
|
],
|
2020-04-24 00:39:47 -05:00
|
|
|
});
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
2020-04-24 00:44:02 -05:00
|
|
|
|
2020-04-24 01:00:27 -05:00
|
|
|
it('begin and end newlines are stripped', () => {
|
|
|
|
expectInlineTokens({
|
|
|
|
md: '`\na\n`',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '`\na\n`', text: 'a' },
|
|
|
|
],
|
2020-04-24 01:00:27 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('begin and end tabs are not stripped', () => {
|
|
|
|
expectInlineTokens({
|
|
|
|
md: '`\ta\t`',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '`\ta\t`', text: '\ta\t' },
|
|
|
|
],
|
2020-04-24 01:00:27 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('begin and end newlines', () => {
|
|
|
|
expectInlineTokens({
|
|
|
|
md: '`\na\n`',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '`\na\n`', text: 'a' },
|
|
|
|
],
|
2020-04-24 01:00:27 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('begin and end multiple spaces only one stripped', () => {
|
2020-04-24 00:44:02 -05:00
|
|
|
expectInlineTokens({
|
|
|
|
md: '` a `',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '` a `', text: ' a ' },
|
|
|
|
],
|
2020-04-24 00:44:02 -05:00
|
|
|
});
|
|
|
|
});
|
2020-04-24 00:51:16 -05:00
|
|
|
|
|
|
|
it('newline to space', () => {
|
|
|
|
expectInlineTokens({
|
|
|
|
md: '`a\nb`',
|
|
|
|
tokens: [
|
2024-07-14 18:54:46 -06:00
|
|
|
{ type: 'codespan', raw: '`a\nb`', text: 'a b' },
|
|
|
|
],
|
2020-04-24 00:51:16 -05:00
|
|
|
});
|
|
|
|
});
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('br', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: 'a\nb',
|
|
|
|
options: { gfm: true, breaks: true },
|
2023-11-10 22:49:27 -07:00
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
raw: 'a',
|
|
|
|
text: 'a',
|
2024-07-14 18:54:46 -06:00
|
|
|
type: 'text',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
raw: '\n',
|
2024-07-14 18:54:46 -06:00
|
|
|
type: 'br',
|
2023-11-10 22:49:27 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
raw: 'b',
|
|
|
|
text: 'b',
|
2024-07-14 18:54:46 -06:00
|
|
|
type: 'text',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('del', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '~~del~~',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'del',
|
|
|
|
raw: '~~del~~',
|
2020-04-14 13:23:41 -05:00
|
|
|
text: 'del',
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'del',
|
|
|
|
text: 'del',
|
|
|
|
escaped: false,
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('url', () => {
|
|
|
|
it('autolink', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '<https://example.com>',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'link',
|
|
|
|
raw: '<https://example.com>',
|
|
|
|
text: 'https://example.com',
|
|
|
|
href: 'https://example.com',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'https://example.com',
|
|
|
|
text: 'https://example.com',
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('autolink email', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: '<test@example.com>',
|
2023-09-02 22:02:24 -06:00
|
|
|
options: {},
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'link',
|
|
|
|
raw: '<test@example.com>',
|
|
|
|
text: 'test@example.com',
|
|
|
|
href: 'mailto:test@example.com',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'test@example.com',
|
|
|
|
text: 'test@example.com',
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('url', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: 'https://example.com',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'link',
|
|
|
|
raw: 'https://example.com',
|
|
|
|
text: 'https://example.com',
|
|
|
|
href: 'https://example.com',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'https://example.com',
|
|
|
|
text: 'https://example.com',
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('url email', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: 'test@example.com',
|
2023-09-02 22:02:24 -06:00
|
|
|
options: { gfm: true },
|
2020-04-02 00:22:40 -05:00
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'link',
|
|
|
|
raw: 'test@example.com',
|
|
|
|
text: 'test@example.com',
|
|
|
|
href: 'mailto:test@example.com',
|
|
|
|
tokens: [
|
2024-11-08 19:38:08 -07:00
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'test@example.com',
|
|
|
|
text: 'test@example.com',
|
|
|
|
},
|
2024-07-14 18:54:46 -06:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('text', () => {
|
2020-04-06 22:28:47 -05:00
|
|
|
expectInlineTokens({
|
2020-04-02 00:22:40 -05:00
|
|
|
md: 'text',
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
|
|
|
raw: 'text',
|
2024-07-14 18:54:46 -06:00
|
|
|
text: 'text',
|
2024-11-08 19:38:08 -07:00
|
|
|
escaped: false,
|
2024-07-14 18:54:46 -06:00
|
|
|
},
|
|
|
|
],
|
2020-04-02 00:22:40 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|