mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-24 23:15:14 +00:00
add bold and strikethrough tag (#76)
This commit is contained in:
parent
e6af8bc92a
commit
3857b03faf
2 changed files with 56 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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~~';
|
||||
|
|
Loading…
Reference in a new issue