Noah Hellman
0484ee2011
lib: make code block language non option
...
no distinction between empty language and None
2023-05-15 19:05:22 +02:00
Noah Hellman
e79f767604
lib: code block lang -> language
2023-05-15 19:05:22 +02:00
Noah Hellman
924a3c35bb
lib: make div class non option
...
there is no distinction between an empty class and a None
2023-05-15 19:05:22 +02:00
Noah Hellman
329207689b
prepass: fix lookup of headings
...
bug caused by confusing binary_search_by_key to be element instead of
index, both of which were usize
2023-05-10 22:04:01 +02:00
Noah Hellman
9efd4e4448
prepass: fix referenced headings with e.g. spaces
...
headings that did not exactly match their ids were previously not
matched with their reference
2023-05-10 22:04:01 +02:00
Noah Hellman
99f4691e52
lib: emit footnotes as they are encountered
...
Previously, footnotes and their children events were skipped (stored in
block tree) and inline parsed at the end. Now, they are emitted by the
parser immediately and the responsibility to aggregate them has been
moved to the renderer.
resolves #31
2023-04-25 21:03:18 +02:00
Noah Hellman
c4ecd0c677
Revert "lib: add Render::render_{event, prologue, epilogue}"
...
This reverts commit e8503e28fd
.
This imposed too many limitations on the renderer implementation. E.g.
making it impossible to store `Event<'s>`'s in the renderer struct.
Revert back to having the renderer struct separate from the implementor
of the Render trait. The implementor may instead create a renderer
struct without any restrictions.
2023-04-25 21:03:18 +02:00
Noah Hellman
8e48021f7a
lib: emit LinkDefinition event
...
resolves #14
2023-04-25 21:03:18 +02:00
Noah Hellman
ab33adc799
lib: cfg guard doctests using html renderer
...
docs do not compile when html feature is off otherwise
2023-04-25 18:35:10 +02:00
Noah Hellman
d2d7f5d474
lib: fix url in autolink/email end event
...
was constant ">" instead of actual url
2023-04-10 18:50:22 +02:00
Noah Hellman
50205573d0
inline: store attributes in vec
2023-04-05 21:17:33 +02:00
Noah Hellman
62d33effc4
inline: parse multiline attributes
...
reimplement after broken by "take str per line instead of full inline
iter" commit
also resolves #18 and #34
2023-04-05 21:17:33 +02:00
Noah Hellman
2bcc6122ca
inline: store link cowstrs in vec
...
try to reduce size of Event by placing the cowstr in a shared vec, and
just keeping an index in the event itself
seems to have a significant performance benefit on benchmarks
2023-04-05 21:17:33 +02:00
Noah Hellman
a846477cea
inline: parse multi-line link tags/urls
...
reimplement after broken by "take str per line instead of full inline
iter" commit
this also resolves #22
2023-04-05 21:17:33 +02:00
Noah Hellman
86ee4ee520
lex: rm lex::Kind::Whitespace
...
Whitespace tokens do not necessarily create new events but they work as
a delimiter for words with attributes and affect some container
delimiters. Now when we can read the source from inline, we can instead
inspect for whitespace when needed.
Removing the whitespace token allows the lexer to continue a lot longer
without stopping. E.g. a typical line in a paragraph with no special
characters can turn into a single token.
2023-04-05 21:17:33 +02:00
Noah Hellman
9454a2e393
inline: apply word attribute when flushing event buf
...
fixes issue with e.g `[text]({.cls})` where attributes get immediately
applied to `[text](` where link should have priority.
2023-04-05 21:17:33 +02:00
Noah Hellman
1b7bb25519
inline: allow reading src
2023-04-05 21:17:33 +02:00
Noah Hellman
8382fe122f
lib: derive Clone for Parser
...
should now be safe to do
2023-04-05 21:17:33 +02:00
Noah Hellman
3a1a3996e9
inline: take str per line instead of full inline iter
...
gets rid of DiscontinousChars which is large and requires cloning on
peek
resolves #4
2023-04-05 21:17:33 +02:00
Noah Hellman
9429f90307
inline: reuse event buffer between blocks
...
make sure not to allocate a new buffer on each block
2023-04-05 21:17:33 +02:00
Noah Hellman
1e5e56c463
only assert in debug builds
...
these are primarily used to detect bugs during e.g. fuzzing.
most of these asserts have negligible impact on performance, but if they
are not debug asserts it is not obvious that they dont affect
performance of release builds
2023-04-05 21:17:33 +02:00
Noah Hellman
0a501fec10
lib: add test attr_inline_consecutive{,_invalid}
2023-04-05 21:17:33 +02:00
Noah Hellman
718f2df60e
lib: add test link_reference_multiline
2023-04-05 21:17:33 +02:00
Noah Hellman
66fd099af1
lib: add test attr_inline_multiline
2023-04-05 21:17:33 +02:00
Noah Hellman
722f549ffd
clippy: allow blocks_in_if_conditions everywhere
2023-04-05 21:17:33 +02:00
Noah Hellman
10788af246
lib: add Render::{push, write}_borrowed
...
allow rendering iterators with borrowed events
resolves #24
2023-04-05 21:17:33 +02:00
Noah Hellman
e8503e28fd
lib: add Render::render_{event, prologue, epilogue}
...
derive push/write automatically from these
2023-04-05 21:17:33 +02:00
Noah Hellman
e506fffed8
mv push/write examples from html to Render trait
...
They apply more to the Render trait now than the implementation in the
html module
2023-04-05 21:17:33 +02:00
Noah Hellman
a603ea2124
lib: Add SpanLinkTag::Unresolved variant
...
keep the tag for unresolved links, and allow distinguishing between
`[tag][tag with empty url]` and `[tag][non-existent tag]`.
closes #26
2023-04-05 21:17:32 +02:00
Noah Hellman
05a4992d99
lib: don't prepend mailto to url in autolink Event
...
better to provide the original url, the event is already tagged as email
also avoids a string allocation
2023-04-05 21:17:04 +02:00
Noah Hellman
62e73100a6
bug fix: set LinkType to Email for email autolinks
2023-03-20 23:39:51 +01:00
Noah Hellman
648a6dbef2
lib: derive Clone for Event and Container
2023-03-16 20:05:20 +01:00
kmaasrud
e3f39d4b88
feat: support escapes in attributes
...
Related issue: #1
2023-03-12 08:19:56 +01:00
Noah Hellman
c3ff064c78
make Event::is_{,container_}block public
...
this is only used by html renderer, may be useful for other renderers
also
2023-02-12 00:59:18 +01:00
kmaasrud
d7f2c0a819
implement Render trait for html::Renderer
2023-02-10 09:46:18 +01:00
kmaasrud
4743781cb9
add Render trait
2023-02-10 09:45:43 +01:00
Noah Hellman
0d560901eb
block: add Element::list
2023-02-07 21:49:35 +01:00
Noah Hellman
34452a282a
features: add flag for html module
2023-02-05 21:59:38 +01:00
Noah Hellman
0de7776020
impl Clone, Copy on public objects
2023-02-05 20:36:49 +01:00
Noah Hellman
477eadde1c
document lib API
2023-02-05 20:36:49 +01:00
Noah Hellman
5efb700c9b
move atomic events to Event from Atom
...
An additional Atom enum seems to be more cumbersome and add little
value.
methods could potentially be used to classify events in several ways,
e.g. block vs inline, atomic vs container
2023-02-05 20:36:49 +01:00
Noah Hellman
0420aad0a5
implement symbols
...
e.g. :some-sym:
2023-02-05 20:36:49 +01:00
Noah Hellman
fbd8811c86
block: parse description list
2023-02-05 20:36:49 +01:00
Noah Hellman
768699d138
optionally use btree maps instead of hash maps
...
btree maps are deterministic which is useful for fuzzing. hash maps,
however have better performance in our case
2023-02-05 20:36:49 +01:00
Noah Hellman
82adc631d9
allow attributes on thematic breaks
2023-02-05 20:36:49 +01:00
Noah Hellman
ca7f3c7e89
do not treat \0 as EOF
...
may appear in input
2023-02-05 20:36:49 +01:00
Noah Hellman
1bbfd4a96a
prepass: avoid consecutive '-' in heading id
2023-02-05 20:36:49 +01:00
Noah Hellman
87d4f7c270
prepass: use hash set to avoid duplicate heading ids
...
linear lookup becomes problematic for large amount of headings with same
title
2023-02-05 20:36:40 +01:00
Noah Hellman
dc38076f50
block: limit ordered list number width
...
use 64-bit to not let limit be too low, 32-bit allows for only 6 alpha
digits, "zzzzzz".
2023-02-05 20:36:40 +01:00
Noah Hellman
de7404137e
parser: keep inlines of code blocks verbatim
2023-02-05 20:36:40 +01:00