21 lines
829 B
JavaScript
21 lines
829 B
JavaScript
'use strict';
|
||
|
||
const test = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const { markdownToHtml } = require('../src/markdown');
|
||
|
||
test('markdown: bold + link + list', () => {
|
||
const html = markdownToHtml('这里有一些 **戒指**:\n- [Rings](https://www.yehwang.com/jewelry/rings)\n- Plain\n\n谢谢');
|
||
assert.match(html, /<strong>戒指<\/strong>/);
|
||
assert.match(html, /<a href="https:\/\/www\.yehwang\.com\/jewelry\/rings"[^>]*>Rings<\/a>/);
|
||
assert.match(html, /<ul><li>/);
|
||
assert.match(html, /<p>谢谢<\/p>/);
|
||
assert.doesNotMatch(html, /\[Rings\]/);
|
||
});
|
||
|
||
test('markdown: escapes html and autolinks bare urls', () => {
|
||
const html = markdownToHtml('<script>x</script> https://a.test/x');
|
||
assert.match(html, /<script>/);
|
||
assert.match(html, /<a href="https:\/\/a\.test\/x"/);
|
||
});
|