scdoc2mdoc

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

commit 7d6ea069526ea719872eb410ab17b503d56501f3
parent a3a853c548bca2f2513f49a6f04e3c953468fb6d
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 14 May 2018 18:42:32 -0400

Emit .RS 4 instead of .RS 4, remove extra RE

Fixes https://todo.sr.ht/~sircmpwn/scdoc/8

Diffstat:
Msrc/main.c | 7+++----
Atest/indent | 21+++++++++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -169,7 +169,7 @@ static int parse_indent(struct parser *p, int *indent, bool write) { roff_macro(p, "RE", NULL); } } else if (i == *indent + 1) { - roff_macro(p, "RS", "4", NULL); + fprintf(p->output, ".RS 4\n"); } else if (i != *indent && ch == '\t') { parser_fatal(p, "Indented by an amount greater than 1"); } @@ -179,7 +179,7 @@ static int parse_indent(struct parser *p, int *indent, bool write) { } static void list_header(struct parser *p, int *num) { - roff_macro(p, "RS", "4", NULL); + fprintf(p->output, ".RS 4\n"); fprintf(p->output, ".ie n \\{\\\n"); if (*num == -1) { fprintf(p->output, "\\h'-0%d'%s\\h'+03'\\c\n", @@ -252,7 +252,7 @@ static void parse_literal(struct parser *p, int *indent) { } int stops = 0; roff_macro(p, "nf", NULL); - roff_macro(p, "RS", "4", NULL); + fprintf(p->output, ".RS 4\n"); do { int _indent = *indent; parse_indent(p, &_indent, false); @@ -479,7 +479,6 @@ commit_table: roff_macro(p, "TE", NULL); fprintf(p->output, ".sp 1\n"); - roff_macro(p, "RE", NULL); } static void parse_document(struct parser *p) { diff --git a/test/indent b/test/indent @@ -0,0 +1,21 @@ +#!/bin/sh +. test/lib.sh + +begin "Indents indented text" +scdoc <<EOF | grep ".RS 4" >/dev/null +test(8) + +Not indented + Indented one level +EOF +end 0 + +begin "Deindents following indented text" +scdoc <<EOF | grep ".RE" >/dev/null +test(8) + +Not indented + Indented one level +Not indented +EOF +end 0