-
Notifications
You must be signed in to change notification settings - Fork 446
Highlight bash commands #1544
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
base: master
Are you sure you want to change the base?
Highlight bash commands #1544
Conversation
|
🚀 Preview deployment available at: https://b6d1686c.rdoc-6cd.pages.dev (commit: d920014) |
33f140c to
b6f5235
Compare
Replace language-specific CSS variables (--c-*) with a shared neutral color palette (--code-*) that can be reused across different syntax highlighters. This reduces duplication and makes it easier to maintain consistent colors across C, Ruby, and future language highlighters. Changes: - Add --code-cyan and --code-gray to neutral palette - Remove --c-* semantic variables for C highlighting - Update .c-* classes to reference neutral --code-* variables
b6f5235 to
8bcfca6
Compare
Add a simple shell/bash syntax highlighter for documentation code blocks. The highlighter is focused on command-line documentation rather than full bash scripts. Highlights: - $ prompts (gray) - Commands/executables - first word on line (blue) - Options like -f, --flag, --option=value (cyan) - Single and double quoted strings (green) - Comments starting with # (gray, italic) The highlighter targets code blocks with language classes: bash, sh, shell, console. Files added: - lib/rdoc/generator/template/aliki/js/bash_highlighter.js - test/rdoc/generator/aliki/highlight_bash_test.rb
8bcfca6 to
d920014
Compare
|
|
||
| // Option (must be after whitespace) | ||
| if (ch === '-' && afterSpace) { | ||
| var match = line.slice(i).match(/^--?[a-zA-Z0-9_-]+(=[^\s]*)?/); |
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.
Assuming this input
git commit --message="initial commit"How about (=[^\s]*)? → (=[^"\s]*)?
"" part will be handled in // Double-quoted string logic above.
|
|
||
| // Command (first word: regular, ./path, ../path, ~/path, @scope/pkg) | ||
| if (!seenCommand && afterSpace) { | ||
| var isCmd = /[a-zA-Z0-9@~]/.test(ch) || |
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.
How about adding / to accept /bin/sh as command?
The current bash command code blocks are highlighted inconsistently because some code blocks got detected as Ruby, so Ruby highlighting is applied. This has been addressed in #1538.
But after the PR, we don't have any highlighting for bash, which I think we can provide rather simply.
With this PR, we can highlight code blocks tagged as
sh,shell,bash, andconsolewith a simple JS highlighter.