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 code block inline marking, including ins & del marker types #1160

Merged
merged 11 commits into from
Aug 2, 2022

Conversation

hippotastic
Copy link
Contributor

What kind of changes does this PR include?

  • Changes to the docs site code

Description

  • Adds support for line marking definitions with an optional marker type prefix. Examples:
    • {4-5,10} (if no marker type prefix is given, it defaults to mark)
    • mark={4-5,10}
    • del={4-5,10} (new, marks a deleted line, alias name: rem)
    • ins={4-5,10} (new, marks an added line, alias name: add)
  • Adds support for inline marking definitions inside forward slashes, with an optional marker type prefix. Examples:
    • /sidebar/ (if no marker type prefix is given, it defaults to mark)
    • mark=/sidebar/ (all common regular expression features are supported)
    • mark=/slot="(.*?)"/ (if capture groups are contained, these will be marked)
    • del=/src\/pages\/.*\.astro/ (escaping special chars with a backslash works, too)
    • ins=/this|that/
  • Fixes various escaping issues by replacing our faulty escapeHtml/unescapeHtml functions with the battle-tested html-escaper package.
  • Adds marker examples to framework-components.md:
    • Line & inline markers of add/ins type:
      image
    • Marking regular expression capture groups:
      image

@netlify
Copy link

netlify bot commented Aug 1, 2022

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 39936d0
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/62e911dbfca631000893956c
😎 Deploy Preview https://deploy-preview-1160--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@hippotastic
Copy link
Contributor Author

Looks like Netlify's Node.js version doesn't support the RegExp flag d which I'm using to get the indices of capture groups. Will need to find an alternative for that. :)

@hippotastic
Copy link
Contributor Author

I added a fallback that seems to work well. https://deploy-preview-1160--astro-docs-2.netlify.app/en/core-concepts/framework-components/ :)

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

LGTM! This totally looks like another instance of “Hippo builds an entire useful ecosystem package inside docs” so like for the link checker, I’d encourage you to consider looking at wrapping this up as a “Rocket-fueled Syntax Highlighter” npm package so we can share the brilliance and make it easier to add tests etc.

@hippotastic hippotastic merged commit d649ada into withastro:main Aug 2, 2022
@hippotastic hippotastic deleted the hippotastic/thirsty-coral branch August 2, 2022 13:50
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.

2 participants