summaryrefslogtreecommitdiff
path: root/src/inlines.c
AgeCommit message (Collapse)Author
2016-09-15Allow a shortcut link before a (.John MacFarlane
See jgm/CommonMark#427
2016-06-24Reformatted.John MacFarlane
2016-06-24Removed redundant check.John MacFarlane
2016-06-24Changed `process_emphasis` to get better results in corner cases.John MacFarlane
This will need corresponding spec changes. 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. Thus, for example, in *a**b* 1 23 4 delimiter 1 cannot match 2, since the sum of the lengths of the first delimiter run (1) and the second (1,2) == 3. Thus we get `<em>a**b</em>` instead of `<em>a</em><em>b</em>`. This gives better behavior on things like *a**b**c* which previously got parsed as <em>a</em><em>b</em><em>c</em> and now would be parsed as <em>a<strong>b</strong>c</em> With this change we get four spec test failures, but in each case the output seems more "intuitive": ``` Example 386 (lines 6490-6494) Emphasis and strong emphasis *foo**bar**baz* --- expected HTML +++ actual HTML @@ -1 +1 @@ -<p><em>foo</em><em>bar</em><em>baz</em></p> +<p><em>foo<strong>bar</strong>baz</em></p> Example 389 (lines 6518-6522) Emphasis and strong emphasis *foo**bar*** --- expected HTML +++ actual HTML @@ -1 +1 @@ -<p><em>foo</em><em>bar</em>**</p> +<p><em>foo<strong>bar</strong></em></p> Example 401 (lines 6620-6624) Emphasis and strong emphasis **foo*bar*baz** --- expected HTML +++ actual HTML @@ -1 +1 @@ -<p><em><em>foo</em>bar</em>baz**</p> +<p><strong>foo<em>bar</em>baz</strong></p> Example 442 (lines 6944-6948) Emphasis and strong emphasis **foo*bar** --- expected HTML +++ actual HTML @@ -1 +1 @@ -<p><em><em>foo</em>bar</em>*</p> +<p><strong>foo*bar</strong></p> ```
2016-06-23Removed positon from delimiter struct.John MacFarlane
It is no longer needed; only the brackets struct needs it. Thanks to @robinst.
2016-06-23Ported robinst's changes to link parsing.John MacFarlane
See https://github.com/jgm/commonmark.js/pull/101 This uses a separate stack for brackets, instead of putting them on the delimiter stack. This avoids the need for looking through the delimiter stack for the next bracket. It also avoids a shortcut reference lookup when the reference text contains brackets. The change dramatically improved performance on the nested links pathological test for commonmark.js. It has a smaller but measurable effect here.
2016-06-23Revert "Better parsing of shortcut references."John MacFarlane
This reverts commit c069cb55bcadfd0f45890d846ff412b3c892eb87.
2016-06-22Better parsing of shortcut references.John MacFarlane
We reuse the parser for reference labels, instead of just assuming that a slice of the link text will be a valid reference label. (It might contain interior brackets, for example.)
2016-06-06cmark: Implement support for custom allocatorsVicent Marti
2016-06-06cmake: Global handler for OOM situationsVicent Marti
2016-06-01inlines: Remove unused variable "link_text"Mathieu Duponchelle
2016-04-09Fixed whitespace.John MacFarlane
2016-04-09Use library functions to insert nodes in emphasis/link processing.John MacFarlane
Previously we did this manually, which introduces many places where errors can creep in.
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.
2015-12-28Don't allow space between link text and link labelJohn MacFarlane
in a reference link. (Spec change.)
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-19Use fully qualified versions of constants.John MacFarlane
2015-08-10Remove need to disable MSVC warning 4800Kevin Wojniak
2015-08-07Fixed `--hardbreaks` with CRLF line breaks.John MacFarlane
Closes #68.
2015-08-06Prefix utf8proc functions to avoid conflict with existing libraryKevin Wojniak
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-15Improved `make_autolink`.John MacFarlane
Ensures that title is chunk with empty string rather than NULL, as with other links. Avoids "potential memory leak" warning from clang static analyzer (though I couldn't measure one with valgrind).
2015-07-15Use full CMARK_NODE_x instead of NODE_x alias.John MacFarlane
2015-07-13Removed assertion that broke debug build.John MacFarlane
2015-07-09Implemented new treatment of dashes with `--smart`.John MacFarlane
2015-06-18process_emphasis: Fixed setting lower bound to potential openers.John MacFarlane
2015-06-18Rename potential_openers -> openers_bottom.John MacFarlane
2015-06-18Rename start_delim -> stack_bottom.John MacFarlane
2015-06-17Fixed emphasis/link parsing bug.John MacFarlane
Closes #59.
2015-06-17Added assertion to peek_char to catch any stray NULLs.John MacFarlane
Note that our current procedure for removing nulls is not working properly.
2015-06-16Small code simplification in inlines.c.John MacFarlane
Use S_is_line_end_char.
2015-06-16skip_spaces: skip tabs too.John MacFarlane
2015-06-16Don't rtrim in subject_from_buffer.John MacFarlane
This gives bad results in parsing reference links, where we might have trailing blanks. (finalize in blocks.c removes the bytes parsed as a reference definition; before this change, some blank bytes might remain on the line.)
2015-06-15Fixed cases likeJohn MacFarlane
``` [ref]: url "title" ok ``` Here we should parse the first line as a reference.
2015-06-15inlines.c: Added utility functions to skip spaces and line endings.John MacFarlane
2015-06-11Small logic fixes and a simplification in process_emphasis.John MacFarlane
2015-06-11Fixed `process_emphasis` to handle new pathological cases.John MacFarlane
Now we have an array of pointers (`potential_openers`), keyed to the delim char. When we've failed to match a potential opener prior to point X in the delimiter stack, we reset `potential_openers` for that opener type to X, and thus avoid having to look again through all the openers we've already rejected. See jgm/commonmark#43.
2015-06-10More code simplification.John MacFarlane
2015-06-10Code simplification.John MacFarlane
2015-06-10process_inlines: remove closers from delim stack when possible.John MacFarlane
When they have no matching openers and cannot be openers themselves, we can safely remove them. This helps with a performance case: "a_ " * 20000. See jgm/commonmark.js#43.
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-06-04Don't allow link labels with no non-whitespace characters.John MacFarlane
See jgm/CommonMark#322.
2015-06-03Merge branch 'master' of https://github.com/btrask/cmark into btrask-masterJohn MacFarlane
Conflicts: src/blocks.c
2015-05-14Store link URL and title as cmark_chunkNick Wellnhofer
2015-04-27Fixed _ emphasis parsing to conform to spec.John MacFarlane
See jgm/CommonMark#317.
2015-04-07Add CRLF/CR handling to inlines.c.Ben Trask
2015-03-30Fixed memory issue.John MacFarlane
This fixes valgrind "invalid read of size 1" on input `[link](<>)`.
2015-03-03astyle changes.John MacFarlane
2015-02-18Repacked delimiter struct to avoid hole.John MacFarlane