fix(widget-markdown): don't add duplicate marks (#3290)
This commit is contained in:
parent
73f679480b
commit
2a0aef27d1
@ -0,0 +1 @@
|
||||
Fill to_*this*_mark, and your charge is but a penny; to_*this*_a penny more; and so on to the full glass—the Cape Horn measure, which you may gulp down for a shilling.\n\nUpon entering the place I found a number of young seamen gathered about a table, examining by a dim light divers specimens of_*skrimshander*.
|
@ -0,0 +1,41 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { markdownToSlate } from '../';
|
||||
|
||||
describe('markdownToSlate', () => {
|
||||
it('should handle use case from issue 3280', () => {
|
||||
const mdast = fs.readFileSync(path.join(__dirname, '__fixtures__', 'issue_3280.md'));
|
||||
const slate = markdownToSlate(mdast);
|
||||
|
||||
expect(slate).toEqual({
|
||||
object: 'block',
|
||||
type: 'root',
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
type: 'paragraph',
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
text: 'Fill to',
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text:
|
||||
'this_mark, and your charge is but a penny; tothisa penny more; and so on to the full glass—the Cape Horn measure, which you may gulp down for a shilling.\\n\\nUpon entering the place I found a number of young seamen gathered about a table, examining by a dim light divers specimens ofskrimshander',
|
||||
marks: [
|
||||
{
|
||||
type: 'italic',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: '.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
@ -230,7 +230,9 @@ export default function remarkToSlate({ voidCodeBlock } = {}) {
|
||||
* mark nodes, if any.
|
||||
*/
|
||||
const markType = markMap[node.type];
|
||||
const marks = markType ? [...parentMarks, { type: markMap[node.type] }] : parentMarks;
|
||||
const marks = markType
|
||||
? [...parentMarks.filter(({ type }) => type !== markType), { type: markType }]
|
||||
: parentMarks;
|
||||
|
||||
const children = flatMap(node.children, child => processMarkChild(child, marks));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user