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

feat: syntax highlighting #55

Closed

Conversation

Jay-Karia
Copy link
Contributor

@Jay-Karia Jay-Karia commented Aug 10, 2024

Adds syntax highlighting to converted command.
Returns an html string.

API

highlight(command, theme)

param: command : string
param: theme : "light" | "dark" with default "light"

Usage

highlight("npm run dev", "dark")

Returns

 <pre class="shiki github-dark" style="background-color:#24292e;color:#e1e4e8" tabindex="0"><code><span class="line"><span style="color:#B392F0">npm</span><span style="color:#9ECBFF"> run</span><span style="color:#9ECBFF"> dev</span></span></code></pre>

Closes #49

@nebrelbug
Copy link
Owner

Looks good! I think it might be better as a separate function though.

@Jay-Karia
Copy link
Contributor Author

@nebrelbug and what about #53 ?

@Jay-Karia
Copy link
Contributor Author

Async / Await does not seem to work in rollup

async_await

It returns a Promise first then the html string, even after using await

@Jay-Karia
Copy link
Contributor Author

jest

Problems in testing using jest.
It has some problem related to the import statement for shiki

@Jay-Karia Jay-Karia mentioned this pull request Aug 24, 2024
@nebrelbug
Copy link
Owner

As I'm thinking about this, I don't know if this functionality belongs in npm-to-yarn. If a user wants to display the command in a codeblock, they can add syntax highlighting with shiki themselves pretty easily.

@Jay-Karia
Copy link
Contributor Author

It would be an add on for the library.
Can improve the asthetics of the output.

If we discontinue this, what about #60

@nebrelbug
Copy link
Owner

I think it might be nice as a separate package to integrate.

The rest of #60 looks good to me though.

@Jay-Karia Jay-Karia closed this Aug 29, 2024
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.

Feature request: add syntax highlighting
2 participants