In HTML to MFM, use angle bracket if needed (#6817)
This commit is contained in:
parent
a8776002f3
commit
27d0ac3d75
3 changed files with 43 additions and 3 deletions
35
test/mfm.ts
35
test/mfm.ts
|
@ -12,6 +12,7 @@ import * as assert from 'assert';
|
|||
|
||||
import { parse, parsePlain } from '../src/mfm/parse';
|
||||
import { toHtml } from '../src/mfm/to-html';
|
||||
import { fromHtml } from '../src/mfm/from-html';
|
||||
import { toString } from '../src/mfm/to-string';
|
||||
import { createTree as tree, createLeaf as leaf, MfmTree } from '../src/mfm/prelude';
|
||||
import { removeOrphanedBrackets } from '../src/mfm/language';
|
||||
|
@ -1199,3 +1200,37 @@ describe('MFM', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('fromHtml', () => {
|
||||
it('br', () => {
|
||||
assert.deepStrictEqual(fromHtml('<p>abc<br><br/>d</p>'), 'abc\n\nd');
|
||||
});
|
||||
|
||||
it('link with different text', () => {
|
||||
assert.deepStrictEqual(fromHtml('<p>a <a href="https://example.com/b">c</a> d</p>'), 'a [c](https://example.com/b) d');
|
||||
});
|
||||
|
||||
it('link with same text', () => {
|
||||
assert.deepStrictEqual(fromHtml('<p>a <a href="https://example.com/b">https://example.com/b</a> d</p>'), 'a https://example.com/b d');
|
||||
});
|
||||
|
||||
it('link with same text, but not encoded', () => {
|
||||
assert.deepStrictEqual(fromHtml('<p>a <a href="https://example.com/ä">https://example.com/ä</a> d</p>'), 'a <https://example.com/ä> d');
|
||||
});
|
||||
|
||||
it('link with no url', () => {
|
||||
assert.deepStrictEqual(fromHtml('<p>a <a href="b">c</a> d</p>'), 'a [c](b) d');
|
||||
});
|
||||
|
||||
it('link without href', () => {
|
||||
assert.deepStrictEqual(fromHtml('<p>a <a>c</a> d</p>'), 'a c d');
|
||||
});
|
||||
|
||||
it('mention', () => {
|
||||
assert.deepStrictEqual(fromHtml('<p>a <a href="https://example.com/@user" class="u-url mention">@user</a> d</p>'), 'a @user@example.com d');
|
||||
});
|
||||
|
||||
it('hashtag', () => {
|
||||
assert.deepStrictEqual(fromHtml('<p>a <a href="https://example.com/tags/a">#a</a> d</p>', ['#a']), 'a #a d');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue