libquentier  0.4.0
The library for rich desktop clients of Evernote service
Classes | Public Member Functions | Static Public Member Functions | List of all members
quentier::ENMLConverter Class Reference

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>

Classes

struct  EnexExportTags
 The EnexExportTags struct is a C++98 style scoped enum which allows to specify whether export of note(s) to ENEX should include the names of note's tags. More...
 
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...
 

Public Member Functions

bool htmlToNoteContent (const QString &html, QString &noteContent, DecryptedTextManager &decryptedTextManager, ErrorString &errorDescription, const QVector< SkipHtmlElementRule > &skipRules=QVector< SkipHtmlElementRule >()) 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 More...
 
bool htmlToQTextDocument (const QString &html, QTextDocument &doc, ErrorString &errorDescription, const QVector< SkipHtmlElementRule > &skipRules=QVector< SkipHtmlElementRule >()) const
 
bool noteContentToHtml (const QString &noteContent, 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 > &notes, const QHash< QString, QString > &tagNamesByTagLocalUids, const EnexExportTags::type exportTagsOption, QString &enex, ErrorString &errorDescription, const QString &version=QString()) const
 exportNotesToEnex - exports either a single note or a set of notes into ENEX format More...
 
bool 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. More...
 

Static Public Member Functions

static bool noteContentToPlainText (const QString &noteContent, QString &plainText, ErrorString &errorMessage)
 
static bool noteContentToListOfWords (const QString &noteContent, QStringList &listOfWords, ErrorString &errorMessage, QString *plainText=Q_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)
 

Detailed Description

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.

Member Function Documentation

◆ 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::type  exportTagsOption,
QString &  enex,
ErrorString errorDescription,
const QString &  version = QString() 
) 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 = QVector< SkipHtmlElementRule >() 
) 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