Skip to content

Markdown could use a better comment syntax #58

@benhourigan

Description

@benhourigan

Short version: Markdown could mark block and inline comments using the % character, rather than relying on HTML comments.

For example…

Block comment:

% This is a block comment. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pretium elementum eros, ac dignissim purus volutpat et. Integer eleifend.

Inline comment:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. %%Here is an inline comment.%% Pellentesque pretium elementum eros, ac dignissim purus volutpat et.


Explanation

Markdown could use a comment syntax that's more in line with the rest of the markup.

Most formatting in Markdown is created with just a single character at the beginning of a line (i.e. #, *, >) or a pair of characters (for *italic*, **bold**, etc.).

But the only way you can comment out text is by using HTML comments, which are comparatively much more difficult: <!-- Here is a comment --> There's a minimum of three characters on each side, at least two of which are different, and the start and end of the paired markers are different.

I use Markdown to collaborate with non-technical users on writing projects, and I've noticed that while these users get the hang of Markdown quickly, they almost always get comments wrong.

We already have CriticMarkup extending commenting, but it arguably suffers from the same problem: the markup is too complex for novice users to master quickly

What I'd propose is a single-character markup for comments that works for block and inline comments. The number one candidate, from my perspective, would be %, which is used to mark comments in LaTeX and also in the Markdown-inspired editor Ulysses.

It's possible that other characters might work better. Another candidate would be //, as used in JavaScript. Having to use /* */ would not be ideal as the beginning and end of the pair differ.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions