-
Notifications
You must be signed in to change notification settings - Fork 135
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
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
@@ -452,3 +452,35 @@ test('map real message with quotes', () => { | |||
const resultString = '\n> hi\n\n\n> hi\n\n'; | |||
expect(parser.htmlToMarkdown(testString)).toBe(resultString); | |||
}); | |||
|
|||
test('Test heading1 markdown replacement', () => { |
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
- normal
# Heading
case - cases with multiple spaces (
# Heading
) - cases with none (
#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 👍
Co-authored-by: Andrew Rosiclair <arosiclair@expensify.com>
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.
Thanks for the changes!
Heyhey! Heads up that this PR caused this issue. We basically forgot to handle a case where the # was followed by two spaces and a new line |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
👋
This has caused a regression in Expensify/App#17998.
We were removing all of the new line breaks before <h1>
tag, (\s), but should remove whitespaces ([^\S\r\n]).
More details here
{ | ||
name: 'heading1', | ||
regex: /^#(?!#) +(.+)$/gm, | ||
replacement: '<h1>$1</h1>', | ||
}, |
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.
This rule was misplaced. It should have been placed before quote rule, because the quote rule consumes the newlines chars i.e. \n
. This made such markdown fail > a\n# b
. (Coming from Expensify/App#21846)
Part of this DesignDoc.
Adds support for heading markdown. A line which starts with # and a space (
#
) is wrapped with<h1></h1>
tag.Fixed Issues
https://github.com/Expensify/Expensify/issues/225615
Tests
expensify-common
local repository by following these stepsQA