Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on how do I get markdown to render # as a shell prompt and not a comment?

Post

how do I get markdown to render # as a shell prompt and not a comment?

+4
−1

Note: This is a general question about Markdown formatting for any Markdown renderer (e.g., Gitlab, Github, Codidact). So this is not just a question about Codidact's renderer.

When displaying shell commands in Markdown, I often want to use the hash sign (#) to indicate that I am running the command as root. However, Markdown renderers usually interpret the # character as the beginning of a comment, which results in the entire line being rendered as a comment (usually in the color gray).

For example, using the shell code fence (```sh), the following command is rendered as intended with colors:

echo hi

However, if I precede that command with #, the Markdown interpreter thinks the entire line is a comment:

# echo hi

Is there anyway to tell Markdown to ignore/exclude the # character?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Markdown does not do highlighting (2 comments)
Markdown does not do highlighting
Moshi‭ wrote 5 days ago

Markdown does provide a way to do a code block with metadata using the backtick syntax, but it does not actually describe either what the metadata describes, nor how highlighting is handled.

This means highlighting is implementation-specific.

Codidact and StackExchange use highlight.js to highlight code blocks.

GitHub uses it's own highlighter called linguist

Note that these two are tools used in addition to the Markdown engine and are not a part of either Markdown implementation.

Andreas witnessed the end of the world today‭ wrote 4 days ago · edited 4 days ago

With this in mind, I don't the think the question really lives up to the standards as of now. The answer still seems useful, though, just for a different question. The question in its current form needs an overhaul; rather large one. Potentially split it into two: one Q/A for the explanation for how code highlighting in Markdown works, and another one for the specific case of sh vs shell/console. Due to the way the question is currently composed, it has limited reusability.