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

Add Support for Highlighting Multiple Words in the Same Line #2059

Merged
merged 22 commits into from
Dec 10, 2023

Conversation

zlimez
Copy link
Contributor

@zlimez zlimez commented Dec 17, 2022

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Overview of changes:

Fixes #2050

Screenshot 2022-12-17 at 9 23 09 PM (2)
Suspect this is the block of code preventing multiple words to be highlighted separately on the same line, as only the first highlight rule is applied.

Modified to collate all rules that is applied to the current line, then apply them as a batch.

Anything you'd like to highlight/discuss:

Overlapping highlight intervals are combined and processed in helper.js collateAllIntervals(boundaries) function. Extract applyHighlight method from 'HighlightRule' to Highlighter. Not certain if that is the best approach.

Highlight line takes precedence over highlight whole text over highlight partial text when applied on the same line. Again, not sure if this is the desirable behaviour.

Testing instructions:

Edits made to testCodeBlocks.md:

  • Modified the fence code block test cases partial word variant, full word variant, partial character variant and full word variant to include situations where more than one highlight rules is applied on one line.
  • Included a fence code block test case under all attr should behave as expected, that does a combined testing of all highlight rules, with some overlapping bounds.

Sample output

highlight markdown

highlight result


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

@tlylt

This comment was marked as resolved.

@zlimez

This comment was marked as resolved.

@zlimez

This comment was marked as resolved.

@tlylt tlylt self-requested a review December 26, 2022 02:41
packages/core/src/lib/markdown-it/index.js Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/index.js Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/index.js Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/index.js Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/highlight/Highlighter.js Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/highlight/helper.js Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/index.js Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/index.js Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/index.js Outdated Show resolved Hide resolved
@zlimez

This comment was marked as resolved.

@tlylt

This comment was marked as resolved.

@tlylt

This comment was marked as resolved.

@zlimez
Copy link
Contributor Author

zlimez commented Feb 13, 2023

Hi @zlimez, conflicting files due to recent updates to the highlight parsing. Checking if you are still keen to implement the last few comments/fixes as requested?

cc @yucheng11122017 @lhw-1 you guys can keep tabs on this and render help if needed (given your recent involvement in changes wrt code highlight, thanks!)

Yap, I am still interested but been really busy please give me a week or so, thx!!

@yucheng11122017
Copy link
Contributor

Hi @zlimez, are you still keen to work on this PR? No pressure if you arent

@zlimez
Copy link
Contributor Author

zlimez commented Jul 25, 2023

Hi @zlimez, are you still keen to work on this PR? No pressure if you arent

Sorry I completely forgot about the existence of this PR, can I have till end of this week to fast forward and update the documentations?

@yucheng11122017
Copy link
Contributor

Hi @zlimez, are you still keen to work on this PR? No pressure if you arent

Sorry I completely forgot about the existence of this PR, can I have till end of this week to fast forward and update the documentations?

Yup sure! Feel free to reach out if there is any issues with merge conflicts as these files have been since converted to typescript

@zlimez zlimez marked this pull request as ready for review August 4, 2023 15:46
@zlimez
Copy link
Contributor Author

zlimez commented Aug 4, 2023

I have added documentations and migrated to TS. Please help me review and soz for taking so long.

@zlimez
Copy link
Contributor Author

zlimez commented Aug 10, 2023

Hi @zlimez, are you still keen to work on this PR? No pressure if you arent

Sorry I completely forgot about the existence of this PR, can I have till end of this week to fast forward and update the documentations?

Yup sure! Feel free to reach out if there is any issues with merge conflicts as these files have been since converted to typescript

Hi hi, as per my latest comment I am done with the migration and docs when you are free please kindly help me review 🙂

Copy link
Contributor

@jovyntls jovyntls left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @zlimez!

Haven't tested the functionality as I'm lacking context on this issue but added some comments on the code :)

packages/core/src/lib/markdown-it/highlight/helper.ts Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/highlight/helper.ts Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/highlight/helper.ts Outdated Show resolved Hide resolved
packages/core/src/lib/markdown-it/highlight/helper.ts Outdated Show resolved Hide resolved
@zlimez

This comment was marked as resolved.

@tlylt
Copy link
Contributor

tlylt commented Nov 29, 2023

@zlimez sorry for the delay, review is underway. If you could spare some time to revisit this PR, please see if there are readability fixes that you can apply. Thanks.

@zlimez
Copy link
Contributor Author

zlimez commented Nov 30, 2023

@zlimez sorry for the delay, review is underway. If you could spare some time to revisit this PR, please see if there are readability fixes that you can apply. Thanks.

Ok I will take a look. Thanks.

Copy link
Contributor

@tlylt tlylt left a comment

Choose a reason for hiding this comment

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

Hi @zlimez, just a few more comments to address and I think it should be good to merge soon.

@zlimez
Copy link
Contributor Author

zlimez commented Dec 3, 2023

I have extracted the line number check as per requested hope it is alright

Copy link
Contributor

@tlylt tlylt left a comment

Choose a reason for hiding this comment

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

LGTM

@tlylt tlylt added this to the v5.2.0 milestone Dec 10, 2023
@tlylt tlylt added the r.Minor Version resolver: increment by 0.1.0 label Dec 10, 2023
@tlylt tlylt changed the title Update highlight parsing Add Support for Highlighting Multiple Words in the Same Line Dec 10, 2023
@tlylt tlylt merged commit 11702c9 into MarkBind:master Dec 10, 2023
8 checks passed
@tlylt
Copy link
Contributor

tlylt commented Dec 10, 2023

@all-contributors please add @zlimez for code

Copy link
Contributor

@tlylt

I've put up a pull request to add @zlimez! 🎉

@zlimez
Copy link
Contributor Author

zlimez commented Dec 10, 2023

LGTM

Yeah thx for helping me review for so long ><

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r.Minor Version resolver: increment by 0.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Highlight separate words in the same line for code block
5 participants