Skip to content

Commit

Permalink
fix: ignore unsupported marks
Browse files Browse the repository at this point in the history
  • Loading branch information
sbezludny committed Dec 17, 2018
1 parent 7a464fa commit 1757331
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ __This is bold text__

_This is italic text_

~~Strikethrough~~
~~Strikethrough is not supported~~


## Blockquotes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('rich-text-from-markdown', () => {
block(BLOCKS.PARAGRAPH, {}, text('This is bold text', mark('bold'))),
block(BLOCKS.PARAGRAPH, {}, text('This is italic text', mark('italic'))),
block(BLOCKS.PARAGRAPH, {}, text('This is italic text', mark('italic'))),
block(BLOCKS.PARAGRAPH, {}, text('Strikethrough', mark(undefined))),
block(BLOCKS.PARAGRAPH, {}, text('Strikethrough is not supported')),
block(BLOCKS.HEADING_2, {}, text('Blockquotes')),
block(BLOCKS.QUOTE, {}, block(BLOCKS.PARAGRAPH, {}, text('Blockquotes'))),
block(BLOCKS.HEADING_2, {}, text('Lists')),
Expand Down
10 changes: 7 additions & 3 deletions packages/rich-text-from-markdown/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ async function mdToRichTextNode(node: MarkdownNode, fallback: FallbackResolver):
// for example: **_Hello_, world!**
// this a markdown node here that's why we use children
nodeValue = node.children ? node.children[0].value : node.value;
marks.push({
type: markTypeFor(node),
});

const markType = markTypeFor(node);
if (markType) {
marks.push({
type: markTypeFor(node),
});
}
}
return {
nodeType: nodeType,
Expand Down

0 comments on commit 1757331

Please sign in to comment.