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

Support code highlighting #2

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

Conversation

rickyzhangca
Copy link

@rickyzhangca rickyzhangca commented May 2, 2024

Feature

specify the language for the snippet and highlight lines, see examples below (using screenshots because github can't escape ```)

Syntax

after specifying the language, specify one or multiple line ranges to highlight, surrounded by {}, it can be {integer}, {integer-integer}, or combined like {integer-integer, integer}

```java {2}
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```

Examples

highlight one line

image

highlight multiple lines with

image

highlight line range with

image

combine them with

image

Note

Test plan

see the deployment below to preview it, or to test locally,

  1. clone the repo
  2. yarn
  3. cd examples
  4. cd pages-router or cd app-router
  5. yarn add file:../../
  6. yarn dev
  7. change the files in examples/pages-router/examples/highlight.mdx or examples/app-router/examples/highlight.mdx and restart the page to see changes

image

Copy link

vercel bot commented May 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mdx-app-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 26, 2024 1:29pm
mdx-pages-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 26, 2024 1:29pm

@hahnbeelee
Copy link
Member

@rickyzhangca can you provide a better test plan? What's the syntax?

This reverts commit 40598cf.
@hahnbeelee
Copy link
Member

@rickyzhangca how would this work with our current code block component?

@rickyzhangca
Copy link
Author

rickyzhangca commented Aug 20, 2024

@hahnbeelee

@rickyzhangca how would this work with our current code block component?

it's plug-and-play, just two things to do!

  1. bump @mintlify/mdx
  2. update this line of prism css in client to be #f7d87c24 to add transparency

image

but testing in client locally with npm link is kinda hard, i tried both npm link and yarn link and had no luck (likely because both package stat with @mintlify/... but are in different repo), i was just copying over the dist folder to node_modules in mint, and manually yarn add parse-numeric-range in mint

note: made a one line fix to remove highlighting range from the meta so the client components don't need to do it, to minimize changes needed downstream

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