diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-03-23 20:10:23 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-03-23 20:10:23 +0000 |
| commit | 6cba4fa3f6c02db9994d6b6234f2ae5007839a5d (patch) | |
| tree | a713c55ba681e428d4770a8c5172982d25a89208 /bk_text.c | |
| parent | 6576379028db35e575cb6c855396706bad363521 (diff) | |
| download | halibut-6cba4fa3f6c02db9994d6b6234f2ae5007839a5d.zip halibut-6cba4fa3f6c02db9994d6b6234f2ae5007839a5d.tar.gz halibut-6cba4fa3f6c02db9994d6b6234f2ae5007839a5d.tar.bz2 halibut-6cba4fa3f6c02db9994d6b6234f2ae5007839a5d.tar.xz | |
Man-page back end for Halibut. Also, a couple of additional markup
features commonly used in man pages: (a) the ability to nest
paragraph breaks, code paragraphs and other lists inside list items,
and (b) description lists as normally used in man pages to describe
command-line options.
[originally from svn r3954]
Diffstat (limited to 'bk_text.c')
| -rw-r--r-- | bk_text.c | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -182,6 +182,7 @@ void text_backend(paragraph *sourceform, keywordlist *keywords, word spaceword; FILE *fp; char *prefixextra; + int nesting, nestindent; int indentb, indenta; IGNORE(keywords); /* we don't happen to need this */ @@ -219,9 +220,20 @@ void text_backend(paragraph *sourceform, keywordlist *keywords, conf.indent_preambles ? conf.indent : 0, 0, conf.width + (conf.indent_preambles ? 0 : conf.indent)); + nestindent = conf.listindentbefore + conf.listindentafter; + nesting = 0; + /* Do the main document */ for (p = sourceform; p; p = p->next) switch (p->type) { + case para_LcontPush: + nesting++; + break; + case para_LcontPop: + assert(nesting > 0); + nesting--; + break; + /* * Things we ignore because we've already processed them or * aren't going to touch them in this pass. @@ -254,10 +266,13 @@ void text_backend(paragraph *sourceform, keywordlist *keywords, break; case para_Rule: - text_rule(fp, conf.indent, conf.width); + text_rule(fp, conf.indent + nestindent*nesting, + conf.width - nestindent*nesting); break; case para_Normal: + case para_DescribedThing: + case para_Description: case para_BiblioCited: case para_Bullet: case para_NumberedList: @@ -271,6 +286,11 @@ void text_backend(paragraph *sourceform, keywordlist *keywords, prefixextra = "."; /* FIXME: configurability */ indentb = conf.listindentbefore; indenta = conf.listindentafter; + } else if (p->type == para_Description) { + prefix = NULL; + prefixextra = NULL; + indentb = conf.listindentbefore; + indenta = conf.listindentafter; } else { prefix = NULL; prefixextra = NULL; @@ -289,8 +309,8 @@ void text_backend(paragraph *sourceform, keywordlist *keywords, body = p->words; } text_para(fp, prefix, prefixextra, body, - conf.indent + indentb, indenta, - conf.width - indentb - indenta); + conf.indent + nestindent*nesting + indentb, indenta, + conf.width - nestindent*nesting - indentb - indenta); if (wp) { wp->next = NULL; free_word_list(body); @@ -298,7 +318,9 @@ void text_backend(paragraph *sourceform, keywordlist *keywords, break; case para_Code: - text_codepara(fp, p->words, conf.indent + conf.indent_code, conf.width - 2 * conf.indent_code); + text_codepara(fp, p->words, + conf.indent + nestindent*nesting + conf.indent_code, + conf.width - nestindent*nesting - 2 * conf.indent_code); break; } |