diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-06-13 19:34:40 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-06-13 19:34:40 +0000 |
commit | 3352a8e9bd0f6a0666c5dcb84ccdb5536471d280 (patch) | |
tree | 7e1a05bb64c2b95a6e4932ee9443151fd48ff660 /man_macro.c | |
parent | a03895d16836ec105b7b21d6333f6b137f1d349e (diff) | |
download | mandoc-3352a8e9bd0f6a0666c5dcb84ccdb5536471d280.tar.gz mandoc-3352a8e9bd0f6a0666c5dcb84ccdb5536471d280.tar.zst mandoc-3352a8e9bd0f6a0666c5dcb84ccdb5536471d280.zip |
Partial support for the \n[an-margin] number register.
Manuals autogenerated from reStructuredText are reckless enough
to peek at this non-portable, implementation-dependent, highly
groff-specific internal register - for no good reason, because the
man(7) language natively provides in a much simpler way what they
are trying to emulate here with much fragility.
A full implementation would be very hard because it would require
access to output-device-specific formatting data at the roff(7)
preprocessor stage, which mandoc doesn't support at all.
So hardcode a few magic numbers as reStructuredText expects them
for terminal output. For other output modes (like HTML), code using
this register is utterly broken anyway.
Diffstat (limited to 'man_macro.c')
-rw-r--r-- | man_macro.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/man_macro.c b/man_macro.c index 22b2597d..3b6fce81 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.120 2017/05/05 15:17:32 schwarze Exp $ */ +/* $Id: man_macro.c,v 1.121 2017/06/13 19:34:40 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012-2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -235,6 +235,10 @@ blk_close(MACRO_PROT_ARGS) ntok = man->last->tok; man_unscope(man, nn); + if (tok == MAN_RE && nn->head->aux > 0) + roff_setreg(man->roff, "an-margin", + nn->head->aux, '-'); + /* Move a trailing paragraph behind the block. */ if (ntok == MAN_LP || ntok == MAN_PP || ntok == MAN_P) { @@ -256,8 +260,17 @@ blk_exp(MACRO_PROT_ARGS) head = roff_head_alloc(man, line, ppos, tok); la = *pos; - if (man_args(man, line, pos, buf, &p)) + if (man_args(man, line, pos, buf, &p)) { roff_word_alloc(man, line, la, p); + if (tok == MAN_RS) { + if (roff_getreg(man->roff, "an-margin") == 0) + roff_setreg(man->roff, "an-margin", + 7 * 24, '='); + if ((head->aux = strtod(p, NULL) * 24.0) > 0) + roff_setreg(man->roff, "an-margin", + head->aux, '+'); + } + } if (buf[*pos] != '\0') mandoc_vmsg(MANDOCERR_ARG_EXCESS, man->parse, line, |