-
Notifications
You must be signed in to change notification settings - Fork 462
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
Use nu-highlight
for code blocks
#1719
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a brilliant idea 👍 , just need a bit tweaks
- name: Install Nushell | ||
run: cargo install nu --locked --no-default-features | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Install Nu by this way is quite slow, try this one: https://github.com/hustcer/setup-nu
this.options.defaultColor = 'onedarkpro'; | ||
// this doesn't work at the top-level for some reason | ||
this.options.colorReplacements = { | ||
// make one-dark-pro background color the same as dark-plus | ||
'#282c34': '#1e1e1e', | ||
// HACK: change color of comments, since nu-highlight can't highlight them | ||
'#abb2bf': '#80858f', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to extract these a few lines to a function like adjustTheme, so we can reuse it later
Work in progress. Adds a Shiki transformer which uses the
highlight.nu
script to highlight nushell code blocks usingnu-highlight
.Also adds the ability to add code before the true code block, for examples which require extra code to work:
Only the
str mycommand
line will show up in the final code block, but it will not be error highlighted since thestr mycommand
definition exists.The output of
nu-highlight
heavily depends on bold fonts for readability, so we should make sure all of the fonts listed in--code-font-family
support bold. Notably, on my machine the font fell back to Andale Mono, which did not have a bold face. I was able to get boldansi
highlighting working install consolas, which is a higher priority font in--code-font-family
and does have a bold face.Need to rebase this on #1718 assuming that gets merged.