summaryrefslogtreecommitdiff
path: root/bk_whlp.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-03-23 20:10:23 +0000
committerSimon Tatham <anakin@pobox.com>2004-03-23 20:10:23 +0000
commit6cba4fa3f6c02db9994d6b6234f2ae5007839a5d (patch)
treea713c55ba681e428d4770a8c5172982d25a89208 /bk_whlp.c
parent6576379028db35e575cb6c855396706bad363521 (diff)
downloadhalibut-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 '')
-rw-r--r--bk_whlp.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/bk_whlp.c b/bk_whlp.c
index f4b1b2d..a21ac04 100644
--- a/bk_whlp.c
+++ b/bk_whlp.c
@@ -50,6 +50,7 @@ void whlp_backend(paragraph *sourceform, keywordlist *keywords,
struct bk_whlp_state state;
WHLP_TOPIC contents_topic;
int i;
+ int nesting;
indexentry *ie;
filename = "output.hlp"; /* FIXME: configurability */
@@ -216,6 +217,7 @@ void whlp_backend(paragraph *sourceform, keywordlist *keywords,
* Now we've done the contents page, we're ready to go through
* and do the main manual text. Ooh.
*/
+ nesting = 0;
for (p = sourceform; p; p = p->next) switch (p->type) {
/*
* Things we ignore because we've already processed them or
@@ -231,6 +233,14 @@ void whlp_backend(paragraph *sourceform, keywordlist *keywords,
case para_Title:
break;
+ case para_LcontPush:
+ nesting++;
+ break;
+ case para_LcontPop:
+ assert(nesting > 0);
+ nesting--;
+ break;
+
/*
* Chapter and section titles: start a new Help topic.
*/
@@ -343,12 +353,14 @@ void whlp_backend(paragraph *sourceform, keywordlist *keywords,
break;
case para_Normal:
+ case para_DescribedThing:
+ case para_Description:
case para_BiblioCited:
case para_Bullet:
case para_NumberedList:
whlp_para_attr(h, WHLP_PARA_SPACEBELOW, 12);
if (p->type == para_Bullet || p->type == para_NumberedList) {
- whlp_para_attr(h, WHLP_PARA_LEFTINDENT, 72);
+ whlp_para_attr(h, WHLP_PARA_LEFTINDENT, 72*nesting + 72);
whlp_para_attr(h, WHLP_PARA_FIRSTLINEINDENT, -36);
whlp_set_tabstop(h, 72, WHLP_ALIGN_LEFT);
whlp_begin_para(h, WHLP_PARA_SCROLL);
@@ -361,6 +373,8 @@ void whlp_backend(paragraph *sourceform, keywordlist *keywords,
}
whlp_tab(h);
} else {
+ whlp_para_attr(h, WHLP_PARA_LEFTINDENT,
+ 72*nesting + (p->type==para_Description ? 72 : 0));
whlp_begin_para(h, WHLP_PARA_SCROLL);
}
@@ -386,6 +400,7 @@ void whlp_backend(paragraph *sourceform, keywordlist *keywords,
for (w = p->words; w; w = w->next) {
if (!w->next)
whlp_para_attr(h, WHLP_PARA_SPACEBELOW, 12);
+ whlp_para_attr(h, WHLP_PARA_LEFTINDENT, 72*nesting);
whlp_begin_para(h, WHLP_PARA_SCROLL);
whlp_set_font(h, FONT_CODE);
whlp_convert(w->text, &c, FALSE);