mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/reader] Add mathematical symbols to TexParser
This commit is contained in:
@@ -125,11 +125,42 @@ Layout TexParser::popCommand() {
|
||||
return poppiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_timesCommand, m_text, strlen(k_timesCommand)) == 0) {
|
||||
m_text += strlen(k_timesCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poptimesCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_divCommand, m_text, strlen(k_divCommand)) == 0) {
|
||||
m_text += strlen(k_divCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popdivCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_forallCommand, m_text, strlen(k_forallCommand)) == 0) {
|
||||
m_text += strlen(k_forallCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popforallCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_partialCommand, m_text, strlen(k_partialCommand)) == 0) {
|
||||
m_text += strlen(k_partialCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poppartialCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_existsCommand, m_text, strlen(k_existsCommand)) == 0) {
|
||||
m_text += strlen(k_existsCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popexistsCommand();
|
||||
}
|
||||
}
|
||||
|
||||
m_hasError = true;
|
||||
return LayoutHelper::String(m_text, strlen(m_text));
|
||||
}
|
||||
|
||||
// Expressions
|
||||
Layout TexParser::popFracCommand() {
|
||||
Layout numerator = popBlock();
|
||||
Layout denominator = popBlock();
|
||||
@@ -152,6 +183,28 @@ Layout TexParser::popSqrtCommand() {
|
||||
}
|
||||
}
|
||||
|
||||
// Symbols
|
||||
Layout TexParser::poptimesCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0xd7));
|
||||
}
|
||||
|
||||
Layout TexParser::popdivCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0xf7));
|
||||
}
|
||||
|
||||
Layout TexParser::popforallCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2200));
|
||||
}
|
||||
|
||||
Layout TexParser::poppartialCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2202));
|
||||
}
|
||||
|
||||
Layout TexParser::popexistsCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2203));
|
||||
}
|
||||
|
||||
// Greek letters
|
||||
Layout TexParser::popthetaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3b8));
|
||||
}
|
||||
|
||||
@@ -18,16 +18,37 @@ private:
|
||||
Layout popBlock();
|
||||
Layout popText(char stop);
|
||||
Layout popCommand();
|
||||
|
||||
// Expressions
|
||||
Layout popFracCommand();
|
||||
Layout popSqrtCommand();
|
||||
|
||||
// Symbols
|
||||
Layout poptimesCommand();
|
||||
Layout popdivCommand();
|
||||
Layout popforallCommand();
|
||||
Layout poppartialCommand();
|
||||
Layout popexistsCommand();
|
||||
|
||||
// Greek letters
|
||||
Layout poppiCommand();
|
||||
Layout popthetaCommand();
|
||||
|
||||
const char * m_text;
|
||||
const char * m_endOfText;
|
||||
bool m_hasError;
|
||||
|
||||
// Expressions
|
||||
static constexpr char const * k_fracCommand = "frac";
|
||||
static constexpr char const * k_sqrtCommand = "sqrt";
|
||||
|
||||
// Symbols
|
||||
static constexpr char const * k_timesCommand = "times";
|
||||
static constexpr char const * k_divCommand = "div";
|
||||
static constexpr char const * k_forallCommand = "forall";
|
||||
static constexpr char const * k_partialCommand = "partial";
|
||||
static constexpr char const * k_existsCommand = "exists";
|
||||
// Greek letters
|
||||
static constexpr char const * k_thetaCommand = "theta";
|
||||
static constexpr char const * k_piCommand = "pi";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user