mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/reader] Ajout du support de \sqrt[n]{x} dans le parser LaTeX
This commit is contained in:
@@ -21,12 +21,12 @@ Layout TexParser::getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
Layout TexParser::popBlock(char block) {
|
||||
Layout TexParser::popBlock() {
|
||||
while (*m_text == ' ') {
|
||||
m_text ++;
|
||||
}
|
||||
|
||||
if (*m_text == block) {
|
||||
if (*m_text == '}') {
|
||||
m_text ++;
|
||||
return popText('}');
|
||||
}
|
||||
@@ -98,12 +98,32 @@ Layout TexParser::popCommand() {
|
||||
return popFracCommand();
|
||||
}
|
||||
}
|
||||
else if (strcmp(k_sqrtCommand, m_text, strlen(k_fracCommand)) == 0) {
|
||||
m_text += strlen(k_fracCommand);
|
||||
if (*m_text == ' ' || *m_text == '{' || *m_text == '[') {
|
||||
return popSqrtCommand();
|
||||
}
|
||||
}
|
||||
|
||||
return popFracCommand();
|
||||
}
|
||||
|
||||
Layout TexParser::popSqrtCommand() {
|
||||
while (*m_text == ' ') {
|
||||
m_text ++;
|
||||
}
|
||||
m_text++;
|
||||
if (*m_text == '[') {
|
||||
return NthRootLayout::Builder(popText(']'),popBlock());
|
||||
}
|
||||
else {
|
||||
return NthRootLayout::Builder(popBlock());
|
||||
}
|
||||
}
|
||||
|
||||
Layout TexParser::popFracCommand() {
|
||||
Layout firstBlock = popBlock('{');
|
||||
Layout secondBlock = popBlock('{');
|
||||
Layout firstBlock = popBlock();
|
||||
Layout secondBlock = popBlock();
|
||||
return FractionLayout::Builder(firstBlock, secondBlock);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@ private:
|
||||
Layout popText(char stop);
|
||||
Layout popCommand();
|
||||
Layout popFracCommand();
|
||||
Layout popSqrtCommand();
|
||||
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";
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user