Fix highlighting of source code blocks throughout the Atomic Desktops docs site #11

Open
opened 2026-01-20 16:34:36 +00:00 by siosm · 14 comments
Owner

As much as possible and where it makes sense, we should remove the $ signs from the code snippets where we expect users will copy/paste the commands as is.

We should make sure to use the console code style for the cases where we have a $ and the bash code style where we don't have one.

Imported from https://pagure.io/fedora-kde/kinoite-docs/issue/15

As much as possible and where it makes sense, we should remove the `$` signs from the code snippets where we expect users will copy/paste the commands as is. We should make sure to use the `console` code style for the cases where we have a `$` and the `bash` code style where we don't have one. Imported from https://pagure.io/fedora-kde/kinoite-docs/issue/15
Member

@siosm wrote in #11 (comment):

As much as possible and where it makes sense, we should remove the $ signs from the code snippets where we expect users will copy/paste the commands as is.

As far as I know, our Fedora (and also Red Hat) guides do not recommend this, but rather what is already our established current style, see:
https://docs.fedoraproject.org/en-US/atomic-desktops/contributing/#writing-documentation
https://docs.fedoraproject.org/en-US/fedora-docs/contributing-docs/style-guide/#_typographic_style_guide
https://stylepedia.net/style/#documenting-command-syntax

@siosm wrote in #11 (comment):

We should make sure to use the console code style for the cases where we have a $ and the bash code style where we don't have one.

We already do this, except in cases where it degrades the visual layout of the commands and their output.

@siosm wrote in https://forge.fedoraproject.org/atomic-desktops/docs/issues/11#issue-50863: > As much as possible and where it makes sense, we should remove the `$` signs from the code snippets where we expect users will copy/paste the commands as is. As far as I know, our Fedora (and also Red Hat) guides do not recommend this, but rather what is already our established current style, see: https://docs.fedoraproject.org/en-US/atomic-desktops/contributing/#writing-documentation https://docs.fedoraproject.org/en-US/fedora-docs/contributing-docs/style-guide/#_typographic_style_guide https://stylepedia.net/style/#documenting-command-syntax @siosm wrote in https://forge.fedoraproject.org/atomic-desktops/docs/issues/11#issue-50863: > We should make sure to use the `console` code style for the cases where we have a `$` and the `bash` code style where we don't have one. We already do this, except in cases where it degrades the visual layout of the commands and their output.
Author
Owner

I'm fine either way.

I'm fine either way.
Member

@hricky wrote in #11 (comment):

@siosm wrote in #11 (comment):

We should make sure to use the console code style for the cases where we have a $ and the bash code style where we don't have one.

We already do this, except in cases where it degrades the visual layout of the commands and their output.

I just realized that I overlooked the source highlighting for code blocks and instead of [source,console] we are currently mostly using [source] or [source,bash]. So when I copy the source code block to the clipboard, the $ is also copied. This is an unpleasant user experience and I will fix it throughout the Atomic Desktops docs site.

@hricky wrote in https://forge.fedoraproject.org/atomic-desktops/docs/issues/11#issuecomment-264605: > @siosm wrote in #11 (comment): > > > We should make sure to use the `console` code style for the cases where we have a `$` and the `bash` code style where we don't have one. > > We already do this, except in cases where it degrades the visual layout of the commands and their output. I just realized that I overlooked the source highlighting for code blocks and instead of `[source,console]` we are currently mostly using `[source]` or `[source,bash]`. So when I copy the source code block to the clipboard, the `$` is also copied. This is an unpleasant user experience and I will fix it throughout the Atomic Desktops docs site.
hricky changed title from Remove dollar sign '$' from the terminal commands to Fix highlighting of source code blocks throughout the Atomic Desktops docs site 2026-01-20 22:23:54 +00:00
hricky self-assigned this 2026-01-20 22:32:33 +00:00

If you just use [,console], it produces a block where if the user highlights a line, the $ or # at the start won't be highlighted, so you can copypaste lines easily. You can see an example here:

Output: https://docs.fedoraproject.org/en-US/epel/getting-started/#_el10

Source: https://forge.fedoraproject.org/epel/docs/src/branch/main/modules/ROOT/pages/getting-started.adoc?display=source#L35

