summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-29 17:33:54 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-29 17:34:39 -0800
commit1bedbcee8a66eeb1d9dbaf172d237a1b8c84939a (patch)
tree99db0a9091bb0a5ee53a2c5adddc65348d0e8162
parentdc5345daad121be5ee38e673acd532e69d5f8e75 (diff)
Added very basic cmark.3 man page, added to install process.
This currently just contains a list of functions. It needs some accompanying text, commentary, examples. See #224.
-rw-r--r--Makefile5
-rw-r--r--man/CMakeLists.txt30
-rw-r--r--man/cmark.3.md190
-rw-r--r--man/man3/cmark.3211
4 files changed, 409 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index 2d9a483..8178455 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ all: $(BUILDDIR)
check:
@cmake --version > /dev/null || (echo "You need cmake to build this program: http://www.cmake.org/download/" && exit 1)
-$(BUILDDIR): check $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc man/man1/cmark.1
+$(BUILDDIR): check $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc man/man1/cmark.1 man/man3/cmark.3
mkdir -p $(BUILDDIR); \
cd $(BUILDDIR); \
cmake .. -G "$(GENERATOR)" -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
@@ -74,6 +74,9 @@ $(PROG): all
man/man1/cmark.1: man/cmark.1.md
mkdir -p man/man1 && pandoc -t man -s $< -o $@
+man/man3/cmark.3: man/cmark.3.md
+ mkdir -p man/man3 && pandoc -t man -s $< -o $@
+
apidoc: src/cmark.h
doxygen Doxyfile
diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt
index 4aba777..afb8711 100644
--- a/man/CMakeLists.txt
+++ b/man/CMakeLists.txt
@@ -1,27 +1,5 @@
-set(MANDEST ${CMAKE_CURRENT_BINARY_DIR})
-file(MAKE_DIRECTORY ${MANDEST}/man1)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man1/cmark.1
+ DESTINATION share/man/man1)
-add_custom_target(manpages ALL
- DEPENDS ${MANDEST}/man1/cmark.1
-)
-
-# This is a temporary fallback until we get a cmark-based
-# build procedure for the man pages:
-add_custom_command(OUTPUT ${MANDEST}/man1/cmark.1
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man1/cmark.1
- COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/man1/cmark.1
- ${MANDEST}/man1/cmark.1 VERBATIM
-)
-
-# add_custom_command(OUTPUT ${MANDEST}/man1/cmark.1
-# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmark.1.md
-# COMMAND pandoc "-s" "-t" "man"
-# ${CMAKE_CURRENT_SOURCE_DIR}/cmark.1.md
-# "-o" ${MANDEST}/man1/cmark.1
-# VERBATIM)
-
-INSTALL(FILES ${MANDEST}/man1/cmark.1 DESTINATION share/man/man1)
-
-# TODO: create cmark.3 man page.
-# file(MAKE_DIRECTORY ${MANDEST}/man3)
-# INSTALL(FILES ${MANDEST}/man3/cmark.3 DESTINATION share/man/man3)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man3/cmark.3
+ DESTINATION share/man/man3) \ No newline at end of file
diff --git a/man/cmark.3.md b/man/cmark.3.md
new file mode 100644
index 0000000..558974d
--- /dev/null
+++ b/man/cmark.3.md
@@ -0,0 +1,190 @@
+---
+title: cmark
+section: 3
+footer: libcmark manual
+date: November 29, 2014
+...
+
+# NAME
+
+cmark - parse, manipulate, and render CommonMark formatted text
+
+ #include <cmark.h>
+
+# SIMPLE INTERFACE
+
+ char*
+ cmark_markdown_to_html(const char *text, int len);
+
+# PARSING
+
+ void
+ cmark_parser_push(cmark_parser *parser, const char *buffer, size_t len);
+
+ cmark_node*
+ cmark_parse_document(const char *buffer, size_t len);
+
+ cmark_node*
+ cmark_parse_file(FILE *f);
+
+# RENDERING
+
+ char*
+ cmark_render_ast(cmark_node *root);
+
+ char*
+ cmark_render_html(cmark_node *root);
+
+# CREATING AND DESTROYING NODES
+
+ cmark_node*
+ cmark_node_new(cmark_node_type type);
+
+ void
+ cmark_node_free(cmark_node *node);
+
+# TREE TRAVERSAL
+
+ cmark_node*
+ cmark_node_next(cmark_node *node);
+
+ cmark_node*
+ cmark_node_previous(cmark_node *node);
+
+ cmark_node*
+ cmark_node_parent(cmark_node *node);
+
+ cmark_node*
+ cmark_node_first_child(cmark_node *node);
+
+ cmark_node*
+ cmark_node_last_child(cmark_node *node);
+
+# TREE MANIPULATION
+
+ void
+ cmark_node_unlink(cmark_node *node);
+
+ int
+ cmark_node_insert_before(cmark_node *node, cmark_node *sibling);
+
+ int
+ cmark_node_insert_after(cmark_node *node, cmark_node *sibling);
+
+ int
+ cmark_node_prepend_child(cmark_node *node, cmark_node *child);
+
+ int
+ cmark_node_append_child(cmark_node *node, cmark_node *child);
+
+# ACCESSORS
+
+ cmark_node_type
+ cmark_node_get_type(cmark_node *node);
+
+ const char*
+ cmark_node_get_string_content(cmark_node *node);
+
+ int
+ cmark_node_set_string_content(cmark_node *node, const char *content);
+
+ int
+ cmark_node_get_header_level(cmark_node *node);
+
+ int
+ cmark_node_set_header_level(cmark_node *node, int level);
+
+ cmark_list_type
+ cmark_node_get_list_type(cmark_node *node);
+
+ int
+ cmark_node_set_list_type(cmark_node *node, cmark_list_type type);
+
+ int
+ cmark_node_get_list_start(cmark_node *node);
+
+ int
+ cmark_node_set_list_start(cmark_node *node, int start);
+
+ int
+ cmark_node_get_list_tight(cmark_node *node);
+
+ int
+ cmark_node_set_list_tight(cmark_node *node, int tight);
+
+ const char*
+ cmark_node_get_fence_info(cmark_node *node);
+
+ int
+ cmark_node_set_fence_info(cmark_node *node, const char *info);
+
+ const char*
+ cmark_node_get_url(cmark_node *node);
+
+ int
+ cmark_node_set_url(cmark_node *node, const char *url);
+
+ const char*
+ cmark_node_get_title(cmark_node *node);
+
+ int
+ cmark_node_set_title(cmark_node *node, const char *title);
+
+ int
+ cmark_node_get_start_line(cmark_node *node);
+
+ int
+ cmark_node_get_start_column(cmark_node *node);
+
+ int
+ cmark_node_get_end_line(cmark_node *node);
+
+# DEFINITIONS
+
+ CMARK_VERSION
+
+ typedef enum {
+ // Block
+ CMARK_NODE_DOCUMENT,
+ CMARK_NODE_BLOCK_QUOTE,
+ CMARK_NODE_LIST,
+ CMARK_NODE_LIST_ITEM,
+ CMARK_NODE_CODE_BLOCK,
+ CMARK_NODE_HTML,
+ CMARK_NODE_PARAGRAPH,
+ CMARK_NODE_HEADER,
+ CMARK_NODE_HRULE,
+ CMARK_NODE_REFERENCE_DEF,
+
+ CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
+ CMARK_NODE_LAST_BLOCK = CMARK_NODE_REFERENCE_DEF,
+
+ // Inline
+ CMARK_NODE_TEXT,
+ CMARK_NODE_SOFTBREAK,
+ CMARK_NODE_LINEBREAK,
+ CMARK_NODE_INLINE_CODE,
+ CMARK_NODE_INLINE_HTML,
+ CMARK_NODE_EMPH,
+ CMARK_NODE_STRONG,
+ CMARK_NODE_LINK,
+ CMARK_NODE_IMAGE,
+
+ CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT,
+ CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
+ } cmark_node_type;
+
+ typedef enum {
+ CMARK_NO_LIST,
+ CMARK_BULLET_LIST,
+ CMARK_ORDERED_LIST
+ } cmark_list_type;
+
+ typedef enum {
+ CMARK_PERIOD_DELIM,
+ CMARK_PAREN_DELIM
+ } cmark_delim_type;
+
+# AUTHORS
+
+John MacFarlane
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
new file mode 100644
index 0000000..431e961
--- /dev/null
+++ b/man/man3/cmark.3
@@ -0,0 +1,211 @@
+.TH "cmark" "3" "November 29, 2014" "libcmark manual" ""
+.SH NAME
+.PP
+cmark \- parse, manipulate, and render CommonMark formatted text
+.IP
+.nf
+\f[C]
+#include\ <cmark.h>
+\f[]
+.fi
+.SH SIMPLE INTERFACE
+.IP
+.nf
+\f[C]
+char*
+cmark_markdown_to_html(const\ char\ *text,\ int\ len);
+\f[]
+.fi
+.SH PARSING
+.IP
+.nf
+\f[C]
+void
+cmark_parser_push(cmark_parser\ *parser,\ const\ char\ *buffer,\ size_t\ len);
+
+cmark_node*
+cmark_parse_document(const\ char\ *buffer,\ size_t\ len);
+
+cmark_node*
+cmark_parse_file(FILE\ *f);
+\f[]
+.fi
+.SH RENDERING
+.IP
+.nf
+\f[C]
+char*
+cmark_render_ast(cmark_node\ *root);
+
+char*
+cmark_render_html(cmark_node\ *root);
+\f[]
+.fi
+.SH CREATING AND DESTROYING NODES
+.IP
+.nf
+\f[C]
+cmark_node*
+cmark_node_new(cmark_node_type\ type);
+
+void
+cmark_node_free(cmark_node\ *node);
+\f[]
+.fi
+.SH TREE TRAVERSAL
+.IP
+.nf
+\f[C]
+cmark_node*
+cmark_node_next(cmark_node\ *node);
+
+cmark_node*
+cmark_node_previous(cmark_node\ *node);
+
+cmark_node*
+cmark_node_parent(cmark_node\ *node);
+
+cmark_node*
+cmark_node_first_child(cmark_node\ *node);
+
+cmark_node*
+cmark_node_last_child(cmark_node\ *node);
+\f[]
+.fi
+.SH TREE MANIPULATION
+.IP
+.nf
+\f[C]
+void
+cmark_node_unlink(cmark_node\ *node);
+
+int
+cmark_node_insert_before(cmark_node\ *node,\ cmark_node\ *sibling);
+
+int
+cmark_node_insert_after(cmark_node\ *node,\ cmark_node\ *sibling);
+
+int
+cmark_node_prepend_child(cmark_node\ *node,\ cmark_node\ *child);
+
+int
+cmark_node_append_child(cmark_node\ *node,\ cmark_node\ *child);
+\f[]
+.fi
+.SH ACCESSORS
+.IP
+.nf
+\f[C]
+cmark_node_type
+cmark_node_get_type(cmark_node\ *node);
+
+const\ char*
+cmark_node_get_string_content(cmark_node\ *node);
+
+int
+cmark_node_set_string_content(cmark_node\ *node,\ const\ char\ *content);
+
+int
+cmark_node_get_header_level(cmark_node\ *node);
+
+int
+cmark_node_set_header_level(cmark_node\ *node,\ int\ level);
+
+cmark_list_type
+cmark_node_get_list_type(cmark_node\ *node);
+
+int
+cmark_node_set_list_type(cmark_node\ *node,\ cmark_list_type\ type);
+
+int
+cmark_node_get_list_start(cmark_node\ *node);
+
+int
+cmark_node_set_list_start(cmark_node\ *node,\ int\ start);
+
+int
+cmark_node_get_list_tight(cmark_node\ *node);
+
+int
+cmark_node_set_list_tight(cmark_node\ *node,\ int\ tight);
+
+const\ char*
+cmark_node_get_fence_info(cmark_node\ *node);
+
+int
+cmark_node_set_fence_info(cmark_node\ *node,\ const\ char\ *info);
+
+const\ char*
+cmark_node_get_url(cmark_node\ *node);
+
+int
+cmark_node_set_url(cmark_node\ *node,\ const\ char\ *url);
+
+const\ char*
+cmark_node_get_title(cmark_node\ *node);
+
+int
+cmark_node_set_title(cmark_node\ *node,\ const\ char\ *title);
+
+int
+cmark_node_get_start_line(cmark_node\ *node);
+
+int
+cmark_node_get_start_column(cmark_node\ *node);
+
+int
+cmark_node_get_end_line(cmark_node\ *node);
+\f[]
+.fi
+.SH DEFINITIONS
+.IP
+.nf
+\f[C]
+CMARK_VERSION
+
+typedef\ enum\ {
+\ \ \ \ //\ Block
+\ \ \ \ CMARK_NODE_DOCUMENT,
+\ \ \ \ CMARK_NODE_BLOCK_QUOTE,
+\ \ \ \ CMARK_NODE_LIST,
+\ \ \ \ CMARK_NODE_LIST_ITEM,
+\ \ \ \ CMARK_NODE_CODE_BLOCK,
+\ \ \ \ CMARK_NODE_HTML,
+\ \ \ \ CMARK_NODE_PARAGRAPH,
+\ \ \ \ CMARK_NODE_HEADER,
+\ \ \ \ CMARK_NODE_HRULE,
+\ \ \ \ CMARK_NODE_REFERENCE_DEF,
+
+\ \ \ \ CMARK_NODE_FIRST_BLOCK\ =\ CMARK_NODE_DOCUMENT,
+\ \ \ \ CMARK_NODE_LAST_BLOCK\ \ =\ CMARK_NODE_REFERENCE_DEF,
+
+\ \ \ \ //\ Inline
+\ \ \ \ CMARK_NODE_TEXT,
+\ \ \ \ CMARK_NODE_SOFTBREAK,
+\ \ \ \ CMARK_NODE_LINEBREAK,
+\ \ \ \ CMARK_NODE_INLINE_CODE,
+\ \ \ \ CMARK_NODE_INLINE_HTML,
+\ \ \ \ CMARK_NODE_EMPH,
+\ \ \ \ CMARK_NODE_STRONG,
+\ \ \ \ CMARK_NODE_LINK,
+\ \ \ \ CMARK_NODE_IMAGE,
+
+\ \ \ \ CMARK_NODE_FIRST_INLINE\ =\ CMARK_NODE_TEXT,
+\ \ \ \ CMARK_NODE_LAST_INLINE\ \ =\ CMARK_NODE_IMAGE,
+}\ cmark_node_type;
+
+typedef\ enum\ {
+\ \ \ \ CMARK_NO_LIST,
+\ \ \ \ CMARK_BULLET_LIST,
+\ \ \ \ CMARK_ORDERED_LIST
+}\ \ cmark_list_type;
+
+typedef\ enum\ {
+\ \ \ \ CMARK_PERIOD_DELIM,
+\ \ \ \ CMARK_PAREN_DELIM
+}\ cmark_delim_type;
+\f[]
+.fi
+.SH AUTHORS
+.PP
+John MacFarlane