CommonMark parsing and rendering library and program in C
CMAKE_C_VISIBILITY_PRESET
for cmake versions greater than 1.8
(e.g. 3.6.2) (#162, Hugh Bellamy). This lets us build swift-cmark
on Windows, using clang-cl.print_delimiters
(commented out) so it compiles again.make format
: don't change order of includes.\0
and \n
(Yuki Izumi).cmark_mem
to free where used to alloc (Yuki Izumi).(
(jgm/CommonMark#427).$(MAKE)
in Makefile instead of hardcoded make
(#146,
Tobias Kortkamp).chunk_set_cstr
with suffix of current string (#139,
Nick Wellnhofer). It's possible that cmark_chunk_set_cstr
is called
with a substring (suffix) of the current string. Delay freeing of the
chunk content to handle this case correctly.process_emphasis
now gets better results in corner cases.
The change is this: when considering matches between an interior
delimiter run (one that can open and can close) and another delimiter
run, we require that the sum of the lengths of the two delimiter
runs mod 3 is not 0.cmark_reference_lookup
: Return NULL if reference is null string.commonmark.c
(Nick Wellnhofer).
Fixes test failures on Windows and undefined behavior.
cmark_isalpha
.commonmark.c
.cmark.h
and its man page (#124).CMARK_OPT_NOBREAKS
to all renderers and add --nobreaks
.CMARK_OPT_NOBREAKS
is set.CMARK_OPT_HARDBREAKS
for LaTeX and man renderers.CMARK_OPT_NOBREAKS
is enabled, or if output is CommonMark and
CMARK_OPT_HARDBREAKS
is enabled.NOBREAKS
option is HTML-onlyno_linebreaks
instead of no_wrap
.
We generally want this option to prohibit any breaking
in things like headers (not just wraps, but softbreaks).realurllen
to int
. This is an alternate solution for pull
request #132, which introduced a new warning on the comparison
(Benedict Cohen).link_text
(Mathiew Duponchelle).cmark_node_new_with_mem
,
cmark_parser_new_with_mem
, cmark_mem
to API.SSIZE_T
compat for Win32 (Vicent Marti).to_commonmark
in test/cmark.py
(for round-trip tests).spec_test.py
- parameterize do_test
with converter.spec_tests.py
: exit code is now sum of failures and errors.
This ensures that a failing exit code will be given when
there are errors, not just with failures.cmark
instead of the round-trip version, since there was a bug in
setting the ROUNDTRIP variable (#131).roundtrip_tests.py
. This replaces the old use of simple shell
scripts. It is much faster, and more flexible. (We will be able
to do custom normalization and skip certain tests.)api_test
(Mathieu Duponchelle).partially_consumed_tab
on every new line (#114, Nick Wellnhofer).last_buffer_ended_with_cr
.
Added test.Fixed tabs in indentation (#101). This patch fixes S_advance_offset so that it doesn't gobble a tab character when advancing less than the width of a tab.
Added partially_consumed_tab to parser. This keeps track of when we have gotten partway through a tab when consuming initial indentation.
Simplified add_line (only need parser parameter).
Properly handle partially consumed tab. E.g. in
- foo
<TAB><TAB>bar
we should consume two spaces from the second tab, including two spaces in the code block.
Properly handle tabs with blockquotes and fenced blocks.
Fixed handling of tabs in lists.
Clarified logic in S_advance_offset.
Use an assertion to check for in-range html_block_type. It's a programming error if the type is out of range.
Refactored S_processLines to make the logic easier to understand, and added documentation (Mathieu Duponchelle).
Removed unnecessary check for empty string_content.
Factored out contains_inlines.
Moved the cmake minimum version to top line of CMakeLists.txt (tinysun212).
Fix ctype(3) usage on NetBSD (Kamil Rytarowski). We need to cast value passed to isspace(3) to unsigned char to explicitly prevent possibly undefined behavior.
Compile in plain C mode with MSVC 12.0 or newer (Nick Wellnhofer). Under MSVC, we used to compile in C++ mode to get some C99 features like mixing declarations and code. With newer MSVC versions, it's possible to build in plain C mode.
Switched 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.
Added include guards to config.h
config.h.in - added compatibility snprintf, vsnprintf for MSVC.
Replaced sprintf with snprintf (Marco Benelli).
config.h: include stdio.h for _vscprintf etc.
Include starg.h when needed in config.h.
Removed an unnecessary C99-ism in buffer.c. This helps compiling on systems like luarocks that don't have all the cmake configuration goodness (thanks to carlmartus).
Don't use variable length arrays (Nick Wellnhofer). They're not supported by MSVC.
Test with multiple MSVC versions under Appveyor (Nick Wellnhofer).
Fix installation dir of man-pages on NetBSD (Kamil Rytarowski).
Fixed typo in cmark.h comments (Chris Eidhof).
Clarify in man page that cmark_node_free frees a node's children too.
Fixed documentation of --width in man page.
Require re2c >= 1.14.2 (#102).
Generated scanners.c with more recent re2c.
is_autolink
- handle case where link has no children,
which previously caused a segfault.)
and
.
characters after digits were escaped; now they are
only escaped if they are genuinely in a position where
they'd cause a list item. This is achieved by changes in
render.c
: (a) renderer->begin_content
is only set to
false after a string of digits at the beginning of the
line, and (b) we never break a line before a digit.
Also, begin_content
is properly initialized to true.consolidate_text_nodes
.cmark_node_replace(oldnode, newnode)
.fenced
in cmark_render_html
.
It's sufficient to check that the info string is empty.
Indeed, those who use the API may well create a code block
with an info string without explicitly setting fenced
.test/smart_punct.txt
.test/spec.txt
, test/smart_punct.txt
, and
spec_tests.py
to new format.get_containing_block
logic in src/commonmark.c
.
This did not allow for the possibility that a node might have no
containing block, causing the commonmark renderer to segfault if
passed an inline node with no block parent.CUSTOM_BLOCK
,
CUSTOM_INLINE
. The old versions raw_inline
and
raw_block
were being used, and this led to incorrect xml output.scheme
scanner according to spec change. We no longer use
a whitelist of valid schemes.CUSTOM_BLOCK
(#96).cmark.h
: moved typedefs for iterator into iterator section.
This just moves some code around so it makes more sense
to read, and in the man page.make_man_page.py
so it includes typedefs again.CUSTOM_BLOCK
and CUSTOM_INLINE
node types.
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 CUSTOM_BLOCK
. These nodes can have children, but they
also have literal text to be printed by the renderer "on enter"
and "on exit." Added cmark_node_get_on_enter
,
cmark_node_set_on_enter
, cmark_node_get_on_exit
,
cmark_node_set_on_exit
to API.NODE_HTML
-> NODE_HTML_BLOCK
,
NODE_INLINE_HTML
-> NODE_HTML_INLINE
. Define aliases
so the old names still work, for backwards compatibility.CMARK_NODE_HEADER
-> CMARK_NODE_HEADING
.
Note that for backwards compatibility, we have defined aliases:
CMARK_NODE_HEADER
= CMARK_NODE_HEADING
,
cmark_node_get_header_level
= cmark_node_get_heading_level
, and
cmark_node_set_header_level
= cmark_node_set_heading_level
.CMARK_NODE_HRULE
-> CMARK_NODE_THEMATIC_BREAK
.
Defined the former as the latter for backwards compatibility.cmark.h
(#88).
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.> \- foo
.[foo](#bar)
as \protect\hyperlink{bar}{foo}
.Makefile.nmake
: be more robust when cmake is missing. Previously,
when cmake was missing, the build dir would be created anyway, and
subsequent attempts (even with cmake) would fail, because cmake would
not be run. Depending on build/CMakeFiles
is more robust -- this won't
be created unless cmake is run. Partially addresses #85.size_t
to int
. This fixes an MSVC warning
"conversion from 'size_t' to 'int', possible loss of data" (Kevin Wojniak).cmark_parse_document
example (Lee Jeffery).CMARK_...
).make bench
.time
has limited resolution.bench.h
and timing calls in main.c
.scanners.c
using re2c 0.15.3.TIMER
macro.LIB_INSTALL_DIR
configurable (Mathieu Bridon, #79).input
, not parser->curline
to determine last line length._scan_at
.TAB_STOP
.make format
reformat api tests as well.begin_content
field. This is like begin_line
except
that it doesn't trigger production of the prefix. So it can be set
after an initial prefix (say >
) is printed by the renderer, and
consulted in determining whether to escape content that has a special
meaning at the beginning of a line. Used in the commonmark renderer.convert_charrefs=False
in normalize.py
(#83). This defeats the
new default as of python 3.5, and allows the script to work with python
3.5.