Implement ; comments

master
Drew DeVault 7 years ago
parent 5ee33091fb
commit 9744a539ab
  1. 8
      scdoc.1.scd
  2. 8
      src/main.c
  3. 22
      test/comments

@ -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 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. 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 # AUTHORS
Maintained by Drew DeVault <sir@cmpwn.com>. Up-to-date sources can be found at Maintained by Drew DeVault <sir@cmpwn.com>. Up-to-date sources can be found at

@ -491,6 +491,14 @@ static void parse_document(struct parser *p) {
break; break;
} }
switch (ch) { 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 '#': case '#':
if (indent != 0) { if (indent != 0) {
parser_pushch(p, ch); parser_pushch(p, ch);

@ -0,0 +1,22 @@
#!/bin/sh
. test/lib.sh
begin "Ignore comments"
scdoc <<EOF | grep "this is a comment" >/dev/null
test(8)
; this is a comment
Hello world!
EOF
end 1
begin "Fail on invalid comments"
scdoc <<EOF >/dev/null
test(8)
;this is an invalid comment
Hello world!
EOF
end 1
Loading…
Cancel
Save