From 37727cf9cf399f80d8be6994f154256ac09dcfea Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 24 Nov 2001 17:50:55 +0000 Subject: Introduce the ability to relabel a section as an `example' or `question' or so on, using the syntax \S{mysection}{example} An example of foobar so that in cross-references it will be referred to as `example 5.1.2' instead of `section 5.1.2'. NOTE WELL: until now Buttress has supported multiple section keywords using the same syntax, so that you could xref the above section as \k{mysection} _or_ \k{example} with the same effect. This behaviour is now revoked because I don't think anyone was using it; if you suddenly find you're getting undefined-keyword errors this may be why. [originally from svn r1408] --- keywords.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'keywords.c') diff --git a/keywords.c b/keywords.c index b401690..26580f8 100644 --- a/keywords.c +++ b/keywords.c @@ -99,25 +99,34 @@ keywordlist *get_keywords(paragraph *source) { kl->nlooseends = kl->looseendssize = 0; kl->looseends = NULL; for (; source; source = source->next) { + wchar_t *p, *q; + p = q = source->keyword; + + /* + * Look for the section type override (`example', + * `question' or whatever - to replace `chapter' or + * `section' on a per-section basis). + */ + if (q) { + q = uadv(q); /* point q at the word beyond */ + if (!*q) q = NULL; + } + /* * Number the chapter / section / list-item / whatever. */ - source->kwtext = number_mktext(n, source->type, source->aux, + source->kwtext = number_mktext(n, source->type, source->aux, q, prevpara, &source->kwtext2, source->fpos, &errors); prevpara = source->type; - if (source->keyword && *source->keyword) { + if (p && *p) { if (source->kwtext || source->type == para_Biblio) { - wchar_t *p = source->keyword; - while (*p) { - keyword *kw = mknew(keyword); - kw->key = p; - kw->text = source->kwtext; - kw->para = source; - heap_add(kl, kw); - p = uadv(p); - } + keyword *kw = mknew(keyword); + kw->key = p; + kw->text = source->kwtext; + kw->para = source; + heap_add(kl, kw); } } else { if (kl->nlooseends >= kl->looseendssize) { -- cgit v1.1