Skip to content

Commit

Permalink
Add --template debugging.
Browse files Browse the repository at this point in the history
This allows **-s -ttree** to see the template AST, which eases
debugging of complex templates.  It introduce an API change of
the tree interface needing to touch the lowdown options.

While here, considerably clean up the main manpages, introducing
a new section for metadata and cleaning up the standalone part.
This cleanup is due to the -s behaviour changes w/r/t the new
template functionality.
  • Loading branch information
kristapsdz committed Dec 15, 2024
1 parent 46c8118 commit d20f705
Show file tree
Hide file tree
Showing 12 changed files with 630 additions and 476 deletions.
6 changes: 4 additions & 2 deletions extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ struct hentry {
TAILQ_HEAD(hentryq, hentry);

struct lowdown_meta
*lowdown_get_meta(const struct lowdown_node *, struct lowdown_metaq *);
*lowdown_get_meta(const struct lowdown_node *,
struct lowdown_metaq *);
int lowdown_template(const char *, const struct lowdown_buf *,
struct lowdown_buf *, const struct lowdown_metaq *);
struct lowdown_buf *, const struct lowdown_metaq *,
int);

int smarty(struct lowdown_node *, size_t, enum lowdown_type);

Expand Down
2 changes: 1 addition & 1 deletion gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ lowdown_gemini_rndr(struct lowdown_buf *ob, void *arg,
goto out;
if (!rndr(tmp, &metaq, st, n))
goto out;
rc = lowdown_template(st->templ, tmp, ob, &metaq);
rc = lowdown_template(st->templ, tmp, ob, &metaq, 0);
} else
rc = rndr(ob, &metaq, st, n);

Expand Down
2 changes: 1 addition & 1 deletion html.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ rndr_root(struct lowdown_buf *ob, const struct lowdown_buf *content,
if (!(st->flags & LOWDOWN_STANDALONE))
return hbuf_putb(ob, content);
if (st->templ != NULL)
return lowdown_template(st->templ, content, ob, mq);
return lowdown_template(st->templ, content, ob, mq, 0);

TAILQ_FOREACH(m, mq, entries)
if (strcasecmp(m->key, "author") == 0)
Expand Down
2 changes: 1 addition & 1 deletion latex.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ rndr_root(const struct latex *st, struct lowdown_buf *ob,
if (!(st->oflags & LOWDOWN_STANDALONE))
return hbuf_putb(ob, content);
if (st->templ != NULL)
return lowdown_template(st->templ, content, ob, mq);
return lowdown_template(st->templ, content, ob, mq, 0);

TAILQ_FOREACH(m, mq, entries)
if (strcasecmp(m->key, "author") == 0)
Expand Down
2 changes: 1 addition & 1 deletion library.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ lowdown_render(const struct lowdown_opts *opts,
lowdown_term_free(rndr);
break;
case LOWDOWN_TREE:
c = lowdown_tree_rndr(ob, n);
c = lowdown_tree_rndr(ob, n, opts);
break;
default:
c = 1;
Expand Down
3 changes: 2 additions & 1 deletion lowdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ int lowdown_nroff_rndr(struct lowdown_buf *, void *,
const struct lowdown_node *);

int lowdown_tree_rndr(struct lowdown_buf *,
const struct lowdown_node *);
const struct lowdown_node *,
const struct lowdown_opts *);

void lowdown_latex_free(void *);
void *lowdown_latex_new(const struct lowdown_opts *);
Expand Down
Loading

0 comments on commit d20f705

Please sign in to comment.