-
Notifications
You must be signed in to change notification settings - Fork 66
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
Fix custom parsing on the web #585
base: main
Are you sure you want to change the base?
Conversation
src/parseExpensiMark.ts
Outdated
@@ -292,4 +292,4 @@ function parseExpensiMark(markdown: string): MarkdownRange[] { | |||
return groupedRanges; | |||
} | |||
|
|||
export default parseExpensiMark; | |||
export {parseExpensiMark, sortRanges}; |
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 don't think it's a good idea to export and use sortRanges
from parseExpensiMark
. This is a self-contained parser used as default which we plan to remove from the repo at some point so we shouldn't use any of its pieces in the library code. Instead, let's extract sortRanges
to a separate file (maybe something like parserUtils.ts
?) and import it here from there.
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.
Okay, I moved them to the rangeUtils
since parserUtils.ts
already exists on the web
@@ -167,7 +168,8 @@ function parseRangesToHTMLNodes( | |||
return {dom: rootElement, tree: rootNode}; | |||
} | |||
|
|||
const markdownRanges = ungroupRanges(ranges); | |||
const sortedRanges = sortRanges(ranges); | |||
const markdownRanges = ungroupRanges(sortedRanges); |
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.
Why don't we move ungroupRanges
to rangeUtils.ts
as well?
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.
Done in 0d710a0
@@ -167,7 +168,8 @@ function parseRangesToHTMLNodes( | |||
return {dom: rootElement, tree: rootNode}; | |||
} | |||
|
|||
const markdownRanges = ungroupRanges(ranges); | |||
const sortedRanges = sortRanges(ranges); |
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.
Can you add a comment here explaining either why we are doing this, or just what we're doing?
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.
Done in 0d710a0
Details
This PR adds range sorting in web range to HTML parser in
parserUtils.ts
. Web parsers requires sorted ranges to work properly, so we with fix we enforce the correct order of itemsfix.mov
Related Issues
#584
Manual Tests
@a #1
Linked PRs