diff options
author | FalseHonesty <thefalsehonesty@gmail.com> | 2020-05-11 13:55:31 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-30 00:32:12 +0200 |
commit | 7ca562b200e9a15bc02bdd23f5c9faedf53e6a26 (patch) | |
tree | ac910d25df68cf9145b7e9123daebe5a54f30a4c /Applications | |
parent | 9a2177437bd197fc53cb1296a52f13afb5c64475 (diff) | |
download | serenity-7ca562b200e9a15bc02bdd23f5c9faedf53e6a26.zip |
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.
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/Help/main.cpp | 7 | ||||
-rw-r--r-- | Applications/TextEditor/TextEditorWidget.cpp | 6 |
2 files changed, 6 insertions, 7 deletions
diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index 3455d9e7d9..ffe41c3e69 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -128,11 +128,10 @@ int main(int argc, char* argv[]) auto buffer = file->read_all(); StringView source { (const char*)buffer.data(), buffer.size() }; - Markdown::Document md_document; - bool success = md_document.parse(source); - ASSERT(success); + auto md_document = Markdown::Document::parse(source); + ASSERT(md_document); - String html = md_document.render_to_html(); + String html = md_document->render_to_html(); auto html_document = Web::parse_html_document(html); page_view.set_document(html_document); diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index 6884335e2c..2f550507c2 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -560,9 +560,9 @@ void TextEditorWidget::set_markdown_preview_enabled(bool enabled) void TextEditorWidget::update_markdown_preview() { - Markdown::Document document; - if (document.parse(m_editor->text())) { - auto html = document.render_to_html(); + auto document = Markdown::Document::parse(m_editor->text()); + if (document) { + auto html = document->render_to_html(); auto html_document = Web::parse_html_document(html, URL::create_with_file_protocol(m_path)); m_page_view->set_document(html_document); } |