From 4578b66de8154e0242b56ae6ae32dc31138b26a2 Mon Sep 17 00:00:00 2001 From: Razi Alavizadeh Date: Wed, 12 Dec 2018 22:53:06 +0330 Subject: [PATCH] Add unknown symbols and instructions to error_list --- lib/jkqtmathtext/jkqtmathtext.cpp | 27 +++++++++++++++++++++++---- lib/jkqtmathtext/jkqtmathtext.h | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index dfea086c48..e74df6871b 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -445,6 +445,10 @@ JKQTmathText::MTinstruction1Node::MTinstruction1Node(JKQTmathText* parent, QStri this->name=name; this->child=child; this->parameters=parameters; + + if (!setupMTenvironment()) { + parent->error_list.append(tr("unknown instruction '%1' found!").arg(name)); + } } JKQTmathText::MTinstruction1Node::~MTinstruction1Node() { @@ -513,7 +517,7 @@ void JKQTmathText::MTinstruction1Node::set_drawBoxes(bool draw) child->set_drawBoxes(draw); } -void JKQTmathText::MTinstruction1Node::setupMTenvironment(JKQTmathText::MTenvironment &ev) +bool JKQTmathText::MTinstruction1Node::setupMTenvironment(JKQTmathText::MTenvironment &ev) { if (name=="bf" || name=="textbf" || name=="mathbf") ev.bold=true; else if (name=="em") ev.italic=!ev.italic; @@ -535,13 +539,16 @@ void JKQTmathText::MTinstruction1Node::setupMTenvironment(JKQTmathText::MTenviro else if (name=="displaystyle") { ev.fontSize=ev.fontSize/0.8; } else if (name=="scriptstyle") { ev.fontSize=ev.fontSize*0.8; } else if (name=="scriptscriptstyle") { ev.fontSize=ev.fontSize*0.8*0.8; } + else { + return false; + } + + return true; } - - JKQTmathText::MTsubscriptNode::MTsubscriptNode(JKQTmathText* parent, MTnode* child): JKQTmathText::MTnode(parent) { @@ -2683,6 +2690,19 @@ JKQTmathText::MTsymbolNode::MTsymbolNode(JKQTmathText* parent, QString name, boo } } if (addWhitespace) symbol=symbol+" "; + + static QSet extraSymbolName = { + "infty", + "|", " ", "quad", ";", ":", ",", "!", + "longleftarrow", "longrightarrow", + "Longleftarrow", "Longrightarrow", + "longleftrightarrow", "Longleftrightarrow" + }; + + if (symbol.simplified().isEmpty() && !extraSymbolName.contains(n)) { + parent->error_list.append(tr("unknown symbol '%1' found!").arg(n)); + } + //std::cout<<"symbol node '"<getTBR(f, "M", painter.device()); painter.drawRect(QRectF(x+shift,y-tbr.height(), xwi, tbr.height()*0.8)); - parent->error_list<<"unknown symbol '"<