# Patch managed by http://www.holgerschurig.de/patcher.html
# This patch is against htmldoc 1.8.24, and it hacks in support for
# correctly indenting the <div class=""> sections in the SWIG manual.
# This patch should only be used until the 1.9 branch of htmldoc
# stabalizes, since the 1.9 branch includes true CSS1 support.
# This patch only affects the PDF generation, an unpatched htmldoc
# creates the one-page html documentation just fine.
--- htmldoc-1.8.24/htmldoc/ps-pdf.cxx~margin-left
+++ htmldoc-1.8.24/htmldoc/ps-pdf.cxx
+extern int lookup_div_class(uchar *);
para->child = para->last_child = NULL;
- parse_doc(t->child, left, right, bottom, top, x, y, page, NULL,
+ if (cname = htmlGetVariable(t, (uchar *)"class")) {
+ num_indent = lookup_div_class(cname);
+ *left += 5.0f * num_indent;
+ parse_doc(t->child, left, right, bottom, top, x, y, page, NULL,
+ *left -= 5.0f * num_indent;
parse_paragraph(para, *left, *right, *bottom, *top, x, y, page, *needspace);
--- htmldoc-1.8.24/htmldoc/htmldoc.cxx~margin-left
+++ htmldoc-1.8.24/htmldoc/htmldoc.cxx
const char *__XOS2RedirRoot(const char *);
+extern void parse_style(char *);
else if (strcmp(temp, "--cookies") == 0)
+ else if (strcmp(temp, "--stylesheet") == 0)
+++ htmldoc-1.8.24/htmldoc/style.cxx
+/* Extreamly simple parsing routines for CSS style sheets.
+ * We only parse div.class { } sections, and only look
+ * for margin-left: <num>em;
+ * Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu>
+ * Released under GNU GPL v2 or above.
+ uchar class_name[BUFF_SIZE];
+ struct div_entry *next;
+static struct div_entry *head = 0;
+/* These are the parsing states */
+#define IGNORE_TILL_SEMI 0
+#define IGNORE_TILL_CLOSE_BRACE 1
+#define READING_ATTRIBUTE 4
+#define CHECKING_ONLY_DIV 6
+static int strucmp(uchar *a, uchar *b) {
+ for (i = 0; a[i] && b[i]; i++) {
+ if (a[i] < b[i]) return -1;
+ if (a[i] > b[i]) return 1;
+ /* This isn't right, but who cares...*/
+ if (a[i] || b[i]) return 1;
+static int read_word(FILE *f, const char *word) {
+ for (int idx = 0; word[idx]; idx++) {
+int lookup_div_class(uchar *name) {
+ struct div_entry *node = head;
+ if (strucmp(node->class_name, name) == 0)
+void parse_style(char *fname) {
+ struct div_entry *cur = 0;
+ fprintf(stderr, "Unable to parse style\n");
+ while (!at_eof && (c = getc(f)) != EOF) {
+ state = READING_ATTRIBUTE;
+ case IGNORE_TILL_CLOSE_BRACE:
+ if (c != ' ' && c != '\t' && c != '\n') {
+ if (c == 'd' && read_word(f, "iv.")) {
+ cur = (struct div_entry *) malloc(sizeof(struct div_entry));
+ memset(cur, 0, sizeof(struct div_entry));
+ state = IGNORE_TILL_CLOSE_BRACE;
+ if (class_idx >= BUFF_SIZE-1) {
+ fprintf(stderr, "class size %s too long\n", cur->class_name);
+ state = IGNORE_TILL_CLOSE_BRACE;
+ cur->class_name[class_idx++] = c;
+ state = READING_ATTRIBUTE;
+ state = CHECKING_ONLY_DIV;
+ case READING_ATTRIBUTE:
+ if (c != ' ' && c != '\t' && c != '\n') {
+ if (c == 'm' && read_word(f, "argin-left:")) {
+ memset(num, 0, sizeof(num));
+ state = IGNORE_TILL_SEMI;
+ if (num_idx >= BUFF_SIZE - 1) {
+ fprintf(stderr, "Number too long\n");
+ state = IGNORE_TILL_SEMI;
+ } else if (c != ' ' && c != '\t') {
+ if (num_idx > 0 && c == 'e' && read_word(f, "m"))
+ cur->indent = atoi(num);
+ state = IGNORE_TILL_SEMI;
+ case CHECKING_ONLY_DIV:
+ if (c != ' ' && c != '\t' && c != '\n') {
+ state = READING_ATTRIBUTE;
+ state = IGNORE_TILL_CLOSE_BRACE;
--- htmldoc-1.8.24/htmldoc/Makefile~margin-left
+++ htmldoc-1.8.24/htmldoc/Makefile
OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o http.o \
http-addr.o http-support.o image.o iso8859.o license.o md5.o \
- progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o
+ progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o style.o