Coverage Report

Created: 2026-11-13 08:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibMarkdown/BlockQuote.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <AK/StringBuilder.h>
8
#include <AK/Vector.h>
9
#include <LibMarkdown/BlockQuote.h>
10
#include <LibMarkdown/Visitor.h>
11
12
namespace Markdown {
13
14
ByteString BlockQuote::render_to_html(bool) const
15
0
{
16
0
    StringBuilder builder;
17
0
    builder.append("<blockquote>\n"sv);
18
0
    builder.append(m_contents->render_to_html());
19
0
    builder.append("</blockquote>\n"sv);
20
0
    return builder.to_byte_string();
21
0
}
22
23
Vector<ByteString> BlockQuote::render_lines_for_terminal(size_t view_width) const
24
0
{
25
0
    Vector<ByteString> lines;
26
0
    size_t child_width = view_width < 4 ? 0 : view_width - 4;
27
0
    for (auto& line : m_contents->render_lines_for_terminal(child_width))
28
0
        lines.append(ByteString::formatted("    {}", line));
29
30
0
    return lines;
31
0
}
32
33
RecursionDecision BlockQuote::walk(Visitor& visitor) const
34
0
{
35
0
    RecursionDecision rd = visitor.visit(*this);
36
0
    if (rd != RecursionDecision::Recurse)
37
0
        return rd;
38
39
0
    return m_contents->walk(visitor);
40
0
}
41
42
OwnPtr<BlockQuote> BlockQuote::parse(LineIterator& lines)
43
16.7M
{
44
16.7M
    lines.push_context(LineIterator::Context::block_quote());
45
16.7M
    if (lines.is_end()) {
46
12.1M
        lines.pop_context();
47
12.1M
        return {};
48
12.1M
    }
49
50
4.68M
    auto contents = ContainerBlock::parse(lines);
51
4.68M
    lines.pop_context();
52
53
4.68M
    if (!contents)
54
0
        return {};
55
56
4.68M
    return make<BlockQuote>(move(contents));
57
4.68M
}
58
59
}