Skip to content

Improve code syntax highlighting and formatting in Sphinx #228

Closed
@kinow

Description

@kinow

I tried using different styles for pygments, but Shell scripts are not easy to parse visually. I thought it wasn't really good, and @swzCuroverse 's review confirmed that the current output is not good enough.

image

In the image above, the three command-line commands are being rendered in Sphinx by pygments (MyST vs. rst doesn't really matter here I think). I had to add the $ before the command to distinguish when the code block includes output. But adding prefixes like $ is not considered a good practice as it makes it harder for users to copy-and-paste commands.

This issue is to find a better way to render commands. GitHub produces a good output. It would be good to find one that:

  • Has different themes/styles (e.g. in case we have reports from color-blind users, we may need to change the theme, easier if we don't have to change CSS styles).
  • Has the option to display line numbers.
  • Has the option to display a command prefix.
  • Creates an output that is easy to comprehend, especially when you have command-line program and output in the same code block.
  • Easy to integrate in Sphinx.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions