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 Codidact Meta!

Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.

Comments on Syntax highlighting comments break the unsupported tags warning message

Post

Syntax highlighting comments break the unsupported tags warning message

+4
−0

When an HTML tag is used in a post but is not supported by Codidact, a warning message is displayed listing the unsupported tags. However, syntax highlighting hints in the form of HTML comments such as <!-- language-all:lang-python --> are listed as <undefined> in the warning message:

Unsupported HTML message, listing undefined instead of a tag name

This makes it difficult for people to guess which part of their draft is the cause of the problem.

Should we exclude HTML comments from the list?

HTML comments (whether related to syntax highlighting or not) are not expected to be visible in the final post. Should anything that starts in <!-- and ends in --> be excluded from the list shown in the warning message?

Do language hints affect syntax highlighting?

As far as I can tell, these HTML comment syntax highlighting hints such as <!-- language-all:lang-python --> have no effect on Codidact.

On Codidact, the language to use for syntax highlighting can instead be defined by surrounding a code block in triple backticks and putting the language name immediately after the opening backticks, like this:

```python
def a():
    print("hi")
    return 1, 2
```

This is then rendered as coloured text on communities that support syntax highlighting such as Code Golf and Software Development. If testing this by editing, note that syntax highlighting is not currently activated here on Codidact Meta.

Should we also support HTML comment hints?

If anyone wants Codidact to support these HTML comment hints for syntax highlighting, I recommend raising a separate feature request here on Codidact Meta.

Should we link to guidance on using backticks?

Users accustomed to Stack Exchange may expect HTML comment hints to work for syntax highlighting. Should we have a separate warning message that appears when HTML comments are present and links to a guide to using backticks for syntax highlighting, so that people are not surprised that their HTML comment approach is not working?

This might be particularly useful because Codidact will guess the intended language when no language is specified using backticks, resulting in the appearance that HTML comments sometimes work (even though in reality this is just coincidence when Codidact guesses the same language).

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

Prior art for such comment hints? (6 comments)
Prior art for such comment hints?
Karl Knechtel‭ wrote 8 months ago

Are syntax highlighting comment hints actually a thing? I mean - is there prior art for them, like some other site that recognizes and uses them? I'm not aware of anything like that having an effect on Stack Exchange, for example. What actually is the underlying motivation for supporting them here, or indeed for suspecting that they might be supported?

trichoplax‭ wrote 8 months ago

The only place I've seen them used is on Stack Exchange. I don't know if my terminology is correct, but they are HTML comments that are recognised by Stack Exchange when rendering syntax highlighting.

trichoplax‭ wrote 8 months ago

On Stack Overflow they are probably used rarely as the language tag on a question will be used to determine the syntax highlighting for the question and its answers.

They are used commonly on Code Golf Stack Exchange, where it is common to have many answers each using a different programming language, so tags do not help.

trichoplax‭ wrote 8 months ago

The example I saw here was on Code Golf Codidact, where the online interpreter Try it online was used with its Stack Exchange output format, which uses HTML comments for syntax highlighting and 4 spaces of indentation for code blocks, rather than triple backticks.

trichoplax‭ wrote 8 months ago

My experience with Stack Exchange is several years out of date, and it sounds like this method of indicating language for syntax highlighting may be deprecated.

See What is syntax highlighting and how does it work?

It sounds like even on SE the backticks approach is preferred, but the HTML comment approach is still supported.

trichoplax‭ wrote 8 months ago

I'm not advocating introducing HTML comments on Codidact for syntax highlighting (hence that section of my question suggesting making that a separate feature request if anyone wants it).

My main reason for posting this question is to raise the general problem that the detection of unsupported HTML tags has false positives for HTML comments (whether related to syntax highlighting or not).