html2md
v1.7.0
Simple and fast HTML to Markdown converter
|
Class for converting HTML to Markdown. More...
#include <html2md.h>
Public Member Functions | |
Converter (const std::string &html, struct Options *options=nullptr) | |
Standard initializer, takes HTML as parameter. Also prepares everything. | |
std::string | convert () |
Convert HTML into Markdown. | |
Converter * | appendToMd (char ch) |
Append a char to the Markdown. | |
Converter * | appendToMd (const char *str) |
Append a char* to the Markdown. | |
Converter * | appendToMd (const std::string &s) |
Append a string to the Markdown. | |
Converter * | appendBlank () |
Appends a ' ' in certain cases. | |
void | addHtmlSymbolConversion (const std::string &htmlSymbol, const std::string &replacement) |
Add an HTML symbol conversion. | |
void | removeHtmlSymbolConversion (const std::string &htmlSymbol) |
Remove an HTML symbol conversion. | |
void | clearHtmlSymbolConversions () |
Clear all HTML symbol conversions. | |
bool | ok () const |
Checks if everything was closed properly(in the HTML). | |
void | reset () |
Reset the generated Markdown. | |
bool | operator== (const Converter *c) const |
Checks if the HTML matches and the options are the same. | |
bool | operator== (const Converter &c) const |
operator bool () const | |
Returns ok(). | |
Class for converting HTML to Markdown.
This class converts HTML to Markdown. There is also a static wrapper for this class (see html2md::Convert).
Option 1: Use the class:
Option 2: Use the static wrapper:
Advanced: use Options:
|
inlineexplicit |
Standard initializer, takes HTML as parameter. Also prepares everything.
html | The HTML as std::string. |
options | Options for the Conversation. See html2md::Options() for more. |
This is the default initializer.
You can use appendToMd() to append something to the beginning of the generated output.
|
inline |
Add an HTML symbol conversion.
htmlSymbol | The HTML symbol to convert |
replacement | The replacement string |
Converter * html2md::Converter::appendBlank | ( | ) |
Appends a ' ' in certain cases.
This function appends ' ' if:
*
\n
aka newline Definition at line 239 of file html2md.cpp.
Converter * html2md::Converter::appendToMd | ( | char | ch | ) |
Append a char to the Markdown.
ch | The char to append. |
Definition at line 197 of file html2md.cpp.
Converter * html2md::Converter::appendToMd | ( | const char * | str | ) |
Append a char* to the Markdown.
str | The char* to append. |
Definition at line 221 of file html2md.cpp.
|
inline |
|
inline |
|
nodiscard |
Convert HTML into Markdown.
This function actually converts the HTML into Markdown. It also cleans up the Markdown so you don't have to do anything.
Definition at line 393 of file html2md.cpp.
|
nodiscard |
Checks if everything was closed properly(in the HTML).
Definition at line 249 of file html2md.cpp.
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
void html2md::Converter::reset | ( | ) |
Reset the generated Markdown.
Definition at line 1039 of file html2md.cpp.