[apps/reader] Support de \pi & \theta (compile mais n'affiche pas dans reader)

This commit is contained in:
Mino1289
2021-10-23 23:28:02 +02:00
parent 710930d8e1
commit 57078755a3
2 changed files with 26 additions and 2 deletions

View File

@@ -113,8 +113,21 @@ Layout TexParser::popCommand() {
return popSqrtCommand();
}
}
else if (strncmp(k_thetaCommand, m_text, strlen(k_thetaCommand)) == 0) {
m_text += strlen(k_thetaCommand);
if (*m_text == ' ') {
return popThetaCommand();
}
}
else if (strncmp(k_piCommand, m_text, strlen(k_piCommand)) == 0) {
m_text += strlen(k_piCommand);
if (*m_text == ' ') {
return popPiCommand();
}
}
m_hasError = true;
return popFracCommand();
return LayoutHelper::String(m_text, strlen(m_text));
}
Layout TexParser::popFracCommand() {
@@ -127,12 +140,19 @@ Layout TexParser::popSqrtCommand() {
}
m_text++;
if (*m_text == '[') {
return NthRootLayout::Builder(popText(']'),popBlock());
return NthRootLayout::Builder(popText(']'), popBlock());
}
else {
return NthRootLayout::Builder(popBlock());
}
}
Layout TexParser::popThetaCommand() {
return CodePointLayout::Builder(UCodePointGreekSmallLetterTheta);
}
Layout TexParser::popPiCommand() {
return CodePointLayout::Builder(UCodePointGreekSmallLetterPi);
}
}

View File

@@ -20,12 +20,16 @@ private:
Layout popCommand();
Layout popFracCommand();
Layout popSqrtCommand();
Layout popPiCommand();
Layout popThetaCommand();
const char * m_text;
const char * m_endOfText;
bool m_hasError;
static constexpr char const * k_fracCommand = "frac";
static constexpr char const * k_sqrtCommand = "sqrt";
static constexpr char const * k_thetaCommand = "theta";
static constexpr char const * k_piCommand = "pi";
};
}