mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibMarkdown: Add render_to_inline_html() to Document
This api is useful when you want to render a markdown document to HTML, but you want to embed it in a existing html document.
This commit is contained in:
parent
83680934e5
commit
57ec19f963
Notes:
sideshowbarker
2024-07-18 04:59:35 +09:00
Author: https://github.com/petelliott Commit: https://github.com/SerenityOS/serenity/commit/57ec19f9638 Pull-request: https://github.com/SerenityOS/serenity/pull/9679 Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 12 additions and 2 deletions
|
@ -28,13 +28,22 @@ String Document::render_to_html() const
|
|||
builder.append("</head>\n");
|
||||
builder.append("<body>\n");
|
||||
|
||||
builder.append(render_to_inline_html());
|
||||
|
||||
builder.append("</body>\n");
|
||||
builder.append("</html>\n");
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
String Document::render_to_inline_html() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
for (auto& block : m_blocks) {
|
||||
auto s = block.render_to_html();
|
||||
builder.append(s);
|
||||
}
|
||||
|
||||
builder.append("</body>\n");
|
||||
builder.append("</html>\n");
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Markdown {
|
|||
class Document final {
|
||||
public:
|
||||
String render_to_html() const;
|
||||
String render_to_inline_html() const;
|
||||
String render_for_terminal(size_t view_width = 0) const;
|
||||
|
||||
static OwnPtr<Document> parse(const StringView&);
|
||||
|
|
Loading…
Add table
Reference in a new issue