Commit Graph

683 Commits

Author SHA1 Message Date
Martin Mitas
447621611f md_is_code_span: New rules for eating whitespace...
... after the opening and before the closing marker of a code span.
2019-03-26 12:58:22 +02:00
Martin Mitas
eb6a221e22 md_is_opening_code_fence: Allow backtick...
... in info string of tilde-based fence.
2019-03-26 11:58:17 +02:00
Martin Mitas
1edd0c9cf5 test/spec.txt: Update to current upstream HEAD. 2019-03-26 11:49:25 +02:00
Martin Mitas
a80e2e1acf md_is_setext_underline: Remove useless duplicated code. 2019-03-18 00:49:55 +02:00
Martin Mitas
1a24865052 Fix building with MD4C_USE_UTF16. 2019-03-16 09:39:00 +02:00
Martin Mitas
2670043fd2 Bump version to 0.3.1 2019-03-13 07:50:34 +02:00
Martin Mitas
2dd96ab4ac Fix O(n^2) in handling the "rule of three".
We had to break the list of potential '*' openers into multiple ones so
we do not have to walk it when looking for matching length due to the
"rule of three" for intraword delimiter runs.

Fixes #63.
2019-03-12 10:27:36 +02:00
Martin Mitas
b21086522e md_analyze_line: Fix O(n^2) in thematic break handling.
Fixes #66.
2019-03-11 21:13:15 +02:00
Martin Mitas
37104fc281 md_is_code_span: Fix crash at EOF.
Fixes #65.
2019-03-11 20:26:58 +02:00
Martin Mitas
966b8e39b5 md_is_link_title: Stop on ')' lin ()-style title.
Fixes #60.
2019-03-11 19:56:46 +02:00
Martin Mitas
fc27108e71 test/pathological_tests.py: Output test durations. 2019-03-11 19:55:08 +02:00
Martin Mitas
53f65852be test/spec.txt: Little update.
Somehow we were having little different spec.txt version that the one
from CommonMark repo tag 0.28. But we still pass all its compliance
test suite.
2019-03-11 19:03:34 +02:00
Martin Mitas
089174b586 CHANGELOG.md: Update. 2019-03-11 13:02:17 +01:00
Martin Mitas
17c9b32b2e Move autolink detection into md_collect_marks().
It has to be done at the same time as raw inline HTML and code spans.
2019-03-11 13:02:17 +01:00
Martin Mitas
685b714453 Move codespan detection from md_analyze_backtick() into...
md_is_code_span(), called from md_collect_marks().

We have to do this at the same time as detecting raw inline HTML to
follow CommonMark priority requirements.

Also it is done very differently now:

When scanning for the closer mark, we remember (the latest) position of
potential closers for all other lengths as well.

This means that:

(1) If we find it, we reduced the task because all subsequent scan shall
begin after the closer.

(2) If we do not find it, then we have to reach the end of the block and
hence we then know (for every allowed marker length) the position of last
such backtick sequence.

(3) That makes the guaranty that any subsequent call with either succeed
in its scan (and reduce the task even further); or that we shall be able
to detect instantly there is no suitable closer.

I.e. every call either reduces the task by O(n) scan (1); or collects
all the data in O(n) because (2) happens at most once; or fails in O(1)
(3).

This makes O(n) guaranty of the function complexity.

Fixes #59.
2019-03-11 13:02:17 +01:00
Martin Mitas
0cb61205b1 Move raw inline HTML detection from md_analyze_lt_qt() into md_collect_marks().
Fixes #58:

For resolving raw inline HTML the function tried closer with all
potential openers, because raw HTML can have '<' inside of an attribute.

However this caused O(n^2) for input like "<><><><><><><>...".

We solved by handling raw HTML in earlier stage, directly in
md_collect_marks(), where we can scan linerary forward.

Fixes #61:

