mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-14 05:57:32 -07:00
MFM: Improve title syntax
This commit is contained in:
parent
87a3983c29
commit
9887e2e08d
2 changed files with 13 additions and 1 deletions
|
@ -9,7 +9,7 @@ export type TextElementTitle = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function(text: string) {
|
export default function(text: string) {
|
||||||
const match = text.match(/^【(.+?)】\n/);
|
const match = text.match(/^(【|\[)(.+?)(】|])\n/);
|
||||||
if (!match) return null;
|
if (!match) return null;
|
||||||
const title = match[0];
|
const title = match[0];
|
||||||
return {
|
return {
|
||||||
|
|
12
test/mfm.ts
12
test/mfm.ts
|
@ -115,6 +115,18 @@ describe('Text', () => {
|
||||||
{ type: 'search', content: 'a b c SEARCH', query: 'a b c'}
|
{ type: 'search', content: 'a b c SEARCH', query: 'a b c'}
|
||||||
], tokens4);
|
], tokens4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('title', () => {
|
||||||
|
const tokens1 = analyze('【yee】\nhaw');
|
||||||
|
assert.deepEqual(
|
||||||
|
{ type: 'title', content: '【yee】\n', title: 'yee'}
|
||||||
|
, tokens1[0]);
|
||||||
|
|
||||||
|
const tokens2 = analyze('[yee]\nhaw');
|
||||||
|
assert.deepEqual(
|
||||||
|
{ type: 'title', content: '[yee]\n', title: 'yee'}
|
||||||
|
, tokens2[0]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('syntax highlighting', () => {
|
describe('syntax highlighting', () => {
|
||||||
|
|
Loading…
Reference in a new issue