Commit Graph

683 Commits

Author SHA1 Message Date
Martin Mitas
a638a4223d md_build_ref_def_hashtable: Fix variable conflict.
By copy&paste error, we have used two nested loops to use the same
iterator.
2017-07-18 19:04:08 +02:00
Martin Mitas
6bc0b86101 Merge branch 'hash' 2017-07-18 18:50:07 +02:00
Martin Mitas
cfbce75910 Rework ref. def. dictionary.
It now uses FNV1a and we now sort/bsearch only contents of single bucket.
Additionally we fix #20 by disabling the invalid ref. definitions during
hashtable build.
2017-07-18 18:49:52 +02:00
Martin Mitas
ff524e9104 Refactor: Isolate dictionary of reference defintions. 2017-07-18 18:02:47 +02:00
Martin Mitas
07c5dba9ba Remove unused structure member. 2017-07-18 18:02:00 +02:00
Martin Mitas
4e831dc112 Add 2017 into copyright notes. 2017-07-15 18:42:50 +02:00
Martin Mitas
f2821cbd8e md_analyze_permissive_email_autolink: Make it compatible with CMark-gfm. 2017-07-14 17:10:45 +02:00
Martin Mitas
a83db2b702 README.md: Minor update. 2017-07-14 16:49:42 +02:00
Martin Mitas
1bc7f3a84e render_url_escaped: Fix escaping of ampersand.
This affected generating href attribute if links or src attribute of
images.
2017-07-14 02:24:21 +02:00
Martin Mitas
f3f9404e53 Improve URL autolinks extension.
It is now much more compatible to Cmark-gfm.

With the flag MD_FLAG_PERMISSIVEWWWAUTOLINKS, we now also support the
WWW autolinks (when the http: scheme is omitted).
2017-07-14 02:06:23 +02:00
Martin Mitas
8818ff14d3 Get rid of unneeded MD_LINK_REF_DEF::index. 2017-07-13 19:18:03 +02:00
Martin Mitas
302cd5f8c0 Improve lookup of link reference definitions.
At the cost of remembering all reference definitions (even when having
same label), we improved the lookup from O(n) to O(log(n)).

This also fixes potential DOS attack by providing input with thousandslink
reference definitions and references to them.
2017-07-13 18:54:34 +02:00
Martin Mitas
82c0eb53c4 entity_lookup: Make it return UTF-32 codepoints.
And adapted callers accordingly.

