-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add h1 markdown #468
Add h1 markdown #468
Changes from all commits
bf8074e
929abd2
3ea9691
29fb855
56af2fe
58f5320
650f1ac
a1e6aa9
1f0a776
6cd14a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,11 @@ export default class ExpensiMark { | |
}, | ||
replacement: g1 => `<blockquote>${g1}</blockquote>`, | ||
}, | ||
{ | ||
name: 'heading1', | ||
regex: /^#(?!#) +(.+)$/gm, | ||
replacement: '<h1>$1</h1>', | ||
}, | ||
Comment on lines
+165
to
+169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This rule was misplaced. It should have been placed before quote rule, because the quote rule consumes the newlines chars i.e. |
||
{ | ||
name: 'newline', | ||
regex: /\n/g, | ||
|
@@ -223,6 +228,11 @@ export default class ExpensiMark { | |
regex: /<br(?:"[^"]*"|'[^']*'|[^'"><])*>\n?/gi, | ||
replacement: '\n', | ||
}, | ||
{ | ||
name: 'heading1', | ||
regex: /\s*<(h1)(?:"[^"]*"|'[^']*'|[^'">])*>(.*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))\s*/gi, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👋 |
||
replacement: '\n# $2\n', | ||
}, | ||
{ | ||
name: 'italic', | ||
regex: /<(em|i)(?:"[^"]*"|'[^']*'|[^'">])*>(.*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi, | ||
|
@@ -465,8 +475,7 @@ export default class ExpensiMark { | |
} | ||
generatedMarkdown = generatedMarkdown.replace(rule.regex, rule.replacement); | ||
}); | ||
generatedMarkdown = generatedMarkdown | ||
.replace(/<div.*?>|<\/div>|<comment.*?>|\n<\/comment>|<\/comment>|<h1>|<\/h1>|<h2>|<\/h2>|<h3>|<\/h3>|<h4>|<\/h4>|<h5>|<\/h5>|<h6>|<\/h6>/gm, '[block]'); | ||
generatedMarkdown = generatedMarkdown.replace(/<div.*?>|<\/div>|<comment.*?>|\n<\/comment>|<\/comment>|<h2>|<\/h2>|<h3>|<\/h3>|<h4>|<\/h4>|<h5>|<\/h5>|<h6>|<\/h6>/gm, '[block]'); | ||
return Str.htmlDecode(this.replaceBlockWithNewLine(Str.stripHTML(generatedMarkdown))); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should split these tests up. For example this one is testing
# Heading
case# Heading
)#Heading
).You can split this into 3 small and simple tests that'll be easier to read. Also this way there's no need for the long message in the test string that explains everything 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I like your suggestion 👍