mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +00:00
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>.
This commit is contained in:
parent
7ca562b200
commit
20faa93cb0
15 changed files with 110 additions and 64 deletions
|
@ -26,12 +26,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace Markdown {
|
||||
|
||||
class Text final {
|
||||
AK_MAKE_NONCOPYABLE(Text);
|
||||
public:
|
||||
struct Style {
|
||||
bool emph { false };
|
||||
|
@ -46,14 +48,21 @@ public:
|
|||
Style style;
|
||||
};
|
||||
|
||||
Text(Text&& text) = default;
|
||||
|
||||
const Vector<Span>& spans() const { return m_spans; }
|
||||
|
||||
String render_to_html() const;
|
||||
String render_for_terminal() const;
|
||||
|
||||
bool parse(const StringView&);
|
||||
static Optional<Text> parse(const StringView&);
|
||||
|
||||
private:
|
||||
Text(Vector<Span>&& spans)
|
||||
: m_spans(move(spans))
|
||||
{
|
||||
}
|
||||
|
||||
Vector<Span> m_spans;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue