mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:58:12 +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,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <LibMarkdown/Block.h>
|
||||
#include <LibMarkdown/Text.h>
|
||||
|
||||
|
@ -33,11 +34,16 @@ namespace Markdown {
|
|||
|
||||
class CodeBlock final : public Block {
|
||||
public:
|
||||
virtual ~CodeBlock() override {}
|
||||
CodeBlock(Text&& style_spec, const String& code)
|
||||
: m_code(move(code))
|
||||
, m_style_spec(move(style_spec))
|
||||
{
|
||||
}
|
||||
virtual ~CodeBlock() override { }
|
||||
|
||||
virtual String render_to_html() const override;
|
||||
virtual String render_for_terminal() const override;
|
||||
virtual bool parse(Vector<StringView>::ConstIterator& lines) override;
|
||||
static OwnPtr<CodeBlock> parse(Vector<StringView>::ConstIterator& lines);
|
||||
|
||||
private:
|
||||
String style_language() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue