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.

Syntax highlighting comments break the unsupported tags warning message

+3
−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 moderator attention?
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)

1 answer

+2
−0

Based on the comment discussion, I can see no reason to consider support for syntax highlight hinting via HTML comments. "Code fences" have a built-in syntax highlighting suggestion and are all around quite practical and standard: such "fenced code blocks" are part of the CommonMark standard, and overall easier to work with than "indented code blocks". They're also, for example, the recommended way to do it on the Python Discourse forum.

However, the warning about HTML comments definitely should be suppressed, IMO. First off, there's no good reason to treat comments as something that need to be "filtered out". For the most "important" Q&A - ones that are expected to be viewed the most often in the long run, or used to close many duplicates - they can offer important information for future editors about why a given detail was formatted in a specific way. (While some aspects of this might be better discussed in comments, surely this isn't universal.)

Second, it doesn't make sense to give the user a "warning" about HTML comments being stripped from the resulting post, because that would be expected anyway - the purpose of a comment is exactly to avoid actually changing anything while providing metadata. It's especially user-unfriendly to see <undefined> in the warning message - it's confusing, since the user didn't actually write a tag with that name; and it generally comes across as though the system encountered some problem while trying to format the message.

On the other hand, it probably doesn't matter if the system actually removes the HTML comments from the final rendered HTML. Just as long as it isn't treated like a cryptic and spurious error.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »