Skip to content

Add line comment syntax (%% to end of line)#384

Open
dereuromark wants to merge 1 commit into
jgm:mainfrom
dereuromark:line-comment-syntax
Open

Add line comment syntax (%% to end of line)#384
dereuromark wants to merge 1 commit into
jgm:mainfrom
dereuromark:line-comment-syntax

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Summary

Introduces a dedicated line comment syntax: %% extends to the end of the line and is ignored.

This is visible %% but this is a comment
%% This entire line is a comment
More visible text

To comment out multiple lines, mark each line:

%% These lines are
%% commented out
This line is not

Motivation

Addresses the limitations of attribute-based comments discussed in #67:

  • Visually obvious what's commented out, even without syntax highlighting
  • Works uniformly in inline and block contexts
  • No issues with blank lines breaking multi-line comments
  • Easy for editors to toggle (like Ctrl+/ in most IDEs)
  • Follows established pattern from LaTeX

The existing attribute comment syntax ({% ... %}) is preserved for adding comments within attributes.

Changes

  • doc/syntax.md: Added "Line comments" subsection under Comment, reorganized existing attribute comment docs
  • doc/cheatsheet.md: Updated comment examples to show both styles

Refs #67

Introduces a dedicated line comment syntax that extends from `%%`
to the end of the line. This addresses the limitations of attribute-based
comments discussed in jgm#67:

- Visually obvious what is commented out, even without highlighting
- Works uniformly in inline and block contexts
- No issues with blank lines breaking multi-line comments
- Follows established pattern from LaTeX

The existing attribute comment syntax (`{% ... %}`) is preserved
for adding comments within attributes.

Refs jgm#67
dereuromark added a commit to php-collective/djot-php that referenced this pull request Mar 16, 2026
Implements line comments that start with `%%` and extend to end of line:

- Inline: `Text before %% this is ignored`
- Full line: `%% This entire line is a comment`

Implementation:
- InlineParser: strips `%%` to end of line before parsing inline content
- BlockParser: handles full-line comments (lines starting with `%%`)

The existing comment syntaxes (`{% ... %}` and `%%%` fenced) are preserved.

Refs jgm/djot#67, jgm/djot#384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant