1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

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.
This commit is contained in:
Tommy Nguyen 2019-12-02 07:42:33 -05:00 committed by Andreas Kling
parent 035c4e15f4
commit 2eb5793d55
4 changed files with 68 additions and 1 deletions

View file

@ -46,6 +46,12 @@ public:
StringView substring_view(int start, int length) const;
Vector<StringView> split_view(char, bool keep_empty = false) const;
// Create a Vector of StringViews split by line endings. As of CommonMark
// 0.29, the spec defines a line ending as "a newline (U+000A), a carriage
// return (U+000D) not followed by a newline, or a carriage return and a
// following newline.".
Vector<StringView> lines(bool consider_cr = true) const;
// FIXME: These should be shared between String and StringView somehow!
unsigned to_uint(bool& ok) const;
int to_int(bool& ok) const;