Commit graph

39 commits

Author SHA1 Message Date
Luke
7094697743 LibMarkdown: Reduce debug spam from invalid characters in table headings
Happens a lot when fuzzing.
2020-11-30 11:35:45 +01:00
Linus Groh
b5b4c50913 LibMarkdown: Only consider "!" a special character when followed by "["
Fixes #4220.
2020-11-29 10:45:00 +01:00
Linus Groh
0aeef47abd LibMarkdown: Use JS::MarkupGenerator for "js" code blocks :^) 2020-10-31 20:52:54 +01:00
Linus Groh
10c19d5207 LibMarkdown: Replace inline styles in HTML with CSS in <head> 2020-10-31 20:52:54 +01:00
Linus Groh
9735879318 LibMarkdown: Don't parse lines starting with a space as heading
This fixes a bug where lines starting with a space would get parsed as
"level 0" headings - it would not find a "#" and therefore never
increase the level counter (starting at zero), which then would cause
the check for "space after #" pass (again, there is no "#").

Eventually we would get funny results like this:

    <h0>[n-1 spaces]oops!</h0>

Also ASSERT(level > 0) in the Heading constructor.
2020-10-26 19:13:19 +01:00
AnotherTest
af05671843 LibMarkdown: Flush the pending paragraphs when encountering empty lines
Fixes #3854.
2020-10-26 09:36:12 +01:00
AnotherTest
eef794b8c6 LibMarkdown: Parse paragraphs line-wise
This gets rid of the doubled-up checks in `Paragraph::parse()`, and
makes a paragraph the last possible kind of block to be parsed.
2020-09-27 21:14:18 +02:00
AnotherTest
176a2f193c LibMarkdown: Add support for Tables
This adds support for GFM-like tables.
The HTML rendering ignores the alignments and relative sizes, but the
terminal view does not!
2020-09-27 21:14:18 +02:00
AnotherTest
7640cb8ec4 LibMarkdown: Add a Text(String) constructor 2020-09-27 21:14:18 +02:00
AnotherTest
445bd86533 LibMarkdown: Make Text default-constructible and move-assignable 2020-09-27 21:14:18 +02:00
AnotherTest
aa65f664a9 LibMarkdown: Take a 'view_width' argument for render_for_terminal()
Some constructs will require the width of the terminal (or a general
'width') to be rendered correctly, such as tables.
2020-09-27 21:14:18 +02:00
Ben Wiederhake
08f9bc26a6 Meta+LibHTTP through LibWeb: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
Ben Wiederhake
da966ac8d8 LibMarkdown: Make warning messages conditional
This is especially a problem during fuzzing.
2020-09-12 13:46:15 +02:00
Nico Weber
1dfae92eac LibMarkdown: Reset offset to 0 on each new List line
Found by FuzzMarkdown.
2020-07-14 17:45:16 +02:00
FalseHonesty
20faa93cb0 LibMarkdown: Change internal MD API to return OwnPtrs
Previously, all Markdown blocks had a virtual parse method which has
been swapped out for a static parse method returning an OwnPtr of
that block's type.

The Text class also now has a static parse method that will return an
Optional<Text>.
2020-05-30 00:32:12 +02:00
FalseHonesty
7ca562b200 LibMarkdown: Change MD Document parse API to return a RefPtr
Markdown documents are now obtained via the static Document::parse
method, which returns a RefPtr<Document>, or nullptr on failure.
2020-05-30 00:32:12 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Andreas Kling
4330046aff LibMarkdown: Turn absolute links into hyperlinks in terminal output :^)
I'm not completely sure how to handle this nicely for relative links
but it would be nice to do that too.
2020-05-09 16:23:41 +02:00
Linus Groh
0a1ecbec48 LibMarkdown: Escape HTML entities in text 2020-05-05 16:18:11 +02:00
Linus Groh
fc3d16d664 LibMarkdown: Use escape_html_entities() from AK/String 2020-05-05 16:18:11 +02:00
Sergey Bugaev
183fa98214 LibMarkdown: Support multi-line list items
You can now continue one list item across several lines, as long as you indent
it the same as the first line of the item. For example:

