Skip to content

Conversation

@diogotcorreia
Copy link
Contributor

Summary

When importing code snippets with the <<< syntax, you could only either specify a single range ({34-37}) or a maximum of two lines to be highlighted ({3,6}).

This PR fixes the regex that was matching the syntax so it allows for unlimited line highlights like the ``` syntax.

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of default theme, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

You have tested in the following browsers: (Providing a detailed version will be better.)

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature
  • Related documents have been updated
  • Related tests have been updated

To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

Before this PR, a snippet like

<<< @/path/to/file.js{5-7,10-16,25}

would output Invalid code snippet option.

Old regex:
image

New regex:
image

for importing files (using `<<<`)
@diogotcorreia diogotcorreia changed the title Fix line highlighting not working correctly Fix: line highlighting not working correctly Jun 11, 2020
@StevenLikeWatermelon
Copy link

good job! it helped me a lot

Copy link
Collaborator

@billyyyyy3320 billyyyyy3320 left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

Could you add a unit test for this change? (markdown/__tests__/snippet.spec.js)

@billyyyyy3320 billyyyyy3320 changed the title Fix: line highlighting not working correctly fix($markdown): line highlighting not working correctly when importing code snippets Jun 28, 2020
@diogotcorreia
Copy link
Contributor Author

@billyyyyy3320 Done! 👍

Copy link
Collaborator

@billyyyyy3320 billyyyyy3320 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

4 participants