Commit graph

28 commits

Author SHA1 Message Date
Andreas Kling 359d6e7b0b Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06 23:46:35 +01:00
Linus Groh 6e7459322d AK: Remove StringBuilder::build() in favor of to_deprecated_string()
Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
2023-01-27 20:38:49 +00:00
Ben Wiederhake 8a331d4fa0 Everywhere: Move AK/Debug.h include to using files or remove 2023-01-02 20:27:20 -05: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
MacDue 8140b1fa18 LibMarkdown: Implement the image size extension
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).
2022-08-04 02:49:29 +02:00
sin-ack c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
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.
2022-07-12 23:11:35 +02: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
huttongrabiel 25970f2763 LibMarkdown: Add strike-through text support to markdown
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.
2022-04-28 22:15:08 +02:00
Peter Elliott 5ad44ac2e5 LibMarkdown: Ignore backslash on non-punctuation characters 2022-04-26 15:02:26 +02:00
xSlendiX 7685d53654 LibMarkdown: Add terminal color formatting
This patch adds color formatting to markdown viewed in the terminal.
This also increases readability.
2022-02-17 19:54:47 +01:00
Andreas Kling 8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling 409b20e316 LibMarkdown: Allow nested links
This fixes an issue where the linked images in our README.md didn't
get turned into images.
2021-11-03 10:21:50 +01:00
Ben Wiederhake 24e7196158 LibMarkdown: Implement introspection of the document tree 2021-10-10 15:18:55 -07:00
Ben Wiederhake aca01932bd LibMarkdown: Make href always a String
This already was the case in some sense, but made it very inconvenient
to access it.
2021-10-10 15:18:55 -07:00
Nico Weber 61e9e80232 LibMarkdown: Fix typo in variable name 2021-10-01 01:33:43 +01:00
Peter Elliott 565b561522 LibMarkdown: Render sequences of spaces properly in the terminal 2021-09-12 12:17:16 +02:00
Peter Elliott 9c0563cc10 LibMarkdown: Implement hard and soft line breaks
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
2021-09-12 12:17:16 +02:00
Peter Elliott af5a07399e LibMarkdown: Handle delimiter flanking with punctuation
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.
2021-09-12 12:17:16 +02:00
Peter Elliott 6724d6d391 LibMarkdown: Add terminal rendering for new markdown Text parser 2021-09-12 12:17:16 +02:00
Peter Elliott ec9f892899 LibMarkdown: Rewrite Inline text parser to be more forgiving
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.
2021-09-12 12:17:16 +02:00
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
Andreas Kling 89f5f92b7e LibMarkdown: Convert a bunch of StringBuilder::appendf() => appendff() 2021-05-05 22:17:33 +02:00
Gunnar Beutner 6cf59b6ae9 Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr 2021-05-01 21:25:06 +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 5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
asynts bb483f7ef4 Everywhere: Name debug macros more consistently.
Personally, I prefer the naming convention DEBUG_FOO over FOO_DEBUG, but
the majority of the debug macros are already named in the latter naming
convention, so I just enforce consistency here.

This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/DEBUG_PATH/PATH_DEBUG/' {} \;
2021-01-25 09:47:36 +01:00
asynts 1a3a0836c0 Everywhere: Use CMake to generate AK/Debug.h.
This was done with the help of several scripts, I dump them here to
easily find them later:

    awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in

    for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in)
    do
        find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \;
    done

    # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list.
    awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
2021-01-25 09:47:36 +01:00
Andreas Kling 13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Renamed from Libraries/LibMarkdown/Text.cpp (Browse further)