diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-04-01 17:22:56 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-04-01 17:22:56 +0000 |
| commit | 02299a79f1d552580bf7b660251f79ec7f479a23 (patch) | |
| tree | c23cc603f6acca910facef31a2b79c3794da5cab /bk_xhtml.c | |
| parent | af770784f1153b346a550363406c57b58d4c2552 (diff) | |
| download | halibut-02299a79f1d552580bf7b660251f79ec7f479a23.zip halibut-02299a79f1d552580bf7b660251f79ec7f479a23.tar.gz halibut-02299a79f1d552580bf7b660251f79ec7f479a23.tar.bz2 halibut-02299a79f1d552580bf7b660251f79ec7f479a23.tar.xz | |
Arrange a mechanism whereby each backend can be passed a filename
from its command-line option (`--text=foo.txt') and automatically
convert it into one or more notional \cfg directives. In the HTML
case this mechanism enables single-file mode as well as setting the
filename.
[originally from svn r4018]
Diffstat (limited to 'bk_xhtml.c')
| -rw-r--r-- | bk_xhtml.c | 53 |
1 files changed, 52 insertions, 1 deletions
@@ -39,7 +39,7 @@ * formatting directive, %% is a literal %). Formatting directives * are: * - * - %n is the section number, minus whitespace (`Chapter1.2'). + * - %n is the section type-plus-number, minus whitespace (`Chapter1.2'). * - %b is the section number on its own (`1.2'). * - %k is the section's _internal_ keyword. * - %N is the section's visible title in the output, again minus @@ -285,6 +285,57 @@ static xhtmlconfig xhtml_configure(paragraph *source) return ret; } +paragraph *xhtml_config_filename(char *filename) +{ + /* + * If the user passes in a single filename as a parameter to + * the `--html' command-line option, then we should assume it + * to imply _two_ config directives: + * \cfg{xhtml-single-filename}{whatever} and + * \cfg{xhtml-leaf-level}{0}; the rationale being that the user + * wants their output _in that file_. + */ + + paragraph *p[2]; + int i, len; + wchar_t *ufilename, *up; + + for (i = 0; i < 2; i++) { + p[i] = mknew(paragraph); + memset(p[i], 0, sizeof(*p[i])); + p[i]->type = para_Config; + p[i]->next = NULL; + p[i]->fpos.filename = "<command line>"; + p[i]->fpos.line = p[i]->fpos.col = -1; + } + + ufilename = ufroma_dup(filename); + len = ustrlen(ufilename) + 2 + lenof(L"xhtml-single-filename"); + p[0]->keyword = mknewa(wchar_t, len); + up = p[0]->keyword; + ustrcpy(up, L"xhtml-single-filename"); + up = uadv(up); + ustrcpy(up, ufilename); + up = uadv(up); + *up = L'\0'; + assert(up - p[0]->keyword < len); + sfree(ufilename); + + len = lenof(L"xhtml-leaf-level") + lenof(L"0") + 1; + p[1]->keyword = mknewa(wchar_t, len); + up = p[1]->keyword; + ustrcpy(up, L"xhtml-leaf-level"); + up = uadv(up); + ustrcpy(up, L"0"); + up = uadv(up); + *up = L'\0'; + assert(up - p[1]->keyword < len); + + p[0]->next = p[1]; + + return p[0]; +} + static xhtmlsection *xhtml_new_section(xhtmlsection *last) { xhtmlsection *ret = mknew(xhtmlsection); |