Coverage Report

Created: 2026-02-16 07:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibMarkdown/Document.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/ByteString.h>
10
#include <AK/OwnPtr.h>
11
#include <AK/String.h>
12
#include <LibMarkdown/Block.h>
13
#include <LibMarkdown/ContainerBlock.h>
14
15
namespace Markdown {
16
17
class Document final {
18
public:
19
    Document(OwnPtr<ContainerBlock> container)
20
5.70k
        : m_container(move(container))
21
5.70k
    {
22
5.70k
    }
23
    ByteString render_to_html(StringView extra_head_contents = ""sv) const;
24
    ByteString render_to_inline_html() const;
25
    ErrorOr<String> render_for_terminal(size_t view_width = 0) const;
26
27
    /*
28
     * Walk recursively through the document tree. Returning `RecursionDecision::Recurse` from
29
     * `Visitor::visit` proceeds with the next element of the pre-order walk, usually a child element.
30
     * Returning `RecursionDecision::Continue` skips the subtree, and usually proceeds with the next
31
     * sibling. Returning `RecursionDecision::Break` breaks the recursion, with no further calls to
32
     * any of the `Visitor::visit` methods.
33
     *
34
     * Note that `walk()` will only return `RecursionDecision::Continue` or `RecursionDecision::Break`.
35
     */
36
    RecursionDecision walk(Visitor&) const;
37
38
    static OwnPtr<Document> parse(StringView);
39
40
private:
41
    OwnPtr<ContainerBlock> m_container;
42
};
43
44
}