summaryrefslogtreecommitdiff
path: root/src/xml.c
AgeCommit message (Collapse)Author
2020-08-23Add MAX_INDENT for xml.John MacFarlane
Otherwise we can get quadratic increase in size with deeply nested structures. See #355.
2020-06-24Fix handling of empty strings when creating XML/HTML output.Steffen Kieß
2020-01-23Rearrange struct cmark_nodeNick Wellnhofer
Introduce multi-purpose data/len members in struct cmark_node. This is mainly used to store literal text for inlines, code and HTML blocks. Move the content strbuf for blocks from cmark_node to cmark_parser. When finalizing nodes that allow inlines (paragraphs and headings), detach the strbuf and store the block content in the node's data/len members. Free the block content after processing inlines. Reduces size of struct cmark_node by 8 bytes.
2020-01-23Use C string instead of chunk for custom block contentsNick Wellnhofer
Reduces size of struct cmark_node by 8 bytes.
2020-01-23Use C string instead of chunk for link URL and titleNick Wellnhofer
Use zero-terminated C strings instead of cmark_chunks without storing the length. This introduces a few additional strlen computations, but overhead should be low. Allows to reduce size of struct cmark_node later.
2020-01-23Use C string instead of chunk for code info and literalNick Wellnhofer
Use zero-terminated C strings instead of cmark_chunks without storing the length. The length of code literals will be readded in a later commit. strlen overhead for code info should be negligible. Reduces size of struct cmark_node by 8 bytes.
2018-07-07Add xml:space="preserve" in XML output when appropriateNguyễn Thái Ngọc Duy
With current HTML escaping, sometimes we may produce an XML tag like <code_block> </code_block> Many XML parsers consider these spaces insignificant and strip them out but we need this. There's actually a test case like this in spec.txt (search "A code block can have all empty lines as its content:") and without proper hinting, an external xml->html converter will fail the spec. XML standard covers this case. If xml:space is "preserve", then whitespaces are significant and should be kept. Add this hint for text, code, code_block, html_inline and html_block tags.
2016-06-06cmark: Implement support for custom allocatorsVicent Marti
2016-03-12Don't use variable length arraysNick Wellnhofer
They're not supported by MSVC.
2016-03-12Switch from "inline" to "CMARK_INLINE"Nick Wellnhofer
Newer MSVC versions support enough of C99 to be able to compile cmark in plain C mode. Only the "inline" keyword is still unsupported. We have to use "__inline" instead.
2016-01-18Merge branch 'master' of https://github.com/mbenelli/cmark into mbenelli-masterJohn MacFarlane
2015-12-28Reformat sources.John MacFarlane
2015-12-28Rename NODE_HTML -> NODE_HTML_BLOCK, NODE_INLINE_HTML -> NODE_HTML_INLINE.John MacFarlane
API change. Sorry, but this is the time to break things, before 1.0 is released. This matches the recent changes to CommonMark.dtd.
2015-12-23Added version number to XML namespace.John MacFarlane
1.0 - looking forward. We don't guarantee stability in this until 1.0 is actually released, however.
2015-12-22CMARK_NODE_HEADER -> CMARK_NODE_HEADING.John MacFarlane
Defined CMARK_NODE_HEADER to CMARK_NODE_HEADING to ease the transition.
2015-12-22Rename 'header' -> 'heading'.John MacFarlane
See jgm/CommonMark commit 0cdbcee4e840abd0ac7db93797b2b75ca4104314 Note that we have defined cmark_node_get_header_level = cmark_node_get_heading_level and cmark_node_set_header_level = camrk_node_set_heading_level for backwards compatibility in the API.
2015-12-22xml renderer - Added xmlns attribute to document node.John MacFarlane
See jgm/CommonMark#87.
2015-12-19Changed API for CUSTOM_BLOCK and CUSTOM_INLINE.John MacFarlane
Instead of using their `as.literal` content, we now give each custom node *two* literal fields, one to be printed on entering the node (before rendering the children, if any), the other on exiting (after rendering children). This gives us the flexibility to have custom nodes with children.
2015-12-19Rename RAW_BLOCK -> CUSTOM_BLOCK, RAW_INLINE -> CUSTOM_INLINE.John MacFarlane
2015-12-19Added RAW_BLOCK and RAW_INLINE node types.John MacFarlane
These are passed through verbatim by all writers, with no escaping. They are never generated by the parser, and do not correspond to CommonMark elements. They are designed to be inserted by filters that postprocess the AST. For example, a filter might convert specially marked code blocks to svg diagrams in HTML and tikz diagrams in LaTeX, passing these through to the renderer as a RAW_BLOCK.
2015-11-02Replaced sprintf with snprintf.Marco Benelli
2015-10-19Fixed DOCTYPE in xml output.John MacFarlane
See http://talk.commonmark.org/t/output-of-t-xml-should-have-different-doctype-declaration/1893.
2015-07-27Use clang-format, llvm style, for formatting.John MacFarlane
* Reformatted all source files. * Added 'format' target to Makefile. * Removed 'astyle' target. * Updated .editorconfig.
2015-07-25xml renderer - use sprintf to avoid strbuf_sprintf.John MacFarlane
2015-07-25Avoid using strbuf_printf when not needed.John MacFarlane
2015-06-07Avoid strlen in xml.cNick Wellnhofer
2015-06-07Convert code base to strbuf_tNick Wellnhofer
There are probably a couple of places I missed. But this will only be a problem if we use a 64-bit bufsize_t at some point. Then, we'll get warnings from -Wshorten-64-to-32.
2015-06-06astyle formatting changes.John MacFarlane
2015-05-14Store link URL and title as cmark_chunkNick Wellnhofer
2015-02-16Made 'options' an int rather than a long.John MacFarlane
For consistency with the API.
2015-02-15Moved normalization step from XML renderer to main.John MacFarlane
2015-01-21Removed unnecessary strbuf_free's.John MacFarlane
2015-01-12Some astyle reformatting.John MacFarlane
2015-01-11xml.c: Include level attribute in header.John MacFarlane
2015-01-11xml format: use 'destination' instead of 'url', like the spec.John MacFarlane
2015-01-09Minor code reformatting.John MacFarlane
2015-01-09xml writer: add list attributes.John MacFarlane
2015-01-07cmark: Add function & option to normalize text nodes.John MacFarlane
So, instead of <text>Hi</text> <text>&amp;</text> <text>lo</text> we get <text>Hi&amp;lo</text> * Added exported `cmark_consolidate_text_nodes` function. * Added `CMARK_OPT_NORMALIZE` to options. * Added optional normalization in XML writer. * Added `--normalize` option to command-line program. * Updated man page.
2015-01-05Reformatted code consistently with astyle.John MacFarlane
2015-01-04xml writer - fixed issues with empty images.John MacFarlane
2014-12-31Remove useless void* castNick Wellnhofer
2014-12-29Make `--sourcepos` affect xml writer too.John MacFarlane
2014-12-29Added options parameter to renderers.John MacFarlane
To keep the API simple and avoid API changes when new options are added, this is just a long integer. Set it by disjoining options that are defined as powers of 2: e.g. `CMARK_HTML_SOURCEPOS | CMARK_HTML_HARDREAKS`. Test options using `&`: `if (options & CMARK_HTML_SOURCEPOS)`. Added `--hardbreaks` and `--sourcepos` command-line options.
2014-12-28Added end_column to cmark_node struct.John MacFarlane
API exports cmark_node_get_column. XML writer indicates start and end line and column for block-level nodes.
2014-12-28Revamped xml writer and dtd to use lowercase element names.John MacFarlane
2014-12-28Added xml writer, to dump the AST in XML.John MacFarlane
This is a work-in-progress. CommonMark.dtd gives the DTD for the generated XML. Closes #53.