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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#ifndef NEWSBOAT_ITEMRENDERER_H_
#define NEWSBOAT_ITEMRENDERER_H_
#include <memory>
#include <string>
#include <vector>
#include "links.h"
#include "textformatter.h"
namespace newsboat {
class ConfigContainer;
class RssItem;
/// \brief Creates different textual representations of an RssItem.
namespace item_renderer {
enum class OutputFormat {
PlainText,
StflRichText,
};
/// \brief Returns feed's title of the item, or some replacement value if
/// the title isn't available.
std::string get_feedtitle(std::shared_ptr<RssItem> item);
/// \brief Splits text into lines marked as wrappable
void render_plaintext(const std::string& source,
std::vector<std::pair<LineType, std::string>>& lines, OutputFormat format);
/// \brief Returns plain-text representation of the RssItem.
///
/// Markup is mostly stripped. Links are numbered and tagged. The text is
/// wrapped at the width specified by the `text-width` setting.
std::string to_plain_text(
ConfigContainer& cfg,
std::shared_ptr<RssItem> item);
/// \brief Returns RssItem as STFL list.
///
/// `html-renderer` settings controls what tool is used to render HTML. \a
/// text_width dictates where text is wrapped. \a window_width dictates
/// where URLs are wrapped. \a rxman rules for \a location are used to
/// highlight the resulting text. \a links is filled with all the links
/// found in the article (which is useful for article view, which lets
/// users open the links by their number).
std::pair<std::string, size_t> to_stfl_list(
ConfigContainer& cfg,
std::shared_ptr<RssItem> item,
unsigned int text_width,
unsigned int window_width,
RegexManager* rxman,
const std::string& location,
Links& links);
/// \brief Returns RssItem's text source as STFL list.
///
/// \a text_width dictates where text is wrapped. \a window_width dictates
/// where URLs are wrapped. \a rxman rules for \a location are used to
/// highlight the resulting text.
std::pair<std::string, size_t> source_to_stfl_list(
std::shared_ptr<RssItem> item,
unsigned int text_width,
unsigned int window_width,
RegexManager* rxman,
const std::string& location);
};
} // namespace newsboat
#endif /* NEWSBOAT_ITEMRENDERER_H_ */
|