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 »
Meta

Welcome to the staging ground for new communities! Each proposal has a description in the "Descriptions" category and a body of questions and answers in "Incubator Q&A". You can ask questions (and get answers, we hope!) right away, and start new proposals.

Are you here to participate in a specific proposal? Click on the proposal tag (with the dark outline) to see only posts about that proposal and not all of the others that are in progress. Tags are at the bottom of each post.

Isolated letters in a code block are sometimes incorrectly bolded.

+4
−0

There seems to be a bug in how some isolated letters are displayed in a code block.

This bug affects how the letters a, b, i, p, and q are displayed. These letters are being bolded without even bolding being requested.

Sample illustrating the bug:

a b c d e f g h i j k l m
n o p q r s t u v w x y z
apple banana island potato queen

Notice how some isolated letters are bolded. :(

History

0 comment threads

2 answers

+3
−0

Syntax highlighting, absent a directive, is guessing at the language. I don't know what language it's defaulting to that would call for highlighting those particular letters, but you can specify text to tell it not to highlight anything, like this:

```text
text goes here
```

Here is your block with this directive:

a b c d e f g h i j k l m 
n o p q r s t u v w x y z
apple banana island potato queen

Alternatively, you can use the HTML pre tag instead of markdown for the block, which is what I did to create the first block in this answer.

History

0 comment threads

+3
−0

Explanation

This is caused by the automatic syntax highlighting. When a programming language is specified for a code block, it is highlighted to reflect the syntax of that language. When no language is specified, the page guesses what language should be displayed, and in some cases this guess is incorrect. This is particularly noticeable when the code block contains plain text rather than code (as might be used to make all the letters the same width for ease of alignment).

This can be avoided by specifying the language you want (in cases where you want syntax highlighting). When you want to suppress syntax highlighting and have all the text displayed consistently, you can specify "plaintext"[1].

If you make your code block in Markdown using triple backticks, you can specify the language name after the opening triple backticks, on the same line.

Examples

CSS

This is the language that was guessed for your example code block, which causes some letters to be displayed in bold.

The raw Markdown:

```css
a b c d e f g h i j k l m
n o p q r s t u v w x y z
apple banana island potato queen
```

Renders as:

a b c d e f g h i j k l m
n o p q r s t u v w x y z
apple banana island potato queen

Plain text

Using "plaintext"[2] results in no syntax highlighting.

The raw Markdown:

```plaintext
a b c d e f g h i j k l m
n o p q r s t u v w x y z
apple banana island potato queen
```

Renders as:

a b c d e f g h i j k l m
n o p q r s t u v w x y z
apple banana island potato queen

  1. The use of "plaintext" is described in the Highlight.js documentation (the software library used to display syntax highlighting on Codidact). Note that Monica's answer describes an alternative approach using a <pre> tag, which avoids specifying the block as code in the first place. This is more appropriate for cases where you want text that is not code but is monospaced (the same width for every character). The approach I describe is less appropriate but uses only Markdown. You are free to use either. ↩︎

  2. Note that "txt" and "text" are synonyms for "plaintext", giving identical rendered output. ↩︎

History

1 comment thread

Clever -- I didn't recognize its choices as single-character HTML elements (and thus things that coul... (4 comments)

Sign up to answer this question »