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.
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.
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.
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)
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.
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.
* 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
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.
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
* 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.
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.
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.