Commit Graph

13 Commits

Author SHA1 Message Date
Tim Ledbetter
bebcf71bdc LibMarkdown: Avoid catastrophic backtracking in thematic break regex
Fixes #17937
2023-04-14 16:02:59 +01:00
Arda Cinar
5cc984d74c LibMarkdown: Render lines to terminal instead of a single string
With this patch, the blocks in a markdown document render a vector of
lines. These lines get concatenated in Document::render_to_terminal, so
this does not change any external APIs of LibMarkdown.

This change makes it possible to indent individual lines in the rendered
markdown. So, rendering blockquotes in a similar way to code blocks :^)
2022-12-31 00:09:23 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
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.
2022-07-12 23:11:35 +02:00
Peter Elliott
c15c57a6af LibMarkdown: Make thematic break parsing more correct
also fix a conflict with lists and thematic breaks
2022-04-26 15:02:26 +02:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Ben Wiederhake
24e7196158 LibMarkdown: Implement introspection of the document tree 2021-10-10 15:18:55 -07:00
Peter Elliott
0a21c2bace LibMarkdown: Implement "tightness" for lists
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.)
2021-10-05 13:27:25 +03:30
Peter Elliott
10f6f6a723 LibMarkdown: Add LineIterator
LineIterator wraps a vector's ConstIterator, to provide an iterator that
can work on indented container blocks (like lists and blockquotes).
2021-10-05 13:27:25 +03:30
Peter Elliott
dee84113ab LibMarkdown: Match HTML formatting of Commonmark tests
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
2021-08-31 16:53:51 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00