summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-12-22 23:21:31 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-12-22 23:21:31 -0800
commit56cd911ac2339a8ef80543780325a31e783f8c03 (patch)
tree7871787d66265975fee5a4545a8fd56eaf24d9ff
parent4811dc3ec2330f015444ac6f5ee4f8cbf3563808 (diff)
Separate parsing and rendering opts in cmark.h.
This change also changes some of these constants' numerical values, but nothing should change in the API if you use the constants themselves. It should now be clear in the man page which options affect parsing and which affect rendering. Closes #88.
-rw-r--r--man/man3/cmark.339
-rw-r--r--src/cmark.h40
2 files changed, 50 insertions, 29 deletions
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
index b6b1206..d5532d5 100644
--- a/man/man3/cmark.3
+++ b/man/man3/cmark.3
@@ -528,6 +528,9 @@ Render a \f[I]node\f[] tree as a commonmark document.
.PP
Render a \f[I]node\f[] tree as a LaTeX document.
+.SS
+Options
+
.PP
.nf
\fC
@@ -538,13 +541,16 @@ Render a \f[I]node\f[] tree as a LaTeX document.
.fi
.PP
-Default writer options.
+Default options.
+
+.SS
+Options affecting rendering
.PP
.nf
\fC
.RS 0n
-#define CMARK_OPT_SOURCEPOS 1
+#define CMARK_OPT_SOURCEPOS 1 << 1
.RE
\f[]
.fi
@@ -556,7 +562,7 @@ Include a \f[C]data\-sourcepos\f[] attribute on all block elements.
.nf
\fC
.RS 0n
-#define CMARK_OPT_HARDBREAKS 2
+#define CMARK_OPT_HARDBREAKS 1 << 2
.RE
\f[]
.fi
@@ -568,32 +574,38 @@ Render \f[C]softbreak\f[] elements as hard line breaks.
.nf
\fC
.RS 0n
-#define CMARK_OPT_NORMALIZE 4
+#define CMARK_OPT_SAFE 1 << 3
.RE
\f[]
.fi
.PP
-Normalize tree by consolidating adjacent text nodes.
+Suppress raw HTML and unsafe links (\f[C]javascript:\f[],
+\f[C]vbscript:\f[], \f[C]file:\f[], and \f[C]data:\f[], except for
+\f[C]image/png\f[], \f[C]image/gif\f[], \f[C]image/jpeg\f[], or
+\f[C]image/webp\f[] mime types). Raw HTML is replaced by a placeholder
+HTML comment. Unsafe links are replaced by empty strings.
+
+.SS
+Options affecting parsing
.PP
.nf
\fC
.RS 0n
-#define CMARK_OPT_SMART 8
+#define CMARK_OPT_NORMALIZE 1 << 8
.RE
\f[]
.fi
.PP
-Convert straight quotes to curly, \-\-\- to em dashes, \-\- to en
-dashes.
+Normalize tree by consolidating adjacent text nodes.
.PP
.nf
\fC
.RS 0n
-#define CMARK_OPT_VALIDATE_UTF8 16
+#define CMARK_OPT_VALIDATE_UTF8 1 << 9
.RE
\f[]
.fi
@@ -606,17 +618,14 @@ with the replacement character U+FFFD.
.nf
\fC
.RS 0n
-#define CMARK_OPT_SAFE 32
+#define CMARK_OPT_SMART 1 << 10
.RE
\f[]
.fi
.PP
-Suppress raw HTML and unsafe links (\f[C]javascript:\f[],
-\f[C]vbscript:\f[], \f[C]file:\f[], and \f[C]data:\f[], except for
-\f[C]image/png\f[], \f[C]image/gif\f[], \f[C]image/jpeg\f[], or
-\f[C]image/webp\f[] mime types). Raw HTML is replaced by a placeholder
-HTML comment. Unsafe links are replaced by empty strings.
+Convert straight quotes to curly, \-\-\- to em dashes, \-\- to en
+dashes.
.SS
Version information
diff --git a/src/cmark.h b/src/cmark.h
index 0200410..c48fa9a 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -483,38 +483,50 @@ char *cmark_render_commonmark(cmark_node *root, int options, int width);
CMARK_EXPORT
char *cmark_render_latex(cmark_node *root, int options, int width);
-/** Default writer options.
+/**
+ * ## Options
+ */
+
+/** Default options.
*/
#define CMARK_OPT_DEFAULT 0
+/**
+ * ### Options affecting rendering
+ */
+
/** Include a `data-sourcepos` attribute on all block elements.
*/
-#define CMARK_OPT_SOURCEPOS 1
+#define CMARK_OPT_SOURCEPOS 1 << 1
/** Render `softbreak` elements as hard line breaks.
*/
-#define CMARK_OPT_HARDBREAKS 2
+#define CMARK_OPT_HARDBREAKS 1 << 2
-/** Normalize tree by consolidating adjacent text nodes.
+/** Suppress raw HTML and unsafe links (`javascript:`, `vbscript:`,
+ * `file:`, and `data:`, except for `image/png`, `image/gif`,
+ * `image/jpeg`, or `image/webp` mime types). Raw HTML is replaced
+ * by a placeholder HTML comment. Unsafe links are replaced by
+ * empty strings.
*/
-#define CMARK_OPT_NORMALIZE 4
+#define CMARK_OPT_SAFE 1 << 3
-/** Convert straight quotes to curly, --- to em dashes, -- to en dashes.
+/**
+ * ### Options affecting parsing
+ */
+
+/** Normalize tree by consolidating adjacent text nodes.
*/
-#define CMARK_OPT_SMART 8
+#define CMARK_OPT_NORMALIZE 1 << 8
/** Validate UTF-8 in the input before parsing, replacing illegal
* sequences with the replacement character U+FFFD.
*/
-#define CMARK_OPT_VALIDATE_UTF8 16
+#define CMARK_OPT_VALIDATE_UTF8 1 << 9
-/** Suppress raw HTML and unsafe links (`javascript:`, `vbscript:`,
- * `file:`, and `data:`, except for `image/png`, `image/gif`,
- * `image/jpeg`, or `image/webp` mime types). Raw HTML is replaced
- * by a placeholder HTML comment. Unsafe links are replaced by
- * empty strings.
+/** Convert straight quotes to curly, --- to em dashes, -- to en dashes.
*/
-#define CMARK_OPT_SAFE 32
+#define CMARK_OPT_SMART 1 << 10
/**
* ## Version information