diff --git a/scdoc.1.scd b/scdoc.1.scd index 5dd124e..9f48596 100644 --- a/scdoc.1.scd +++ b/scdoc.1.scd @@ -169,6 +169,14 @@ literally in the man viewer - that is, it's not a means for inserting your own roff macros into the output. Note that \\ is still interpreted within literal blocks, which for example can be useful to output \``` inside of a literal block. +## COMMENTS + +Lines beginning with ; and a space are ignored. + +``` +; This is a comment +``` + # AUTHORS Maintained by Drew DeVault . Up-to-date sources can be found at diff --git a/src/main.c b/src/main.c index 1417986..2431eb1 100644 --- a/src/main.c +++ b/src/main.c @@ -491,6 +491,14 @@ static void parse_document(struct parser *p) { break; } switch (ch) { + case ';': + if ((ch = parser_getch(p)) != ' ') { + parser_fatal(p, "Expected space after ; to begin comment"); + } + do { + ch = parser_getch(p); + } while (ch != UTF8_INVALID && ch != '\n'); + break; case '#': if (indent != 0) { parser_pushch(p, ch); diff --git a/test/comments b/test/comments new file mode 100755 index 0000000..179ac40 --- /dev/null +++ b/test/comments @@ -0,0 +1,22 @@ +#!/bin/sh +. test/lib.sh + +begin "Ignore comments" +scdoc </dev/null +test(8) + +; this is a comment + +Hello world! +EOF +end 1 + +begin "Fail on invalid comments" +scdoc </dev/null +test(8) + +;this is an invalid comment + +Hello world! +EOF +end 1