* This is the first item,
  which spans multiple lines.
* This is the second item, which also has some
  *emphasis* in it.
2020-05-04 21:44:50 +02:00
Sergey Bugaev
f1a8fb1e88 LibMarkdown: Add support for images :^) 2020-04-30 11:30:27 +02:00
Sergey Bugaev
b8aab5fdc3 LibMarkdown: Handle broken link markup better
Let's output *something* instead of crashing on a failed assertion.
2020-04-30 11:30:27 +02:00
Andreas Kling
ea204ef05b LibMarkdown: Drop MD prefixes and move into "Markdown" namespace :^) 2020-04-28 21:04:25 +02:00
Andreas Kling
37fc6c117c Userspace: Add missing #includes now that AK/StdLibExtras.h is smaller 2020-03-08 13:06:51 +01:00
Andreas Kling
70b940c307 LibMarkdown: Fix breakage from Vector using size_t
It's no longer possible rely on negative VectorIterator when iterating
backwards. It would be nice to have a general solution for reverse
iteration, but for now let me just patch this up.
2020-02-29 17:06:57 +01:00
Andreas Kling
ceec1a7d38 AK: Make Vector use size_t for its size and capacity 2020-02-25 14:52:35 +01:00
Andreas Kling
3bbf4610d2 AK: Add a forward declaration header
You can now #include <AK/Forward.h> to get most of the AK types as
forward declarations.

Header dependency explosion is one of the main contributors to compile
times at the moment, so this is a step towards smaller include graphs.
2020-02-14 23:31:18 +01:00
Sergey Bugaev
c0b32f7b76 Meta: Claim copyright for files created by me
This changes copyright holder to myself for the source code files that I've
created or have (almost) completely rewritten. Not included are the files
that were significantly changed by others even though it was me who originally
created them (think HtmlView), or the many other files I've contributed code to.
2020-01-24 15:15:16 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
joshua stein
ac25438d54 Build: clean up build system, use one shared Makefile
Allow everything to be built from the top level directory with just
'make', cleaned with 'make clean', and installed with 'make
install'.  Also support these in any particular subdirectory.

Specifying 'make VERBOSE=1' will print each ld/g++/etc. command as
it runs.

Kernel and early host tools (IPCCompiler, etc.) are built as
object.host.o so that they don't conflict with other things built
with the cross-compiler.
2019-12-20 20:20:54 +01:00
Andreas Kling
6f4c380d95 AK: Use size_t for the length of strings
Using int was a mistake. This patch changes String, StringImpl,
StringView and StringBuilder to use size_t instead of int for lengths.
Obviously a lot of code needs to change as a result of this.
2019-12-09 17:51:21 +01:00
Tommy Nguyen
2eb5793d55 LibMarkdown: Handle CRLF line endings
Previously, MDDocument only split on Unix-style line endings. This adds
a new function to StringView which handles LF, CR and CRLF.
2019-12-02 13:52:42 +01:00
Andreas Kling
c1efa4f336 LibMarkdown: Include a <head> element when rendering MD to HTML
This should really be handled by LibHTML, but just include a <head>
element for now, so generated man pages always have a <head>.
2019-10-30 20:28:44 +01:00
Andreas Kling
517e78a7e2 LibMarkdown: Emit properly formed HTML documents 2019-10-13 12:58:56 +02:00
Andreas Kling
b0d2117bfd LibMarkdown: Avoid emitting <pre> tags for now, to help LibHTML
LibHTML can't handle block children of inline elements just yet.
2019-10-03 16:46:38 +02:00
Sergey Bugaev
30437b0936 LibMarkdown: Implement link support
We can now parse links that like this:

   visit the [SerenityOS home page](http://www.serenityos.org/)

producing proper <a> HTML elements ^)
2019-10-03 08:23:54 +02:00
Andreas Kling
d43c7d55f4 LibMarkdown: Support escaping of special characters
This allows you to escape function\_names\_like\_this() :^)
2019-09-28 20:51:46 +02:00
Sergey Bugaev
2e80b2b32f Libraries: Add LibMarkdown 2019-09-28 18:29:42 +02:00