Fixes #12.
2017-07-13 16:23:45 +02:00
Martin Mitas
25a156ee1b Implement strikethrough extension. 2017-07-12 23:30:14 +02:00
Martin Mitas
d84dcec8f1 md4c/md4c.h: MD_DIALECT_GITHUB does not imply MD_FLAG_PERMISSIVEATXHEADERS.
Since migration to Cmark-gfm, github.com does not accept them anymore.
2017-07-12 22:54:29 +02:00
Martin Mitas
aa51e86f9e md2html/md2html.c: Add options for Markdown dialect.
Added support for options --commonmark and --github.
2017-07-12 22:52:58 +02:00
Martin Mitas
71d74e9f55 Merge branch 'master' of https://github.com/mity/md4c 2017-05-04 16:33:56 +02:00
Martin Mitas
921602b373 md_is_link_reference_definition: Do not store multiple link definitions with same label. 2017-05-04 16:33:29 +02:00
ale rimoldi
1998090786 use typedef structs that are compatible with both c and c++ 2017-03-19 23:15:26 +01:00
Martin Mitas
aeaff18e87 Bump version to 0.2.2 2017-01-08 09:04:24 +01:00
Martin Mitas
ea83b7f6e6 md_analyze_simple_pairing_mark: Fix gcc warning. 2017-01-04 21:58:24 +01:00
Martin Mitas
8999e1844a Fix "rule of three" for emphasis resolution (issue #14). 2017-01-04 15:20:46 +01:00
Martin Mitas
c63909df8e When splitting emphasis opener mark, we have to retain 'dummy' marks available for more splitting in the future (issue #15). 2017-01-04 15:06:14 +01:00
Martin Mitas
3c28a8b8db md_rollback: Do not play with the mark flag MD_MARK_LEAF.
And remove the flag altogether.
2017-01-04 15:06:14 +01:00
Martin Mitas
3688e0fc65 md_link_label_eq: Remove harmful anti-optimization. 2017-01-01 23:53:46 +01:00
Martin Mitas
ca5da63d4d md_collect_marks: Optimize in case of 8-bit encodings by eliminating some branches in the fast path. 2017-01-01 22:02:33 +01:00
Martin Mitas
443ee51581 md_collect_marks: Optimize the fast path by making its loops tighter. 2017-01-01 21:39:48 +01:00
Martin Mitas
7cb7f65cf0 md_collect_marks: Optimize fast path by some manual loop unrolling. 2017-01-01 18:20:25 +01:00
Martin Mitas
2726b7cb5e Minor code cleanup. 2017-01-01 17:51:24 +01:00
Martin Mitas
9c644b40dc md_analyze_line: Optimize scanning for end of line. 2017-01-01 17:26:36 +01:00
Martin Mitas
f1a63f1ca8 md_process_table_row: Fix possible errorneous free() on an error path. 2017-01-01 16:19:07 +01:00
Martin Mitas
1a8ce93d6f Add macros MD_DIALECT_COMMONMARK and MD_DIALECT_GITHUB. 2016-12-28 00:02:23 +01:00
Martin Mitas
5271238426 When parsing tables, pipes inside a link/image/code span cannot make cell boundary (issue #7). 2016-12-27 22:52:06 +01:00
Martin Mitas
72173b3f8a Propagate to renderer more info about lists (issue #13).
Make MD_BLOCK_OL_DETAIL and MD_BLOCK_UL_DETAIL (new structure) expose more
info about the lists.

In particular flag whether the list is tight or loose, and info about the
fundamental chartacter making the list item marks.
2016-12-21 19:24:59 +01:00
Martin Mitas
a9582fa4f9 .travis.yml: Add md2html to coveralls upload. 2016-12-16 11:23:34 +01:00
Martin Mitas
ba686ec3f1 render_html.c: Fix build with MSVC. 2016-12-16 10:16:17 +01:00
Martin Mitas
c377f567af Add some versioning info.
* md4c.h now contains macros MD_VERSION_xxxx.
 * md2html has option --version.

(Of course those shall have some meaningful values only when we introduce
some release process.)
2016-12-16 10:06:07 +01:00
Martin Mitas
c9ef8ccb2f render_html.c: Unify use of char versus MD_CHAR. 2016-12-16 09:59:03 +01:00
Martin Mitas
c850843c12 md2html: Isolate HTML renderer into render_html.c (issue #8). 2016-12-16 09:53:31 +01:00
Martin Mitas
232ceeac24 md_analyze_line: A list item can begin with at most one blank line (issue #6).
Hacky. I very dislike it, but it brings us full CommonMark 0.27
compliance.

Hallelujah.
2016-12-16 00:11:23 +01:00
Martin Mitas
3ec2a19596 md_analyze_backtick: Ensire that code span opener and closer do not overlap. 2016-12-15 23:57:58 +01:00
Martin Mitas
f9b4cb8f6e md_process_inlines: Fix when an expanded mark shadows some nested marks (issue #11). 2016-12-15 16:47:41 +01:00
Martin Mitas
c235a02ee8 test/coverage.txt: Add some tests for higher code coverage. 2016-12-15 13:18:48 +01:00
Martin Mitas
a38c79db66 md_build_attr_append_substr: Fix leak on an error path (CID 1389262). 2016-12-15 11:33:20 +01:00
Martin Mitas
a725fee3f6 md_enter_child_containers: Fix crash (issue #10).
Calling md_push_container_bytes() may result in ending a current block
which may result in removing some contents from ctx->block_bytes when
removing some lines with link reference definitions.

This in effect means we have to end the block explicitly before storing
the offset into the ctx->block_bytes.
2016-12-14 16:51:24 +01:00
Martin Mitas
c085ab5cfe Implement support for entities outside normal text flow (issue #5).
* Change API (md4c.h) to propagate different substring type info to renderer.
 * Implement/refactor related code in the parser.
 * Adapt renderer (md2html) to the new API.
2016-12-14 13:23:47 +01:00
Martin Mitas
ba29d0075e md_is_link_reference_definition: Fix handling of multiline label (issue #9). 2016-12-12 23:31:59 +01:00
Martin Mitas
a4d4f4638f README.md: Improve wording. 2016-12-12 18:04:14 +01:00
Martin Mitas
09ae86095f Handle images more like links.
Remove MD_SPAN_IMG_DETAIL::alt. Instead, the contents of the image is
propagated to the renderer via MD_RENDERER::text() callback.

 * This fixes handling of entities inside the image text (issue #4).
 * It simplifies parsing and, more importantly, it better distingusshes
   what is responsibility of parser or renderer respectively.
 * This allows more flexibility on renderers side. Renderer who do not
 * really support images can just output the image content as any
   other text.

The cost is a renderer into HTML (if it wants to render image contents
into the attribute ALT of the IMG tag), has to handle images with more
care. Typically such renderer has to track whether it is inside an image,
and if so, then render span enter/leave as an empty string.
2016-12-07 23:56:47 +01:00
Martin Mitas
b7f37ae67f README.md: Minor update. 2016-12-07 23:24:17 +01:00