/*
* To be done:
*
- * - index
- *
* - header/footer? Page numbers at least would be handy. Fully
* configurable footer can wait, though.
*
page_data *lastpage;
};
+enum {
+ word_PageXref = word_NotWordType + 1
+};
+
static font_data *make_std_font(font_list *fontlist, char const *name);
static void wrap_paragraph(para_data *pdata, word *words,
int w, int i1, int i2);
word *second);
static word *fake_word(wchar_t *text);
static word *fake_space_word(void);
+static word *fake_page_ref(page_data *page);
+static word *fake_end_ref(void);
static word *prepare_contents_title(word *first, wchar_t *separator,
word *second);
static void fold_into_page(page_data *dest, page_data *src, int right_shift);
case word_HyperEnd:
case word_UpperXref:
case word_LowerXref:
+ case word_PageXref:
case word_XrefEnd:
case word_IndexRef:
return 0;
case word_HyperLink:
case word_UpperXref:
case word_LowerXref:
+ case word_PageXref:
if (text->type == word_HyperLink) {
dest.type = URL;
dest.url = utoa_dup(text->text);
dest.page = NULL;
+ } else if (text->type == word_PageXref) {
+ dest.type = PAGE;
+ dest.url = NULL;
+ dest.page = (page_data *)text->private_data;
} else {
keyword *kwl = kw_lookup(keywords, text->text);
para_data *pdata;
* mention it once in the index.
*/
if (pi->lastpage != page) {
+ word **wp;
+
if (pi->lastword) {
pi->lastword = pi->lastword->next =
fake_word(L",");
pi->lastword = pi->lastword->next =
fake_space_word();
- pi->lastword = pi->lastword->next =
- fake_word(page->number);
- } else {
- pi->lastword = pi->words =
- fake_word(page->number);
- }
+ wp = &pi->lastword->next;
+ } else
+ wp = &pi->words;
+
+ pi->lastword = *wp =
+ fake_page_ref(page);
+ pi->lastword = pi->lastword->next =
+ fake_word(page->number);
+ pi->lastword = pi->lastword->next =
+ fake_end_ref();
}
pi->lastpage = page;
return ret;
}
+static word *fake_page_ref(page_data *page)
+{
+ word *ret = mknew(word);
+ ret->next = NULL;
+ ret->alt = NULL;
+ ret->type = word_PageXref;
+ ret->text = NULL;
+ ret->breaks = FALSE;
+ ret->aux = 0;
+ ret->private_data = page;
+ return ret;
+}
+
+static word *fake_end_ref(void)
+{
+ word *ret = mknew(word);
+ ret->next = NULL;
+ ret->alt = NULL;
+ ret->type = word_XrefEnd;
+ ret->text = NULL;
+ ret->breaks = FALSE;
+ ret->aux = 0;
+ return ret;
+}
+
static word *prepare_contents_title(word *first, wchar_t *separator,
word *second)
{
para_LcontPop, /* end continuation of list item */
para_QuotePush, /* begin block quote */
para_QuotePop, /* end block quote */
+ /*
+ * Back ends may define their own paragraph types beyond here,
+ * in case they need to use them internally.
+ */
para_NotParaType /* placeholder value */
};
word_XrefEnd, /* (invisible; no text) */
word_IndexRef, /* (always an invisible one) */
word_HyperLink, /* (invisible) */
- word_HyperEnd /* (also invisible; no text) */
+ word_HyperEnd, /* (also invisible; no text) */
+ /*
+ * Back ends may define their own word types beyond here, in
+ * case they need to use them internally.
+ */
+ word_NotWordType /* placeholder value */
};
/* aux values for attributed words */
enum {