add bold and strikethrough tag (#76)

This commit is contained in:
Johann150 2021-09-29 17:39:14 +02:00 committed by GitHub
parent e6af8bc92a
commit 3857b03faf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 0 deletions

View file

@ -241,6 +241,10 @@ bold
= "**" content:(!"**" i:inline { return i; })+ "**"
{
return BOLD(mergeText(content));
}
/ "<b>" content:(!"</b>" i:inline { return i; })+ "</b>"
{
return BOLD(mergeText(content));
}
/ "__" content:$(!"__" c:([a-z0-9]i / _) { return c; })+ "__"
{
@ -287,6 +291,10 @@ strike
{
return STRIKE(mergeText(content));
}
/ "<s>" content:(!("</s>" / LF) i:inline { return i; })+ "</s>"
{
return STRIKE(mergeText(content));
}
// inline: inlineCode

View file

@ -362,6 +362,44 @@ hoge`;
});
});
describe('bold tag', () => {
it('basic', () => {
const input = '<b>abc</b>';
const output = [
BOLD([
TEXT('abc')
])
];
assert.deepStrictEqual(mfm.parse(input), output);
});
it('inline syntax allowed inside', () => {
const input = '<b>123~~abc~~123</b>';
const output = [
BOLD([
TEXT('123'),
STRIKE([
TEXT('abc')
]),
TEXT('123')
])
];
assert.deepStrictEqual(mfm.parse(input), output);
});
it('line breaks', () => {
const input = '<b>123\n~~abc~~\n123</b>';
const output = [
BOLD([
TEXT('123\n'),
STRIKE([
TEXT('abc')
]),
TEXT('\n123')
])
];
assert.deepStrictEqual(mfm.parse(input), output);
});
});
describe('bold', () => {
it('basic', () => {
const input = '**abc**';
@ -556,6 +594,16 @@ hoge`;
});
});
describe('strike tag', () => {
it('basic', () => {
const input = '<s>foo</s>';
const output = [STRIKE([
TEXT('foo')
])];
assert.deepStrictEqual(mfm.parse(input), output);
});
});
describe('strike', () => {
it('basic', () => {
const input = '~~foo~~';