If you just use `[,console]`, it produces a block where if the user highlights a line, the `$` or `#` at the start won't be highlighted, so you can copypaste lines easily. You can see an example here: Output: https://docs.fedoraproject.org/en-US/epel/getting-started/#_el10 Source: https://forge.fedoraproject.org/epel/docs/src/branch/main/modules/ROOT/pages/getting-started.adoc?display=source#L35
Author
Owner

If you just use [,console], it produces a block where if the user highlights a line, the $ or # at the start won't be highlighted, so you can copypaste lines easily.

Oh this is nice. Let's do that.

> If you just use `[,console]`, it produces a block where if the user highlights a line, the `$` or `#` at the start won't be highlighted, so you can copypaste lines easily. Oh this is nice. Let's do that.
Member

@siosm wrote in #11 (comment):

Oh this is nice. Let's do that.

If you don't mind, I would prefer the longer and more descriptive form ([source,console]) that I mentioned in my previous comment. I tested it and the rendering of the HTML site is identical for both forms. For reference, see https://docs.asciidoctor.org/asciidoc/latest/verbatim/source-highlighter/#shell-vs-console.

@siosm wrote in https://forge.fedoraproject.org/atomic-desktops/docs/issues/11#issuecomment-336747: > Oh this is nice. Let's do that. If you don't mind, I would prefer the longer and more descriptive form (`[source,console]`) that I mentioned in my previous comment. I tested it and the rendering of the HTML site is identical for both forms. For reference, see https://docs.asciidoctor.org/asciidoc/latest/verbatim/source-highlighter/#shell-vs-console.
Author
Owner

Ah, sure, I did not know that both were equivalent. Usually better to be explicit.

Ah, sure, I did not know that both were equivalent. Usually better to be explicit.
Author
Owner

So I guess a lot of the "code" blocks only need an update from bash to console.

So I guess a lot of the "code" blocks only need an update from bash to console.
Member

Yes, I fixed a few files in different commits and when I'm done with the rest, I'll open a PR with all of them.

Yes, I fixed a few files in different commits and when I'm done with the rest, I'll open a PR with all of them.
Member

Apparently the source-highlighter attribute with the console source language used treats # as the start of a comment. When the line begins with it, the entire line is not even copied to the clipboard. This actually makes sense, as it is an expected and nice feature. However, it kind of contradicts with the writing style conventions/gudes referred in one of my previous post.

The Typographic style guide in the Fedora Documentation Style Guide states:

