Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #100 from FSX/master

Do not nest the fist list in a table of contents.
  • Loading branch information...
commit cd77aea761bec00bfcf53b91c4d7c10b0a4fa7a9 2 parents 12cdf8e + fa0bd49
@vmg vmg authored
Showing with 7 additions and 1 deletion.
  1. +6 −1 html/html.c
  2. +1 −0  html/html.h
View
7 html/html.c
@@ -491,6 +491,11 @@ toc_header(struct buf *ob, const struct buf *text, int level, void *opaque)
{
struct html_renderopt *options = opaque;
+ if (options->toc_data.header_count == 0) {
+ options->toc_data.level_offset = level - 1;
+ }
+ level -= options->toc_data.level_offset;
+
if (level > options->toc_data.current_level) {
while (level > options->toc_data.current_level) {
BUFPUTSL(ob, "<ul>\n<li>\n");
@@ -516,7 +521,7 @@ toc_header(struct buf *ob, const struct buf *text, int level, void *opaque)
static int
toc_link(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *content, void *opaque)
{
- if (content && content->size)
+ if (content && content->size)
bufput(ob, content->data, content->size);
return 1;
}
View
1  html/html.h
@@ -25,6 +25,7 @@ struct html_renderopt {
struct {
int header_count;
int current_level;
+ int level_offset;
} toc_data;
unsigned int flags;
Please sign in to comment.
Something went wrong with that request. Please try again.