Minsky: 3.17.0
anonymous_namespace{latexMarkup.cc}::Result Struct Reference
Inheritance diagram for anonymous_namespace{latexMarkup.cc}::Result:
Inheritance graph
Collaboration diagram for anonymous_namespace{latexMarkup.cc}::Result:
Collaboration graph

Public Member Functions

 Result (const string &x="")
 
void push_back (const string &x, bool popAgain=false)
 
void push (const string &x, const char *&input)
 
void pop ()
 
void process1arg (const string &tag, const char *&input)
 
void processLaTeX (const char *&input)
 

Static Public Member Functions

static string parseOpt (const char *&input)
 

Public Attributes

vector< string > stack
 
vector< bool > popMore
 

Detailed Description

Definition at line 720 of file latexMarkup.cc.

Constructor & Destructor Documentation

◆ Result()

anonymous_namespace{latexMarkup.cc}::Result::Result ( const string &  x = "")
inline

Definition at line 725 of file latexMarkup.cc.

725 : string(x) {}

Member Function Documentation

◆ parseOpt()

static string anonymous_namespace{latexMarkup.cc}::Result::parseOpt ( const char *&  input)
inlinestatic

Definition at line 789 of file latexMarkup.cc.

790  {
791  string r;
792  if (*input=='[') ++input;
793  for (; *input!=']' && *input!='\0'; ++input)
794  r+=*input;
795  if (*input==']') ++input;
796  return r;
797  }
Definition: input.py:1

◆ pop()

void anonymous_namespace{latexMarkup.cc}::Result::pop ( )
inline

Definition at line 768 of file latexMarkup.cc.

769  {
770  if (stack.empty()) return;
771  do
772  {
773  if (!stack.back().empty() && stack.back()!="{")
774  *this+="</"+stack.back()+">";
775  stack.pop_back();
776  popMore.pop_back();
777  } while (!stack.empty() && !popMore.empty() && popMore.back());
778  }

◆ process1arg()

void anonymous_namespace{latexMarkup.cc}::Result::process1arg ( const string &  tag,
const char *&  input 
)
inline

Definition at line 780 of file latexMarkup.cc.

781  {
782  if (*input=='{' || !tag.empty())
783  push(tag, input);
784  else
785  *this+=*input++;
786  }
Definition: input.py:1
void push(const string &x, const char *&input)
Definition: latexMarkup.cc:735

◆ processLaTeX()

void anonymous_namespace{latexMarkup.cc}::Result::processLaTeX ( const char *&  input)
inline

Definition at line 799 of file latexMarkup.cc.

References minsky::defang(), anonymous_namespace{latexMarkup.cc}::latexSymbols, and anonymous_namespace{latexMarkup.cc}::parseLaTeXSym().

800  {
801  const string token=parseLaTeXSym(++input);
802  const map<string,string>::const_iterator repl=latexSymbols.find(token);
803  if (repl!=latexSymbols.end())
804  *this+=repl->second;
805  else if (token=="mathit" || token=="mathcal")
806  process1arg("i", input);
807  else if (token=="mathrm" || token=="mathsf")
808  process1arg("rm", input);
809  else if (token=="mathbf")
810  process1arg("b", input);
811  else if (token=="mathtt")
812  process1arg("tt", input);
813  else if (token=="sqrt")
814  {
815  if (*input=='[')
816  {
817  const string index=parseOpt(input);
818  *this+="<small><sup>"+index+"</sup></small>";
819  }
820  *this+=latexSymbols["surd"];
821  process1arg("", input);
822  }
823  else if (token=="verb")
824  {
825  // next character is the delimiter
826  *this+="<tt>";
827  const char delim=*input++;
828  for (; *input!='\0' && *input!=delim; ++input)
829  *this+=minsky::defang(*input);
830  *this+="</tt>";
831  ++input;
832  }
833  else
834  *this+="\\"+token; //unknown token, leave it as is
835  }
string defang(char c)
Definition: latexMarkup.cc:842
Definition: input.py:1
string parseLaTeXSym(const char *&input)
Definition: latexMarkup.cc:668
static string parseOpt(const char *&input)
Definition: latexMarkup.cc:789
map< string, string > latexSymbols
Definition: latexMarkup.cc:662
void process1arg(const string &tag, const char *&input)
Definition: latexMarkup.cc:780
Here is the call graph for this function:

◆ push()

void anonymous_namespace{latexMarkup.cc}::Result::push ( const string &  x,
const char *&  input 
)
inline

Definition at line 735 of file latexMarkup.cc.

References anonymous_namespace{latexMarkup.cc}::utf8char().

736  {
737  if (x=="{")
738  {
739  push_back(x); // preserve bare braced pairs
740  return;
741  }
742  if (*input=='{')
743  if (x=="rm") // fake an rm tag by deitalicising
744  {
745  input++;
746  }
747  else
748  {
749  if (!x.empty())
750  *this+="<"+x+">";
751  push_back(x);
752  input++;
753  }
754  else if (*input=='\\')
755  {
756  push_back(x,x!="{");
757  if (!x.empty())
758  *this+="<"+x+">";
760  return;
761  }
762  else if (x=="rm")
763  *this+=utf8char(input);
764  else if (!x.empty())
765  *this+=string("<")+x+">"+utf8char(input)+"</"+x+">";
766  }
void push_back(const string &x, bool popAgain=false)
Definition: latexMarkup.cc:727
Definition: input.py:1
string utf8char(const char *&input)
Definition: latexMarkup.cc:705
Here is the call graph for this function:

◆ push_back()

void anonymous_namespace{latexMarkup.cc}::Result::push_back ( const string &  x,
bool  popAgain = false 
)
inline

Definition at line 727 of file latexMarkup.cc.

728  {
729  stack.push_back(x);
730  popMore.push_back(popAgain);
731  }

Member Data Documentation

◆ popMore

vector<bool> anonymous_namespace{latexMarkup.cc}::Result::popMore

Definition at line 723 of file latexMarkup.cc.

◆ stack

vector<string> anonymous_namespace{latexMarkup.cc}::Result::stack

Definition at line 722 of file latexMarkup.cc.


The documentation for this struct was generated from the following file: