42#include "formatting_style.h"
43#include "parser_manager.h"
44#include "parser_parameters.h"
56 inline static const std::string
TAG_P =
"p";
58 inline static const std::string
TAG_BR =
"br";
59 inline static const std::string
TAG_B =
"b";
61 inline static const std::string
TAG_I =
"i";
63 inline static const std::string
TAG_U =
"u";
65 inline static const std::string
TAG_TABLE =
"table";
67 inline static const std::string
TAG_TR =
"tr";
69 inline static const std::string
TAG_TD =
"td";
71 inline static const std::string
TAG_TEXT =
"#text";
72 inline static const std::string
TAG_LINK =
"a";
74 inline static const std::string
TAG_STYLE =
"style";
77 inline static const std::string
TAG_LIST =
"list";
82 inline static const std::string
TAG_MAIL =
"mail";
94 inline static const std::string
TAG_PAGE =
"new-page";
106 explicit Info(
const std::string &tagName =
"",
const std::string &plainText =
"",
const std::map<std::string, std::any> &attrs = {})
108 plain_text(plainText),
113 std::optional<T> getAttributeValue(
const std::string &name)
const
115 auto attribute_value = attributes.find(name);
116 if (attribute_value!= attributes.end() && attribute_value->second.type() ==
typeid(T))
118 return std::any_cast<T>(attribute_value->second);
124typedef std::function<void(Info &info)> NewNodeCallback;
136 explicit Parser(
const std::shared_ptr<doctotext::ParserManager> &inParserManager =
nullptr);
161 std::ostream& getLogOutStream()
const;
163 bool isVerboseLogging()
const;
165 Info sendTag(
const std::string& tag_name,
const std::string& text =
"",
const std::map<std::string, std::any> &attributes = {})
const;
166 Info sendTag(
const Info &info)
const;
168 std::shared_ptr<doctotext::ParserManager> m_parser_manager;
172 struct DllExport Implementation;
173 struct DllExport ImplementationDeleter {
void operator() (Implementation*); };
174 std::unique_ptr<Implementation, ImplementationDeleter> base_impl;
Abstract class for all parsers.
virtual void parse() const =0
Executes text parsing.
Parser(const std::shared_ptr< doctotext::ParserManager > &inParserManager=nullptr)
virtual Parser & addOnNewNodeCallback(NewNodeCallback callback)
Adds new function to execute when new node will be created. Node is a part of parsed text....
FormattingStyle getFormattingStyle() const
Loads FormattingStyle from ParserParameters.
Stores list of parsers parameters. Every parser can query ParserParameter for a specific parameter....
Contains set of basic tags using in parsers.
static const std::string TAG_B
Tag for bold.
static const std::string TAG_ATTACHMENT
Tag for attachment. If you set skip in this tag, then the attachment won't be parsed....
static const std::string TAG_FOLDER
Tag for folder. If you set skip in this tag, then the folder won't be parsed. Attributes: "name": std...
static const std::string TAG_TEXT
Tag for text.
static const std::string TAG_MAIL_BODY
Tag for mail body.
static const std::string TAG_MAIL
Tag for mail. Attributes: "subject": std::string, "date": uint (unix timestamp).
static const std::string TAG_P
Tag for paragraph.
static const std::string TAG_CLOSE_TR
Tag for closing table row.
static const std::string TAG_PAGE
Tag for page. This tag is sent before parsing the page, so if we set in this tag, then the page won't...
static const std::string TAG_CLOSE_B
Tag for closing bold.
static const std::string TAG_TABLE
Tag for table.
static const std::string TAG_CLOSE_ATTACHMENT
Tag for closing attachment.
static const std::string TAG_CLOSE_LIST_ITEM
Tag for closing list item.
static const std::string TAG_CLOSE_PAGE
Tag for closing page.
static const std::string TAG_STYLE
Tag for style.
static const std::string TAG_COMMENT
Tag for comments. Attributes: "author": std::string, "time": std::string (format:(yyyy-mm-ddThh:mm:ss...
static const std::string TAG_TR
Tag for table row.
static const std::string TAG_TD
Tag for table cell.
static const std::string TAG_CLOSE_P
Tag for closing paragraph.
static const std::string TAG_CLOSE_STYLE
Tag for close style.
static const std::string TAG_U
Tag for underline.
static const std::string TAG_BR
Tag for line break.
static const std::string TAG_CLOSE_LINK
Tag for link.
static const std::string TAG_CLOSE_TD
Tag for closing table cell.
static const std::string TAG_METADATA
Tag for metadata.
static const std::string TAG_CLOSE_I
Tag for closing italic.
static const std::string TAG_I
Tag for italic.
static const std::string TAG_CLOSE_TABLE
Tag for closing table.
static const std::string TAG_LINK
Tag for link. Attributes: "url": std::string.
static const std::string TAG_CLOSE_U
Tag for closing underline.
static const std::string TAG_CLOSE_MAIL_BODY
Tag for closing mail body.
static const std::string TAG_CLOSE_MAIL
Tag for closing mail.
static const std::string TAG_CLOSE_LIST
Tag for closing list.
static const std::string TAG_CLOSE_FOLDER
Tag for closing folder.
static const std::string TAG_LIST_ITEM
Tag for list item.
static const std::string TAG_LIST
Tag for list. Attributes: "is_ordered": bool (def. is false), "list_style_prefix": std::string.
std::map< std::string, std::any > attributes
tag attributes
std::string tag_name
tag name
std::string plain_text
Stores text from last parsed node.