summaryrefslogtreecommitdiff
path: root/bk_text.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2008-02-25 19:36:12 +0000
committerSimon Tatham <anakin@pobox.com>2008-02-25 19:36:12 +0000
commit0d791fb645abb77b339d90c95882ef315d1f912c (patch)
tree044b4b867dd171935db1c0a14981de1a9d714221 /bk_text.c
parent5527360cf7e5b68a1954874c82128690ed7df488 (diff)
downloadhalibut-0d791fb645abb77b339d90c95882ef315d1f912c.zip
halibut-0d791fb645abb77b339d90c95882ef315d1f912c.tar.gz
halibut-0d791fb645abb77b339d90c95882ef315d1f912c.tar.bz2
halibut-0d791fb645abb77b339d90c95882ef315d1f912c.tar.xz
New option *-section-shownumber, alongside *-section-numeric and in
both the back ends which currently support that, to leave out chapter and section numbers totally in section headings. Can be useful for publishing man pages (which don't normally want section numbers) on the web. [originally from svn r7892]
Diffstat (limited to 'bk_text.c')
-rw-r--r--bk_text.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/bk_text.c b/bk_text.c
index 6df426e..1a1796e 100644
--- a/bk_text.c
+++ b/bk_text.c
@@ -10,7 +10,7 @@
typedef enum { LEFT, LEFTPLUS, CENTRE } alignment;
typedef struct {
alignment align;
- int just_numbers;
+ int number_at_all, just_numbers;
wchar_t *underline;
wchar_t *number_suffix;
} alignstruct;
@@ -67,6 +67,7 @@ static textconfig text_configure(paragraph *source) {
ret.bullet.alt = NULL;
ret.bullet.type = word_Normal;
ret.atitle.just_numbers = FALSE; /* ignored */
+ ret.atitle.number_at_all = TRUE; /* ignored */
/*
* Defaults.
@@ -80,12 +81,14 @@ static textconfig text_configure(paragraph *source) {
ret.atitle.underline = L"\x2550\0=\0\0";
ret.achapter.align = LEFT;
ret.achapter.just_numbers = FALSE;
+ ret.achapter.number_at_all = TRUE;
ret.achapter.number_suffix = L": ";
ret.achapter.underline = L"\x203E\0-\0\0";
ret.nasect = 1;
ret.asect = snewn(ret.nasect, alignstruct);
ret.asect[0].align = LEFTPLUS;
ret.asect[0].just_numbers = TRUE;
+ ret.asect[0].number_at_all = TRUE;
ret.asect[0].number_suffix = L" ";
ret.asect[0].underline = L"\0";
ret.include_version_id = TRUE;
@@ -144,6 +147,8 @@ static textconfig text_configure(paragraph *source) {
ret.achapter.underline = uadv(p->keyword);
} else if (!ustricmp(p->keyword, L"text-chapter-numeric")) {
ret.achapter.just_numbers = utob(uadv(p->keyword));
+ } else if (!ustricmp(p->keyword, L"text-chapter-shownumber")) {
+ ret.achapter.number_at_all = utob(uadv(p->keyword));
} else if (!ustricmp(p->keyword, L"text-chapter-suffix")) {
ret.achapter.number_suffix = uadv(p->keyword);
} else if (!ustricmp(p->keyword, L"text-section-align")) {
@@ -191,6 +196,21 @@ static textconfig text_configure(paragraph *source) {
ret.nasect = n+1;
}
ret.asect[n].just_numbers = utob(q);
+ } else if (!ustricmp(p->keyword, L"text-section-shownumber")) {
+ wchar_t *q = uadv(p->keyword);
+ int n = 0;
+ if (uisdigit(*q)) {
+ n = utoi(q);
+ q = uadv(q);
+ }
+ if (n >= ret.nasect) {
+ int i;
+ ret.asect = sresize(ret.asect, n+1, alignstruct);
+ for (i = ret.nasect; i <= n; i++)
+ ret.asect[i] = ret.asect[ret.nasect-1];
+ ret.nasect = n+1;
+ }
+ ret.asect[n].number_at_all = utob(q);
} else if (!ustricmp(p->keyword, L"text-section-suffix")) {
wchar_t *q = uadv(p->keyword);
int n = 0;
@@ -615,12 +635,14 @@ static void text_heading(textfile *tf, word *tprefix, word *nprefix,
int firstlinewidth, wrapwidth;
wrappedline *wrapping, *p;
- if (align.just_numbers && nprefix) {
- text_rdaddw(&t, nprefix, NULL, cfg);
- rdadds(&t, align.number_suffix);
- } else if (!align.just_numbers && tprefix) {
- text_rdaddw(&t, tprefix, NULL, cfg);
- rdadds(&t, align.number_suffix);
+ if (align.number_at_all) {
+ if (align.just_numbers && nprefix) {
+ text_rdaddw(&t, nprefix, NULL, cfg);
+ rdadds(&t, align.number_suffix);
+ } else if (!align.just_numbers && tprefix) {
+ text_rdaddw(&t, tprefix, NULL, cfg);
+ rdadds(&t, align.number_suffix);
+ }
}
margin = length = ustrwid(t.text ? t.text : L"", cfg->charset);