![]() |
JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
|
a LaTeX parser for JKQTMathText More...
#include <jkqtmathtextlatexparser.h>
Public Member Functions | |
| JKQTMathTextLatexParser (JKQTMathText *parent=nullptr) | |
| class constructor | |
| ~JKQTMathTextLatexParser () | |
| class destructor | |
| virtual JKQTMathTextNode * | parse (const QString &text, JKQTMathText::ParseOptions options=JKQTMathText::DefaultParseOptions) override |
| parse the given mathematical markup string. | |
| Public Member Functions inherited from JKQTMathTextParser | |
| JKQTMathTextParser (JKQTMathText *parent=nullptr) | |
| class constructor | |
| virtual | ~JKQTMathTextParser () |
| class destructor | |
| JKQTMathText * | getParentMathText () |
| parentMathText | |
| const JKQTMathText * | getParentMathText () const |
| parentMathText | |
Protected Types | |
| enum | tokenType { MTTnone , MTTtext , MTTinstruction , MTTinstructionNewline , MTTinstructionVerbatim , MTTinstructionVerbatimVisibleSpace , MTTinstructionBegin , MTTinstructionEnd , MTTunderscore , MTThat , MTTdollar , MTTopenbrace , MTTclosebrace , MTTopenbracket , MTTclosebracket , MTTwhitespace , MTTampersand , MTThyphen , MTTendash , MTTemdash , MTTtilde } |
| the token types that may arrise in the string More... | |
Protected Member Functions | |
| tokenType | getToken () |
| tokenizer for the LaTeX parser | |
| void | giveBackToTokenizer (size_t count) |
| returns some characters to the Tokenizer | |
| JKQTMathTextNode * | parseInstruction (bool *_foundError=nullptr, bool *getNew=nullptr) |
| parses a single instruction (including it's parameters) | |
| JKQTMathTextNode * | parseLatexString (bool get, JKQTMathTextBraceType quitOnClosingBrace=JKQTMathTextBraceType::MTBTAny, const QString &quitOnEnvironmentEnd=QString(""), bool quitOnClosingBracket=false) |
| parse a LaTeX string | |
| JKQTMathTextNode * | parseMath (bool get) |
| parse a LaTeX math environment | |
| JKQTMathTextVerticalListNode * | parseMultilineLatexString (bool get, const QString &quitOnEnvironmentEnd=QString(""), JKQTMathTextHorizontalAlignment _alignment=MTHALeft, double _linespacingFactor=1.0, JKQTMathTextLineSpacingMode spacingMode_=MTSMDefaultSpacing, JKQTMathTextVerticalOrientation _verticalOrientation=MTVOFirstLine) |
| parse a LaTeX string with linebreaks | |
| QString | parseSingleString (bool get) |
| parses a string, i.e. a sequence of text and whitespaces. returns after any other token was found | |
| QStringList | parseStringParams (bool get, size_t Nparams, bool *foundError=nullptr) |
parses a list of string-arguments, i.e. {p1}{p2}{...} | |
| QString | readUntil (bool get, const QString &endsequence, bool removeFirstlineWhitespace=false) |
| read all text without tokenizing, until the sequence endsequence is found. | |
| Protected Member Functions inherited from JKQTMathTextParser | |
| void | addToErrorList (const QString &error) |
| adds a new error to the JKQTMathText referenced by parentMathText | |
| void | clearErrorList () |
| clears the error list in the JKQTMathText referenced by parentMathText | |
Static Protected Member Functions | |
| static void | initStaticStructures () |
| fills all static data structures, if they are still empty | |
| static QString | tokenType2String (tokenType type) |
| convert a tokenType into a string, e.g. for debugging output | |
Protected Attributes | |
| tokenType | currentToken |
| used by the tokenizer. type of the current token | |
| int | currentTokenID |
| used by the tokenizer. Points to the currently read character in parseString | |
| QString | currentTokenName |
| used by the tokenizer. Name of the current token, id applicable | |
| QMap< QString, size_t > | lastMatrixLineCommandCount |
returns the number of \hline , \hdashline , ... commands in the last parseLatexString() call | |
| JKQTMathTextBraceType | lastRightBraceType |
the JKQTMathTextBraceType associated with the last \right command the parser encountered | |
| QString | parseString |
| used by the tokenizer. The string to be parsed | |
| bool | parsinginMathTextStyle |
| used by the parser. indicates whether to use textstyle or displaystyle in math-mode | |
| bool | parsingMathEnvironment |
| used by the parser. indicates whether we are in a math environment | |
| Protected Attributes inherited from JKQTMathTextParser | |
| JKQTMathText * | parentMathText |
| JKQTMathText that instanciated and uses this parser. | |
Static Protected Attributes | |
| static QHash< QString, QChar > | accentLetters |
maps instructions for accents in text-mode (e.g. \'a or \ae ) to the corresponding unicode character | |
| static QSet< int > | accentLetters_LenBackslash |
| lists all lengths of keys in accentLetters that start with a backslash | |
| static QSet< int > | accentLetters_LenCurly |
| lists all lengths of keys in accentLetters that start with a curly brace | |
| static QHash< QString, double > | big_instructions_family |
maps instructions for braces with fixed size, e.g \bigl to the magnification factor of the brace versus the base font | |
| static QSet< QChar > | mathEnvironmentSpecialChars |
| characters that require special treatment in math mode | |
| static QSet< QChar > | mathEnvironmentSpecialEndChars |
| characters that require special treatment in math mode | |
| static QSet< QString > | mathEnvironmentSpecialText |
| characters that have to be replaced by the correspcoting JKQTMathTextSymbolNode in math mode | |
| static QSet< QChar > | SingleCharInstructions |
| single character instructions | |
| static QSet< QChar > | TokenCharacters |
| characters that initiate a new token | |
a LaTeX parser for JKQTMathText
JKQTMathText is a self-contained mathematical markup renderer for Qt. It is used to renderer labels in JKQTPlotter/JKQTBasePlotter, but can be used independently.
That class is responsible for rendering a memory representation of mathematical markup, but relies on the current class JKQTMathTextLatexParser to parse a LaTeX string into the mentioned memory representation.
In particular JKQTMathTextLatexParser actually parses e.g. a LaTeX string and draws it in pure C++. It does NOT rely on an installed LaTeX for the rendering!
|
protected |
the token types that may arrise in the string
| JKQTMathTextLatexParser::JKQTMathTextLatexParser | ( | JKQTMathText * | parent = nullptr | ) |
class constructor
| JKQTMathTextLatexParser::~JKQTMathTextLatexParser | ( | ) |
class destructor
|
protected |
tokenizer for the LaTeX parser
|
protected |
returns some characters to the Tokenizer
|
staticprotected |
fills all static data structures, if they are still empty
|
overridevirtual |
parse the given mathematical markup string.
| text | the markup to be parsed |
| options | Options for parsing, |
nullptr on failure. Implements JKQTMathTextParser.
|
protected |
parses a single instruction (including it's parameters)
| [out] | _foundError | will be set to true if an error occured (unexpected token) or false otherwise |
| [out] | getNew | returns true if the parser has to call getToken() to go on |
nullptr on error (then also _foundError is set true )
|
protected |
parse a LaTeX string
| get | if true this calls getToken() |
| quitOnClosingBrace | if unequal MTBTAny, this returns if the given closing brace is found |
| quitOnEnvironmentEnd | wuit if \end{quitOnEnvironmentEnd} is found |
| quitOnClosingBracket | if true, quits on encountering a MTTclosebracket token |
|
protected |
parse a LaTeX math environment
|
protected |
parse a LaTeX string with linebreaks
| get | if true this calls getToken() |
| quitOnEnvironmentEnd | wuit if \end{quitOnEnvironmentEnd} is found |
| _alignment | horizontal alignment of the JKQTMathTextVerticalListNode |
| _linespacingFactor | line spacing factor of the lines |
| spacingMode_ | spacing mode/algorithm for the lines |
| _verticalOrientation | vertical orientation of the block of all lines, see JKQTMathTextVerticalListNode::verticalOrientation and JKQTMathTextVerticalOrientation |
|
protected |
parses a string, i.e. a sequence of text and whitespaces. returns after any other token was found
|
protected |
parses a list of string-arguments, i.e. {p1}{p2}{...}
| get | call getToken() at the start, otherwise it is expected that currentToken==MTTopenbrace | |
| Nparams | the number of parameters to expect | |
| [out] | foundError | will be set to true if an error occured (unexpected token) or false otherwise |
|
protected |
read all text without tokenizing, until the sequence endsequence is found.
| get | if true the functions begins by reading a new character, otherwise the current character is used as first character |
| endsequence | the sequence, ending the read |
| removeFirstlineWhitespace | if true the returned string does not contain the first whitespace-line and a possible trailing whitespace line |
|
staticprotected |
convert a tokenType into a string, e.g. for debugging output
|
staticprotected |
maps instructions for accents in text-mode (e.g. \'a or \ae ) to the corresponding unicode character
|
staticprotected |
lists all lengths of keys in accentLetters that start with a backslash
|
staticprotected |
lists all lengths of keys in accentLetters that start with a curly brace
|
staticprotected |
maps instructions for braces with fixed size, e.g \bigl to the magnification factor of the brace versus the base font
|
protected |
used by the tokenizer. type of the current token
|
protected |
used by the tokenizer. Points to the currently read character in parseString
|
protected |
used by the tokenizer. Name of the current token, id applicable
|
protected |
returns the number of \hline , \hdashline , ... commands in the last parseLatexString() call
|
protected |
the JKQTMathTextBraceType associated with the last \right command the parser encountered
|
staticprotected |
characters that require special treatment in math mode
|
staticprotected |
characters that require special treatment in math mode
|
staticprotected |
characters that have to be replaced by the correspcoting JKQTMathTextSymbolNode in math mode
|
protected |
used by the tokenizer. The string to be parsed
|
protected |
used by the parser. indicates whether to use textstyle or displaystyle in math-mode
|
protected |
used by the parser. indicates whether we are in a math environment
|
staticprotected |
single character instructions
|
staticprotected |
characters that initiate a new token