summaryrefslogtreecommitdiffstats
path: root/roff_html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-05-04 22:16:09 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-05-04 22:16:09 +0000
commit9ec7fd0e6d519550b4d3ae0ae9dd5c53d10e6cab (patch)
treeafaaee54c2f56b82235088f352b9382a1117f9d6 /roff_html.c
parent5fbabdf032b370e99e8685958b6e15eb3b2ff0f7 (diff)
downloadmandoc-9ec7fd0e6d519550b4d3ae0ae9dd5c53d10e6cab.tar.gz
Start roff formatter modules for HTML and termininal output,
used by both the mdoc and man formatters, with the ultimate goal of reducing code duplication between the two macro formatters. Made possible by the parser unification. Add the first formatting function (for the .br request).
Diffstat (limited to 'roff_html.c')
-rw-r--r--roff_html.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/roff_html.c b/roff_html.c
new file mode 100644
index 00000000..533fb9b7
--- /dev/null
+++ b/roff_html.c
@@ -0,0 +1,48 @@
+/* $OpenBSD$ */
+/*
+ * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <sys/types.h>
+
+#include <assert.h>
+
+#include "roff.h"
+#include "out.h"
+#include "html.h"
+
+#define ROFF_HTML_ARGS struct html *h, const struct roff_node *n
+
+typedef void (*roff_html_pre_fp)(ROFF_HTML_ARGS);
+
+static void roff_html_pre_br(ROFF_HTML_ARGS);
+
+static const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = {
+ roff_html_pre_br, /* br */
+};
+
+
+void
+roff_html_pre(struct html *h, const struct roff_node *n)
+{
+ assert(n->tok < ROFF_MAX);
+ (*roff_html_pre_acts[n->tok])(h, n);
+}
+
+static void
+roff_html_pre_br(ROFF_HTML_ARGS)
+{
+ print_otag(h, TAG_DIV, "");
+ print_text(h, "\\~"); /* So the div isn't empty. */
+}