scdoc2mdoc

A fork of scdoc to output mdoc(7)
git clone git://git.sgregoratto.me/scdoc2mdoc
Log | Files | Refs | README | LICENSE

commit 9744a539ab8dd477b35577dc096a15a783e1f641
parent 5ee33091fbaa341b6c86fcf65d4069b6fcf02111
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 14 May 2018 18:34:11 -0400

Implement ; comments

Diffstat:
Mscdoc.1.scd | 8++++++++
Msrc/main.c | 8++++++++
Atest/comments | 22++++++++++++++++++++++
3 files changed, 38 insertions(+), 0 deletions(-)

diff --git 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 <sir@cmpwn.com>. Up-to-date sources can be found at diff --git 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 @@ -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