mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 09:57:29 -07:00
Resolve #1153
This commit is contained in:
parent
ab1714e464
commit
9220081e12
2 changed files with 15 additions and 1 deletions
|
@ -9,7 +9,7 @@ export type TextElementQuote = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function(text: string) {
|
export default function(text: string) {
|
||||||
const match = text.match(/^"([\s\S]+?)\n"/);
|
const match = text.match(/^"([\s\S]+?)\n"/) || text.match(/^>([\s\S]+?)\n\n/) || text.match(/^\n>([\s\S]+?)\n\n/) || text.match(/^>([\s\S]+?)$/);
|
||||||
if (!match) return null;
|
if (!match) return null;
|
||||||
const quote = match[0];
|
const quote = match[0];
|
||||||
return {
|
return {
|
||||||
|
|
14
test/mfm.ts
14
test/mfm.ts
|
@ -87,6 +87,20 @@ describe('Text', () => {
|
||||||
], tokens2);
|
], tokens2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('quote', () => {
|
||||||
|
const tokens1 = analyze('> foo\nbar\baz');
|
||||||
|
assert.deepEqual([
|
||||||
|
{ type: 'quote', content: '> foo\nbar\baz', quote: 'foo\nbar\baz' }
|
||||||
|
], tokens1);
|
||||||
|
|
||||||
|
const tokens2 = analyze('before\n> foo\nbar\baz\n\nafter');
|
||||||
|
assert.deepEqual([
|
||||||
|
{ type: 'text', content: 'before' },
|
||||||
|
{ type: 'quote', content: '\n> foo\nbar\baz\n\n', quote: 'foo\nbar\baz' },
|
||||||
|
{ type: 'text', content: 'after' }
|
||||||
|
], tokens2);
|
||||||
|
});
|
||||||
|
|
||||||
it('url', () => {
|
it('url', () => {
|
||||||
const tokens = analyze('https://himasaku.net');
|
const tokens = analyze('https://himasaku.net');
|
||||||
assert.deepEqual([{
|
assert.deepEqual([{
|
||||||
|
|
Loading…
Reference in a new issue