NodeBB / NodeBB/nodebb-plugin-markdown
Spurious {1} inserted into autodetect code highlighting when numbering enabled.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 33
- Forks
- 41
- Avg merge
- 3h 40m
- Merged PRs (30d)
- 4
Description
There is a bug where specific words in a code block set to use line numbering will cause some empty following lines to have spurious {1} text inserted in it. e.g.:

this can be confirmed by inspecting the <code class> element it will be set to hljs sql for blocks with this issue and hljs perl or other wise for blocks of code without this issue.
This only happens if the code language is autodetected as SQL (hence why the specific words are needed to trigger the highlight.js autodetection for SQL). if the language type is set to SQL or any other type it does not happen:

If line numbering for SQL is turned off in the markdown plugin settings it does not happen:

(note no line numbering, no {1})
So we can work around this issue by just not having line numbering for SQL as we don't post SQL frequently/at all on our forum.
Versions:
NodeBB version: 1.18.5 (although we have had this issue from at least 1.16)
Markdown plugin version: 8.14.4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in the Markdown plugin with an autodetected SQL code block and line numbering enabled, then inspect the code-highlighting and line-numbering integration. Done means SQL autodetection no longer inserts spurious {1} text into empty following lines, while explicit SQL highlighting and other languages remain unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100