blob: 4d21baad4a8ebc3627957ed6437e105f43a65b68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/*
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Noncopyable.h>
#include <AK/String.h>
#include <AK/Vector.h>
namespace Markdown {
class Text final {
AK_MAKE_NONCOPYABLE(Text);
public:
struct Style {
bool emph { false };
bool strong { false };
bool code { false };
String href;
String img;
};
struct Span {
String text;
Style style;
};
explicit Text(String&& text);
Text(Text&& text) = default;
Text() = default;
Text& operator=(Text&&) = default;
const Vector<Span>& spans() const { return m_spans; }
String render_to_html() const;
String render_for_terminal() const;
static Optional<Text> parse(const StringView&);
private:
Text(Vector<Span>&& spans)
: m_spans(move(spans))
{
}
Vector<Span> m_spans;
};
}
|