Welcome: Get LibWeb to parse Markdown documents for us
This commit is contained in:
parent
28a591ce7b
commit
1da53ef854
Notes:
sideshowbarker
2024-07-17 06:34:06 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/1da53ef854 Pull-request: https://github.com/SerenityOS/serenity/pull/15365 Reviewed-by: https://github.com/linusg ✅
2 changed files with 3 additions and 13 deletions
|
@ -17,9 +17,7 @@
|
|||
#include <LibGUI/Process.h>
|
||||
#include <LibGfx/Font/BitmapFont.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
#include <LibWebView/OutOfProcessWebView.h>
|
||||
#include <serenity.h>
|
||||
|
||||
WelcomeWidget::WelcomeWidget()
|
||||
{
|
||||
|
@ -104,15 +102,7 @@ void WelcomeWidget::open_and_parse_tips_file()
|
|||
|
||||
void WelcomeWidget::open_and_parse_readme_file()
|
||||
{
|
||||
auto file = Core::File::construct("/home/anon/README.md");
|
||||
if (!file->open(Core::OpenMode::ReadOnly))
|
||||
return;
|
||||
|
||||
auto document = Markdown::Document::parse(file->read_all());
|
||||
if (document) {
|
||||
auto html = document->render_to_html();
|
||||
m_web_view->load_html(html, URL::create_with_file_protocol("/home/anon/README.md"));
|
||||
}
|
||||
m_web_view->load(URL::create_with_file_scheme("/home/anon/README.md"));
|
||||
}
|
||||
|
||||
void WelcomeWidget::set_random_tip()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -11,7 +11,6 @@
|
|||
#include <LibGUI/Icon.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <unistd.h>
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
|
@ -22,6 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(Core::System::unveil("/res", "r"));
|
||||
TRY(Core::System::unveil("/home", "r"));
|
||||
TRY(Core::System::unveil("/tmp/user/%uid/portal/filesystemaccess", "rw"));
|
||||
TRY(Core::System::unveil("/tmp/user/%uid/portal/webcontent", "rw"));
|
||||
TRY(Core::System::unveil("/bin/Help", "x"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
|
Loading…
Add table
Reference in a new issue