As a side effect, this also fixes the issue that MD_FLAG_NOHTMLSPANS
disabled also recognition of CommonMark autolinks.
2019-03-11 13:02:17 +01:00
Martin Mitas
cbae179314 md_analyze_line: Fix propagation of uninitialized variable.
Actually it should not be harmful because the consumer should use the
variable MD_CONTAINER::task_mark_off only when MD_CONTAINER::is_task
flag is set and it that case the task_mark_off _is_ initialized.

(CID 1476829)
2019-02-18 11:55:17 +01:00
Martin Mitas
30cfd4e38b appveyor.yml: Fix syntax. 2019-02-13 12:27:21 +01:00
Martin Mitas
e43ac60ae9 appveyor.yml: CMake 3.13.3 seems to always equire path to project root. 2019-02-13 12:25:27 +01:00
Martin Mitas
7ca80c6f5f CHANGELOG.md: Add note about building as shared lib. 2019-02-13 11:26:19 +01:00
Martin Mitas
1ea4b3e2f1 README.md + CHANGELOG.md: More updates. 2019-02-11 10:10:26 +01:00
Martin Mitas
2c1dddc1f5 README.md: Minor update. 2019-02-11 09:29:53 +01:00
Martin Mitas
5a5f10ef76 CHANGELOG.md: Update for version 0.3.0. 2019-02-10 23:08:54 +01:00
Martin Mitas
00a70fea61 Bump version to 0.3.0 2019-02-10 22:59:49 +01:00
Martin Mitáš
8e01a769ea
Implement task lists. (#50)
Fixes #30.
2019-02-10 22:58:42 +01:00
Lisandro Damián Nicanor Pérez Meyer
0b95bcc984 Fix installation path of pkgconfig file.
If the package is compiled on a multiarch-enabled distribution (Debian and
derivatives) the resulting md4c.pc file will have a m-a path in it.

In this case it's better to install into LIBDIR.
2019-02-10 08:04:19 +01:00
Martin Mitas
b9fcd470d6 CHANGELOG.md: Update. 2019-02-09 11:01:56 +01:00
Martin Mitas
d32aa2e076 Fix conflict in parsing permissive autolinks and ordinary links.
The issues is caused by the fact that we do not know exact position
of permissive auto-link in time of md_collect_marks() because there
is no syntax to mark its end on the 1st place.

This causes that eventually, the closer mark in ctx->marks[] can be
out-of-order somewhat.

As a consequence, if some other mark range (e.g. ordinary link)
shadows the auto-link, the closer mark may be left outside the shadowed
range and survive till the phase when we generate the output.

We fix by using an extra mark flag to remember we did really output
the opener mark, and output the closer only in such case.

Fixes #53.
2019-02-09 10:40:52 +01:00
Martin Mitas
f1f2f306a6 md_analyze_permissive_url_autolink: Minor cleanup. 2019-02-09 09:40:25 +01:00
Martin Mitas
bfca107d34 Build: Allow again building MD4C as static lib.
* On Windows, we build static lib by default, as there is no /usr/lib
   counterpart.

 * On other systems the shared lib is the default.

 * Use option BUILD_SHARED_LIBS to override it:
   $ cmake -DBUILD_SHARED_LIBS=ON path_to_root   # to build shared lib
   $ cmake -DBUILD_SHARED_LIBS=OFF path_to_root  # to build static lib
2019-02-08 09:23:20 +01:00
Lisandro Damián Nicanor Pérez Meyer
69fcc953cb Remove useless instructions. (#52)
The library is built as a shared library by default.
Adding a static configuration requires some more work, and probably not
really needed, most people will just embed the code.
2019-02-07 20:04:16 +01:00
Lisandro Damián Nicanor Pérez Meyer
5f33d93308 Build md4c as a shared library. (#49)
Build md4c as a shared library.

- Define the current version in the main CMakeLists.txt, so it can be used
  within the project.
- Define VERSION, SOVERSION and PUBLIC_HEADER as target properties.
- Be able to install both libmd4c and md2html.
- Create a pkg-config file.

Fixes #48
2019-02-07 19:54:25 +01:00
Martin Mitas
c340e78bf9 md_analyze_inlines: Simplify the code path for table_mode. 2019-02-06 04:59:26 +01:00
Martin Mitas
a6cf8ff6e6 CHANGELOG.md: Small update. 2019-02-06 04:36:01 +01:00
Martin Mitas
67401e7019 md_analyze_inlines: Resolve table cell boundaries before links.
This brings some corner cases closer to cmark-gfm.

Also fixes #51.
2019-02-06 04:31:25 +01:00
Martin Mitas
00236fc749 Update years in the files changed this year and in LICENSE.md. 2019-02-05 12:59:44 +01:00
Martin Mitas
03f586851f md4c.h: Rename and refactorize MD_RENDERER struct.
* Rename MD_RENDERER to MD_PARSER. (Typedef to provide the original
   name is provided to minimize disruption of existing code.)
 * Reorder its members to make better sense.
 * Add abi_version member (hopefully, it shall never be needed ;-)
 * Update md2html utility to deal with the change.

Rationale:

This is done in order to prepare for long-term maintenance of ABI
compatibility, as there is no work-in-progress to be buildable as
shared lib, and be included in some Linux distros.
2019-02-05 10:29:53 +01:00
Martin Mitas
162b5fe34e Add CHANGELOG.md. 2019-02-05 10:05:49 +01:00
Martin Mitas
a505f69654 md_process_table_row: Enforce that all trable raws have the same count of cells.
The count of columns is derived from the table header underline. If any
other table line (i.e. the header line, or body line) has too few cells,
additional empty cells are generated automatically.

If the line has too many cells, the bogus ones are silently ignored.

This allows consumers to be more simplistic; and it also seems to match
behavior of Github more closely.
2019-02-03 14:30:06 +01:00
Martin Mitas
69e914b170 README.md: Minor wording enhancements. 2019-02-03 13:29:47 +01:00
Martin Mitas
da511fa4df md_is_entity_str(): Fix using bad offset and buffer overflow situation.
Fixes #47.
2019-02-03 01:16:08 +01:00
Martin Mitas
7d8f253fca md_enter_leave_span_a: Fix calling md_free_attribute() on uninitialized data.
(Coverity issue CID 1475544)
2018-11-18 11:24:37 +01:00
Craig Barnes
e6a51bd6ae Add "-Wall" to CFLAGS when using Clang as compiler
See also:

* https://cmake.org/cmake/help/v3.12/variable/CMAKE_LANG_COMPILER_ID.html
* https://cmake.org/cmake/help/v3.12/variable/CMAKE_COMPILER_IS_GNUCC.html
2018-07-12 07:49:23 +02:00
Martin Mitas
2f79185b66 Bump version to 0.2.7. 2018-06-11 18:40:48 +02:00
Martin Mitas
8fc692badc md_rollback: Do not touch TABLECELLBOUNDARIES chain.
This chain is not normal opener/closer inline mark chain.

Fixes #42.
2018-06-11 18:18:56 +02:00
Martin Mitas
5710bfec81 Fix/simplify handling of end-of-file special mark.
Fixes #43.
2018-06-11 14:13:28 +02:00
Martin Mitas
e6e2ea4c5a md_analyze_line: Fix mixing list and table parsing.
If table header underline is not nested the same way as the preceding
line (i.e. the wannabe table header line), then it cannot form a table.

Fixes #41.
2018-06-11 11:43:47 +02:00
Martin Mitas
cb7ecd7135 Bump version to 0.2.6. 2018-05-30 00:29:01 +02:00
Martin Mitas
4ef024fbb7 md_process_inlines: Fix link/image closers spanning over multiple lines.
Fixes #40.
2018-05-29 23:30:02 +02:00
Martin Mitas
99a5568909 md_is_inline_link_spec_helper: Link destination is mandatory...
... unless it is omitted also with the title.
2018-05-29 23:09:06 +02:00