Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Skalakid
Copy link
Collaborator

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 items

fix.mov

Related Issues

#584

Manual Tests

  1. Open the example app
  2. Write following text: @a #1

Linked PRs

@@ -292,4 +292,4 @@ function parseExpensiMark(markdown: string): MarkdownRange[] {
return groupedRanges;
}

export default parseExpensiMark;
export {parseExpensiMark, sortRanges};
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

@tomekzaw tomekzaw linked an issue Dec 12, 2024 that may be closed by this pull request
@Skalakid Skalakid requested a review from tomekzaw December 13, 2024 08:18
@@ -167,7 +168,8 @@ function parseRangesToHTMLNodes(
return {dom: rootElement, tree: rootNode};
}

const markdownRanges = ungroupRanges(ranges);
const sortedRanges = sortRanges(ranges);
const markdownRanges = ungroupRanges(sortedRanges);
Copy link
Collaborator

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?

Copy link
Collaborator Author

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);
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0d710a0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom parser duplicates the input content on web
3 participants