Use a shell prompt ($ or #) to indicate privilege level and set the input apart from output.

The Command Terminology and Syntax section of the Red Hat Technical Writing Style Guide states at the beginning:

There is sufficient variation in the terminology used to describe commands, options, arguments, etc., so only general advice is provided here.

And also below:

The prompt ($) indicates that a normal user can run the command, as compared to the root user, which would be indicated by the number sign (#).

...some sections omitted...

In the narrative, do not show the use of su or sudo, but always show privileged commands with the correct prompt.

So, should we replace the # symbol at the beginning of lines with the $ sudo prompt/command, contrary to conventions/guides, or should we disable the source-highlighter attribute with the console source language used, and continue to provide the not-so-pleasant user experience of copying $ and # to the clipboard?

Or maybe something different?

Apparently the `source-highlighter` attribute with the `console` source language used treats `#` as the start of a comment. When the line begins with it, the entire line is not even copied to the clipboard. This actually makes sense, as it is an expected and nice feature. However, it kind of contradicts with the writing style conventions/gudes referred in one of my previous post. The Typographic style guide in the Fedora Documentation Style Guide states: > Use a shell prompt (`$` or `#`) to indicate privilege level and set the input apart from output. The Command Terminology and Syntax section of the Red Hat Technical Writing Style Guide states at the beginning: > There is sufficient variation in the terminology used to describe commands, options, arguments, etc., so only general advice is provided here. And also below: > The prompt (`$`) indicates that a normal user can run the command, as compared to the root user, which would be indicated by the number sign (`#`). ...some sections omitted... > In the narrative, do not show the use of `su` or `sudo`, but always show privileged commands with the correct prompt. So, should we replace the `#` symbol at the beginning of lines with the `$ sudo` prompt/command, contrary to conventions/guides, or should we disable the `source-highlighter` attribute with the `console` source language used, and continue to provide the not-so-pleasant user experience of copying `$` and `#` to the clipboard? Or maybe something different?
Author
Owner

Well, we already don't follow the recommendations from https://docs.fedoraproject.org/en-US/atomic-desktops/contributing/#writing-documentation in https://docs.fedoraproject.org/en-US/atomic-desktops/tips-and-tricks/#_hiding_the_default_browser_firefox for example.

I think we should remove those recommendations and instead rely on the general docs recommendations if they exists?

But in the meantime I'm leaning towards using $ sudo everywhere as that's what we are using already.

Well, we already don't follow the recommendations from https://docs.fedoraproject.org/en-US/atomic-desktops/contributing/#writing-documentation in https://docs.fedoraproject.org/en-US/atomic-desktops/tips-and-tricks/#_hiding_the_default_browser_firefox for example. I think we should remove those recommendations and instead rely on the general docs recommendations if they exists? But in the meantime I'm leaning towards using `$ sudo` everywhere as that's what we are using already.
Member

I think the general docs recommendations should be The Command Terminology and Syntax section of the Red Hat Technical Writing Style Guide, which as mentioned begins with:

Sufficient variation exists in the terminology that is used to describe commands, options, arguments, and so on that only general advice is provided here.

Since the specifics of Antora/AsciiDoc and their copy/paste functionalities are not covered in this document and for a better user experience, I also think it would be better to replace the # symbol at the beginning of lines with the $ sudo prompt/command.

I think the general docs recommendations should be [The Command Terminology and Syntax section of the Red Hat Technical Writing Style Guide](https://stylepedia.net/style/#documenting-command-syntax), which as mentioned begins with: > Sufficient variation exists in the terminology that is used to describe commands, options, arguments, and so on that only general advice is provided here. Since the specifics of Antora/AsciiDoc and their copy/paste functionalities are not covered in this document and for a better user experience, I also think it would be better to replace the `#` symbol at the beginning of lines with the `$ sudo` prompt/command.

@hricky The bit from the Red Hat Technical Writing Style Guide isn't all that relevant in this particular case (it's a good resource otherwise, though a bit too expansive for community use).

In Red Hat Enterprise Linux, there's typically a root account on the machine that can be normally accessed, and procedures in docs often tell the user to start by switching to root. This avoids having to put "sudo" on every line. In that case, the prompt is useful to remind the user "where" they are. So, if you're in the middle of a procedure, the next step shows the $ prompt and you're seeing a # or the other way around, it's a good idea to take a second look because you probably missed a step, or you're looking at the wrong terminal session.

Fedora has had locked down root by default for years now, so everything is done through sudo, and the distinction becomes less important, the prompt is pretty much always going to be a $. We could even drop it completely, but sometimes it's useful to indicate a difference between a command and its output. So, as @siosm says, I'd use $ sudo everywhere.

@hricky The bit from the Red Hat Technical Writing Style Guide isn't all that relevant in this particular case (it's a good resource otherwise, though a bit too expansive for community use). In Red Hat Enterprise Linux, there's typically a root account on the machine that can be normally accessed, and procedures in docs often tell the user to start by switching to root. This avoids having to put "sudo" on every line. In that case, the prompt is useful to remind the user "where" they are. So, if you're in the middle of a procedure, the next step shows the `$` prompt and you're seeing a `#` or the other way around, it's a good idea to take a second look because you probably missed a step, or you're looking at the wrong terminal session. Fedora has had locked down root by default for years now, so everything is done through sudo, and the distinction becomes less important, the prompt is pretty much always going to be a `$`. We could even drop it completely, but sometimes it's useful to indicate a difference between a command and its output. So, as @siosm says, I'd use `$ sudo` everywhere.
Member

Sometimes it is convenient to use sudo -i to avoid typing sudo for subsequent commands. Currently in Fedora Silverblue this changes both the colour and the symbol of the prompt. Anyhow, it doesn't seem to matter that much and I'll follow your suggestions and use $ sudo everywhere.

Sometimes it is convenient to use `sudo -i` to avoid typing `sudo` for subsequent commands. Currently in Fedora Silverblue this changes both the colour and the symbol of the prompt. Anyhow, it doesn't seem to matter that much and I'll follow your suggestions and use `$ sudo` everywhere.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
atomic-desktops/docs#11
No description provided.