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(content): failed ci on windows and enhance file name detection regex #680

Merged
merged 3 commits into from
Dec 15, 2020
Merged

fix(content): failed ci on windows and enhance file name detection regex #680

merged 3 commits into from
Dec 15, 2020

Conversation

jefrydco
Copy link
Contributor

@jefrydco jefrydco commented Dec 13, 2020

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR do 2 things:

  1. Fix failed CI build on windows.
    Last time we added custom highlighter, the test case always make the CI failed on Windows. After long debugging, I found that the culprit was shiki twoslash always renders a custom link to TypeScript playground for each code block. I don't know why the custom link is generated a little bit random although the code isn't changed in Windows. It doesn't work that way in Linux or Windows, the link will always be same. That's why the CI isn't failed in Linux and Mac. So I decided to remove that link to make the test case worked.

To give more context @benjamincanac and I already discussed here #467 .

  1. Enhance file name detection regex
    Using previous method, this code won't parsed correctly:
```typescript {}[something.ts] somemeta
console.log('Hello World')

By default we already parsed language, line highlight and file name. And actually we can still add our custom data/identifier there. In new custom highlighter syntax we can get that value through node:

export default {
  content: {
    highlighter(rawCode, lang, thematicBlock, astUtility) {
      const { node } = astUtility
      const { meta } = node 
      // meta here contains "somemeta" above
    }
  }
}

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (if not applicable, please state why)

Copy link
Member

@Atinux Atinux left a comment

Choose a reason for hiding this comment

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

Beautiful work!

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.

None yet

3 participants