Skip to content

Commit

Permalink
Turn off link and autolink rule matching in inlineRules
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashoat committed Jul 19, 2020
1 parent ca584a0 commit 3bf844b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions native/markdown/rules.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ function inlineMarkdownRules(
styles: StyleSheetOf<MarkdownStyles>,
): MarkdownRuleSpec {
const simpleMarkdownRules = {
// Matches '<https://google.com>' during parse phase and returns a 'link'
// node
autolink: SimpleMarkdown.defaultRules.autolink,
// Matches 'https://google.com' during parse phase and returns a 'link' node
url: {
...SimpleMarkdown.defaultRules.url,
Expand All @@ -36,6 +33,7 @@ function inlineMarkdownRules(
// rendering all 'link' nodes, including for 'autolink' and 'url'
link: {
...SimpleMarkdown.defaultRules.link,
match: () => null,
react(
node: SimpleMarkdown.SingleASTNode,
output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,
Expand Down Expand Up @@ -92,8 +90,22 @@ function inlineMarkdownRules(
function fullMarkdownRules(
styles: StyleSheetOf<MarkdownStyles>,
): MarkdownRuleSpec {
const inlineRules = inlineMarkdownRules(styles);
const simpleMarkdownRules = {
...inlineRules.simpleMarkdownRules,
// Matches '<https://google.com>' during parse phase and returns a 'link'
// node
autolink: SimpleMarkdown.defaultRules.autolink,
// Matches '[Google](https://google.com)' during parse phase and handles
// rendering all 'link' nodes, including for 'autolink' and 'url'
link: {
...inlineRules.simpleMarkdownRules.link,
match: SimpleMarkdown.defaultRules.link.match,
},
};
return {
...inlineMarkdownRules(styles),
...inlineRules,
simpleMarkdownRules,
emojiOnlyFactor: 2,
};
}
Expand Down

0 comments on commit 3bf844b

Please sign in to comment.