Add double underscore syntax for bold markdown (#3733)
* Add double underscore syntax for bold markdown see https://github.com/syuilo/misskey/pull/3732 this allows bold text through either **text** or __text__ * Add tests for underscore bold mfm syntax
This commit is contained in:
parent
8fcf75f77c
commit
53481accf1
2 changed files with 24 additions and 1 deletions
|
@ -154,7 +154,7 @@ const mfm = P.createLanguage({
|
||||||
|
|
||||||
//#region Bold
|
//#region Bold
|
||||||
bold: r =>
|
bold: r =>
|
||||||
P.regexp(/\*\*([\s\S]+?)\*\*/, 1)
|
P.regexp(/(\*\*|__)([\s\S]+?)\1/, 2)
|
||||||
.map(x => createTree('bold', P.alt(
|
.map(x => createTree('bold', P.alt(
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
|
|
23
test/mfm.ts
23
test/mfm.ts
|
@ -177,6 +177,29 @@ describe('MFM', () => {
|
||||||
text('bar'),
|
text('bar'),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('with underscores', () => {
|
||||||
|
const tokens = analyze('__foo__');
|
||||||
|
assert.deepStrictEqual(tokens, [
|
||||||
|
tree('bold', [
|
||||||
|
text('foo')
|
||||||
|
], {}),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('mixed syntax', () => {
|
||||||
|
const tokens = analyze('**foo__');
|
||||||
|
assert.deepStrictEqual(tokens, [
|
||||||
|
text('**foo__'),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('mixed syntax', () => {
|
||||||
|
const tokens = analyze('__foo**');
|
||||||
|
assert.deepStrictEqual(tokens, [
|
||||||
|
text('__foo**'),
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('big', () => {
|
it('big', () => {
|
||||||
|
|
Loading…
Reference in a new issue