The ENMLConverter class encapsulates a set of methods and helper data structures for performing the conversions between ENML and other note content formats, namely HTML.
More...
#include <ENMLConverter.h>
|
struct | NoteContentToHtmlExtraData |
|
class | SkipHtmlElementRule |
| The SkipHtmlElementRule class describes the set of rules for HTML -> ENML conversion about the HTML elements that should not be actually converted to ENML due to their nature of being "helper" elements for the display or functioning of something within the note editor's page. The HTML -> ENML conversion would ignore tags and attributes forbidden by ENML even without these rules conditionally preserving or skipping the contents and nested elements of skipped elements. More...
|
|
|
enum class | EnexExportTags { Yes = 0
, No
} |
| The EnexExportTags enum allows to specify whether export of note(s) to ENEX should include the names of note's tags.
|
|
|
bool | htmlToNoteContent (const QString &html, QString ¬eContent, DecryptedTextManager &decryptedTextManager, ErrorString &errorDescription, const QVector< SkipHtmlElementRule > &skipRules={}) const |
|
bool | cleanupExternalHtml (const QString &inputHtml, QString &cleanedUpHtml, ErrorString &errorDescription) const |
| cleanupExternalHtml method cleans up a piece of HTML coming from some external source: the cleanup includes the removal (or replacement with equivalents/alternatives) of any tags and attributes not supported by the ENML representation of note page's HTML
|
|
bool | htmlToQTextDocument (const QString &html, QTextDocument &doc, ErrorString &errorDescription, const QVector< SkipHtmlElementRule > &skipRules={}) const |
|
bool | noteContentToHtml (const QString ¬eContent, QString &html, ErrorString &errorDescription, DecryptedTextManager &decryptedTextManager, NoteContentToHtmlExtraData &extraData) const |
|
bool | validateEnml (const QString &enml, ErrorString &errorDescription) const |
|
bool | validateAndFixupEnml (QString &enml, ErrorString &errorDescription) const |
|
bool | exportNotesToEnex (const QVector< Note > ¬es, const QHash< QString, QString > &tagNamesByTagLocalUids, const EnexExportTags exportTagsOption, QString &enex, ErrorString &errorDescription, const QString &version={}) const |
| exportNotesToEnex exports either a single note or a set of notes into ENEX format
|
|
bool | importEnex (const QString &enex, QVector< Note > ¬es, QHash< QString, QStringList > &tagNamesByNoteLocalUid, ErrorString &errorDescription) const |
| importEnex reads the content of input ENEX file and converts it into a set of notes and tag names.
|
|
|
static bool | noteContentToPlainText (const QString ¬eContent, QString &plainText, ErrorString &errorMessage) |
|
static bool | noteContentToListOfWords (const QString ¬eContent, QStringList &listOfWords, ErrorString &errorMessage, QString *plainText=nullptr) |
|
static QStringList | plainTextToListOfWords (const QString &plainText) |
|
static QString | toDoCheckboxHtml (const bool checked, const quint64 idNumber) |
|
static QString | encryptedTextHtml (const QString &encryptedText, const QString &hint, const QString &cipher, const size_t keyLength, const quint64 enCryptIndex) |
|
static QString | decryptedTextHtml (const QString &decryptedText, const QString &encryptedText, const QString &hint, const QString &cipher, const size_t keyLength, const quint64 enDecryptedIndex) |
|
static QString | resourceHtml (const Resource &resource, ErrorString &errorDescription) |
|
static void | escapeString (QString &string, const bool simplify=true) |
|
The ENMLConverter class encapsulates a set of methods and helper data structures for performing the conversions between ENML and other note content formats, namely HTML.
◆ cleanupExternalHtml()
bool quentier::ENMLConverter::cleanupExternalHtml |
( |
const QString & |
inputHtml, |
|
|
QString & |
cleanedUpHtml, |
|
|
ErrorString & |
errorDescription |
|
) |
| const |
cleanupExternalHtml method cleans up a piece of HTML coming from some external source: the cleanup includes the removal (or replacement with equivalents/alternatives) of any tags and attributes not supported by the ENML representation of note page's HTML
- Parameters
-
inputHtml | - the input HTML to be cleaned up |
cleanedUpHtml | - the result of the method's work |
errorDescription | - the textual description of the error if conversion of input HTML into QTextDocument has failed |
- Returns
- true in case of successful conversion, false otherwise
◆ exportNotesToEnex()
bool quentier::ENMLConverter::exportNotesToEnex |
( |
const QVector< Note > & |
notes, |
|
|
const QHash< QString, QString > & |
tagNamesByTagLocalUids, |
|
|
const EnexExportTags |
exportTagsOption, |
|
|
QString & |
enex, |
|
|
ErrorString & |
errorDescription, |
|
|
const QString & |
version = {} |
|
) |
| const |
exportNotesToEnex exports either a single note or a set of notes into ENEX format
- Parameters
-
notes | The notes to be exported into the enex format. The connection of particular notes to tags is expected to follow from note's tag local uids. In other words, if some note has no tag local uids, its corresponding fragment of ENEX won't contain tag names associated with the note |
tagNamesByTagLocalUids | Tag names for all tag local uids across all passed in notes. The lack of any tag name for any tag local uid is considered an error and the overall export attempt fails |
exportTagsOption | Whether the export to ENEX should include the names of notes' tags |
enex | The output of the method |
errorDescription | The textual description of the error, if any |
version | Optional "version" tag for the ENEX. If not set, the corresponding ENEX tag is set to empty value |
- Returns
- True if the export completed successfully, false otherwise
◆ htmlToQTextDocument()
bool quentier::ENMLConverter::htmlToQTextDocument |
( |
const QString & |
html, |
|
|
QTextDocument & |
doc, |
|
|
ErrorString & |
errorDescription, |
|
|
const QVector< SkipHtmlElementRule > & |
skipRules = {} |
|
) |
| const |
Converts the passed in HTML into its simplified form acceptable by QTextDocument (see http://doc.qt.io/qt-5/richtext-html-subset.html for the list of elements supported by QTextDocument)
- Parameters
-
html | - the input HTML which needs to be converted to QTextDocument |
doc | - QTextDocument filled with the result of the method's work |
errorDescription | - the textual description of the error if conversion of input HTML into QTextDocument has failed |
skipRules | - rules for skipping the particular elements |
- Returns
- true in case of successful conversion, false otherwise
◆ importEnex()
bool quentier::ENMLConverter::importEnex |
( |
const QString & |
enex, |
|
|
QVector< Note > & |
notes, |
|
|
QHash< QString, QStringList > & |
tagNamesByNoteLocalUid, |
|
|
ErrorString & |
errorDescription |
|
) |
| const |
importEnex reads the content of input ENEX file and converts it into a set of notes and tag names.
- Parameters
-
enex | The input ENEX file contents |
notes | Notes read from the ENEX |
tagNamesByNoteLocalUid | Tag names per each read note; it is the responsibility of the method caller to find the actual tags corresponding to these names and set the tag local uids and/or guids to the note |
errorDescription | The textual descrition of the error if the ENEX file could not be read and converted into a set of notes and tag names for them |
- Returns
- True of the ENEX file was read and converted into a set of notes and tag names successfully, false otherwise