The escape sequence to color a section's name was separated
by a newline from the section's name, making less(1) trim
the escape sequence off when the section's name was on the
first line.
This implements the image size extension that's quite commonly used:
https://github.com/commonmark/commonmark-spec/wiki/Deployed-Extensions#image-size
This supports specifying...
Both width and height: ![](foo.png =100x200)
Width only: ![](foo.png =100x)
Height only: ![](foo.png =x200)
The size is always in pixels (relative sizing does not seem
to be spec'd anywhere).
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).
No functional changes.
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).
No functional changes.
Using ~~text~~ syntax will strike out the text between the two tildes.
Only missing portion is the terminal rendering of strike through text.
The ansi escape codes for strike through text are \e[9m and \e[29m but
it appears the terminal does not support these. Please correct me if I
am wrong.
I tested that the render_to_terminal function was being called by giving
it bold ANSI escape codes, and that did work so the function is being
called correctly.
Previously, only terminal output aligned table column contents
correctly. Now, we apply a `text-align` to each cell. This does not
actually *work* however, since LibWeb's table layout code is not yet
fully functional.
This also improves Commonmark coverage, e.g. it fixes tests
HTML_blocks_ex179_2894..2906 and Lists_ex308_5439..5457.
In other words, we go from 271 out of 652 to 273 out of 652.
This patch adds contexts to line iterator for nesting list items and
blockquotes. It also incidentally makes the api for LineIterator
simpler, and will make it easier to add other containers in the future.
From the commonmark spec:
A list is loose if any of its constituent list items are separated by
blank lines, or if any of its constituent list items directly contain
two block-level elements with a blank line between them. Otherwise a
list is tight. (The difference in HTML output is that paragraphs in a
loose list are wrapped in <p> tags, while paragraphs in a tight list are
not.)
I decided to not use the text parser for this one and rely on a regex to
parse the style tags. This way it supports only and opening delimiter
run and also is much simpler.
Hard line breaks insert a <br /> when two spaces are at the end of a
line. soft line breaks are just regular newlines, but whitespace is now
stripped before and after them
This patch handles the following two rules
1) A delimiter run is either (a) not followed by a Unicode punctuation
character, or (b) followed by a Unicode punctuation character and
preceded by Unicode whitespace or a Unicode punctuation character.
2) A _ can be used to open/close a delimiter run if it's (a) not part
of a left-flanking delimiter run or (b) part of a left-flanking
delimiter run followed by a Unicode punctuation character.
The previous Text::parse was not able to give up on parsing a textual
element, and just leave it as plain text. Because this is a very
important part of markdown, I fully rewrote the parser to support this
without having to backtrack. Also the parser now some other little
features, such ast delimiter runs and flanking.
This patch changes the HTML formatting (where to put newlines, etc...)
to better match commonmark's test cases. This has minimal effect of the
correctness of our markdown implementation, but makes it easier to test.
Changes:
- Use <em> instead of <i>.
- Newline before end of code block.
- <hr /> instead of <hr>.
- Newline before first list item.
- Newline between lines of a paragraph.
- Trim whitespace on lines of paragraphs.
Tests passed: 33/652 -> 87/652
This fixes#7131
The parser already distinguishes between inline code (handled in
Text.cpp) and triple-tick code blocks, so only
CodeBlock::render_to_html() needed to change. Blank lines within
a code block still cause issues, but that's an HTML issue. (#7121)