PhoenixLecture  2.0.0
Set of tools to make lectures
platexobj_tex.h File Reference
+ Include dependency graph for platexobj_tex.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  POutputTex
 Output mode for tex backend. More...
 

Functions

POutputTex defaultPOutputTex ()
 Create a default POutputTex. More...
 
bool isPLatexObjInline (const PLatexObj &obj)
 Say if the given PLatexObj is inlined. More...
 
bool platexobj_tex (POutputTex &outputMode, const PLatexObj &obj)
 Save the main PLatexObj. More...
 
PString platexobj_texStr (POutputTex &outputMode, const PLatexObj &obj, const PString &indentation, bool allowText=true)
 Convert a PLatexObj into a string. More...
 
PString platexobj_texStr (POutputTex &outputMode, const PVecLatexObj &vecObj, const PString &indentation, bool allowText=true)
 Save a vector of PLatexObj in tex. More...
 

Function Documentation

◆ defaultPOutputTex()

POutputTex defaultPOutputTex ( )

Create a default POutputTex.

Returns
default POutputTex

Definition at line 18 of file platexobj_tex.cpp.

18  {
19  POutputTex out;
20  out.isLastObjInline = true;
21  out.splitPart = false;
22  out.splitChapter = false;
23  out.splitSection = false;
24  out.splitSubSection = false;
25  out.splitSubSubSection = false;
26  return out;
27 }
Output mode for tex backend.
Definition: platexobj_tex.h:13
bool isLastObjInline
True if the last used PLatexObj was inlined, false if it was a block.
Definition: platexobj_tex.h:15
bool splitPart
True to split parts in separates files.
Definition: platexobj_tex.h:17
bool splitSection
True to split sections in separates files.
Definition: platexobj_tex.h:21
bool splitChapter
True to split charpters in separates files.
Definition: platexobj_tex.h:19
bool splitSubSubSection
True to split subsubsections in separates files.
Definition: platexobj_tex.h:25
bool splitSubSection
True to split subsections in separates files.
Definition: platexobj_tex.h:23

References POutputTex::isLastObjInline, POutputTex::splitChapter, POutputTex::splitPart, POutputTex::splitSection, POutputTex::splitSubSection, and POutputTex::splitSubSubSection.

Referenced by processAllFile().

+ Here is the caller graph for this function:

◆ isPLatexObjInline()

bool isPLatexObjInline ( const PLatexObj obj)

Say if the given PLatexObj is inlined.

Parameters
obj: PLatexObj to be checked
Returns
true if the given PLatexObj is inlined, false otherwise

Definition at line 33 of file platexobj_tex.cpp.

33  {
34  PLatexType::PLatexType type(obj.getType());
35  return type == PLatexType::CITATION || type == PLatexType::FOOTNOTE || type == PLatexType::HREF ||
36  type == PLatexType::INLINEMATH || type == PLatexType::REF ||
37  type == PLatexType::TEXT || type == PLatexType::TEXTBF || type == PLatexType::TEXTIT || type == PLatexType::URL ||
38  type == PLatexType::VARCALL;
39 }
const PLatexType::PLatexType & getType() const
Gets the type of the PLatexObj.
Definition: PLatexObj.cpp:298
PLatexType
Type of the PLatexObj.
Definition: PLatexType.h:12

References PLatexType::CITATION, PLatexType::FOOTNOTE, PLatexObj::getType(), PLatexType::HREF, PLatexType::INLINEMATH, PLatexType::REF, PLatexType::TEXT, PLatexType::TEXTBF, PLatexType::TEXTIT, PLatexType::URL, and PLatexType::VARCALL.

Referenced by platexobj_texStr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ platexobj_tex()

bool platexobj_tex ( POutputTex outputMode,
const PLatexObj obj 
)

Save the main PLatexObj.

Parameters
[out]outputMode: output mode of the tex backend
obj: main PLatexObj to be saved
Returns
true on success, false otherwise

Definition at line 566 of file platexobj_tex.cpp.

566  {
567  PString fileContent(platexobj_texStr(outputMode, obj, ""));
568  PPath indexTex(obj.getLink());
569  if(!indexTex.saveFileContent(fileContent)){
570  std::cerr << "platexobj_tex : can't save file '"<<indexTex<<"'" << std::endl;
571  return false;
572  }else{
573  std::cerr << "platexobj_tex : save file '"<<indexTex<<"'" << std::endl;
574  }
575  return true;
576 }
const PString & getLink() const
Gets the link of the PLatexObj.
Definition: PLatexObj.cpp:368
Path of a directory or a file.
Definition: PPath.h:17
Extends the std::string.
Definition: PString.h:16
PString platexobj_texStr(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation, bool allowText)
Convert a PLatexObj into a string.

References PLatexObj::getLink(), platexobj_texStr(), and PPath::saveFileContent().

Referenced by processAllFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ platexobj_texStr() [1/2]

PString platexobj_texStr ( POutputTex outputMode,
const PLatexObj obj,
const PString indentation,
bool  allowText 
)

Convert a PLatexObj into a string.

Parameters
[out]outputMode: output mode of the tex backend
obj: PLatexObj to be converted into a string
allowText: true if the TEXT PLatexObj are allowed, false if not
indentation: indentation of the text
Returns
output string which contains the PLatexObj

Definition at line 472 of file platexobj_tex.cpp.

472  {
473  PString body("");
474  bool isCurrentObjInlined(isPLatexObjInline(obj));
475 // if(isCurrentObjInlined != outputMode.isLastObjInline){
476 // body += "\n";
477 // }
478  outputMode.isLastObjInline = isCurrentObjInlined;
479 
480  PLatexType::PLatexType type(obj.getType());
481  if(type == PLatexType::TEXT && allowText){body += platexobj_texStrText(obj);}
482  else if(type == PLatexType::COMMENT){body += platexobj_texStrComment(obj);}
483  else if(type == PLatexType::PERCENT){body += "\\%";}
484  else if(type == PLatexType::URL){body += platexobj_texStrUrl(obj);}
485  else if(type == PLatexType::GETENV){body += platexobj_texStrGetenv(obj);}
486  else if(type == PLatexType::REF){body += platexobj_texStrRef(obj);}
487  else if(type == PLatexType::SPACEPARAGRAPH){body += platexobj_texStrSpaceParagraph(obj);}
488  else if(type == PLatexType::AUTOSPACEPARAGRAPH){body += "\n\n";}
489  else if(type == PLatexType::CITATION){body += platexobj_texStrCitation(obj);}
490 
491  else if(type == PLatexType::HREF){body += platexobj_texStrHref(obj);}
492  else if(type == PLatexType::TEXTBF){body += platexobj_texStrTextBf(obj);}
493  else if(type == PLatexType::TEXTIT){body += platexobj_texStrTextIt(obj);}
494  else if(type == PLatexType::DEBUG){body += platexobj_texStrTextDebug(obj);}
495  else if(type == PLatexType::FOOTNOTE){body += platexobj_texStrTextFootnote(outputMode, obj);}
496  else if(type == PLatexType::CAPTION){body += platexobj_texStrCaption(outputMode, obj);}
497  else if(type == PLatexType::WORK_IN_PROGRESS){body += platexobj_texStrWip(outputMode, obj);}
498 
499  else if(type == PLatexType::IMAGE){body += platexobj_texStrImage(obj);}
500 
501  else if(type == PLatexType::PARTSTAR){body += platexobj_texStrAllPart(outputMode, obj, "part*", "");}
502  else if(type == PLatexType::CHAPTERSTAR){body += platexobj_texStrAllPart(outputMode, obj, "chapter*", "\t");}
503  else if(type == PLatexType::SECTIONSTAR){body += platexobj_texStrAllPart(outputMode, obj, "section*", "\t\t");}
504  else if(type == PLatexType::SUBSECTIONSTAR){body += platexobj_texStrAllPart(outputMode, obj, "subsection*", "\t\t\t");}
505  else if(type == PLatexType::SUBSUBSECTIONSTAR){body += platexobj_texStrAllPart(outputMode, obj, "subsubsection*", "\t\t\t\t");}
506 
507  else if(type == PLatexType::PART){body += platexobj_texStrSection(outputMode, obj, "part");}
508  else if(type == PLatexType::CHAPTER){body += platexobj_texStrSection(outputMode, obj, "chapter");}
509  else if(type == PLatexType::SECTION){body += platexobj_texStrSection(outputMode, obj, "section");}
510  else if(type == PLatexType::SUBSECTION){body += platexobj_texStrSection(outputMode, obj, "subsection");}
511  else if(type == PLatexType::SUBSUBSECTION){body += platexobj_texStrSection(outputMode, obj, "subsubsection");}
512 
513 
514  else if(type == PLatexType::PARAGRAPHE){body += platexobj_texStrBasicEnv(outputMode, obj, "paragraph", indentation);}
515  else if(type == PLatexType::CENTER){body += platexobj_texStrBasicEnv(outputMode, obj, "center", indentation);}
516  else if(type == PLatexType::COLUMN){body += platexobj_texStrBasicEnv(outputMode, obj, "column", indentation);}
517 
518  else if(type == PLatexType::COLUMNS){body += platexobj_texStrColumns(outputMode, obj, indentation);}
519 
520  else if(type == PLatexType::TABLE){body += platexobj_texStrBasicEnv(outputMode, obj, "table", indentation);}
521  else if(type == PLatexType::TABULAR){body += platexobj_texStrTabular(outputMode, obj, indentation);}
522  else if(type == PLatexType::TABROW){body += platexobj_texStrTabRow(outputMode, obj, indentation);}
523  else if(type == PLatexType::TABCELL){body += platexobj_texStrTabCell(outputMode, obj, indentation);}
524  else if(type == PLatexType::FIGURE){body += platexobj_texStrBasicEnv(outputMode, obj, "figure", indentation);}
525 
526  else if(type == PLatexType::DISPLAYMATH){body += platexobj_texStrMathEnv(outputMode, obj, "displaymath");}
527  else if(type == PLatexType::EQNARRAY){body += platexobj_texStrMathEnv(outputMode, obj, "eqnarray*");}
528  else if(type == PLatexType::INLINEMATH){body += platexobj_texStrInlineMath(outputMode, obj);}
529 
530  else if(type == PLatexType::ITEMIZE){body += platexobj_texStrItemize(outputMode, obj, indentation);}
531  else if(type == PLatexType::ENUMERATE){body += platexobj_texStrEnumerate(outputMode, obj, indentation);}
532  else if(type == PLatexType::ITEM){body += platexobj_texStrItem(outputMode, obj, indentation);}
533  else if(type == PLatexType::VIDEO){body += platexobj_texStrVideo(obj);}
534 
535  else if(type == PLatexType::ENVIRONEMENT){body += platexobj_texStrExtraEnvironement(outputMode, obj, indentation);}
536  else if(type == PLatexType::FUNCTION){body += platexobj_texStrExtraFunction(outputMode, obj, indentation);}
537  else if(type == PLatexType::PARSER){body += platexobj_texStrExtraParser(obj);}
538 
539  else if(type == PLatexType::FILE){body += platexobj_indexTex(outputMode, obj);}
540  else{
541  body += platexobj_texStr(outputMode, obj.getVecContent(), indentation, allowText);
542  }
543  return body;
544 }
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
@ SUBSUBSECTION
Definition: PLatexType.h:54
@ SUBSECTIONSTAR
Definition: PLatexType.h:60
@ AUTOSPACEPARAGRAPH
Definition: PLatexType.h:28
@ SPACEPARAGRAPH
Definition: PLatexType.h:27
@ ENVIRONEMENT
Definition: PLatexType.h:85
@ SUBSUBSECTIONSTAR
Definition: PLatexType.h:61
@ WORK_IN_PROGRESS
Definition: PLatexType.h:32
PString platexobj_texStrColumns(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation)
Convert a PLatexObj into a string.
PString platexobj_texStrExtraParser(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrMathEnv(POutputTex &outputMode, const PLatexObj &obj, const PString &latexEnvName)
convert fomulae env into latex
PString platexobj_texStrEnumerate(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation)
Convert an itemize environement in tex.
PString platexobj_texStrVideo(const PLatexObj &obj)
Convert a video call in tex.
PString platexobj_texStrItemize(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation)
Convert an itemize environement in tex.
PString platexobj_texStrTextDebug(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrText(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrTextIt(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrTabCell(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation)
Convert a cell into a tex string.
PString platexobj_texStrUrl(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrComment(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrAllPart(POutputTex &outputMode, const PLatexObj &obj, const PString &latexFunction, const PString &indentation)
Convert a PLatexObj into a string.
PString platexobj_texStrTextFootnote(POutputTex &outputMode, const PLatexObj &obj)
Convert a PLatexObj into a string.
bool isPLatexObjInline(const PLatexObj &obj)
Say if the given PLatexObj is inlined.
PString platexobj_texStrImage(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrItem(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation)
Convert an itemize environement in tex.
PString platexobj_texStrCitation(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_indexTex(POutputTex &outputMode, const PLatexObj &obj)
Save the index.tex file.
PString platexobj_texStrRef(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrTextBf(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrTabRow(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation)
Convert a row into a tex string.
PString platexobj_texStrSpaceParagraph(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrGetenv(const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrInlineMath(POutputTex &outputMode, const PLatexObj &obj)
convert inline fomulae into latex
PString platexobj_texStrExtraEnvironement(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation)
Convert a PLatexObj into a string.
PString platexobj_texStrWip(POutputTex &outputMode, const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrExtraFunction(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation)
Convert a PLatexObj into a string.
PString platexobj_texStrBasicEnv(POutputTex &outputMode, const PLatexObj &obj, const PString &baliseName, const PString &indentation, bool allowText)
Convert a basic environement into a string.
PString platexobj_texStrSection(POutputTex &outputMode, const PLatexObj &obj, const PString &latexFunction)
Save a section in tex.
PString platexobj_texStrCaption(POutputTex &outputMode, const PLatexObj &obj)
Convert a PLatexObj into a string.
PString platexobj_texStrTabular(POutputTex &outputMode, const PLatexObj &obj, const PString &indentation)
Convert a tabular into a tex string.
PString platexobj_texStrHref(const PLatexObj &obj)
Convert a PLatexObj into a string.

References PLatexType::AUTOSPACEPARAGRAPH, PLatexType::CAPTION, PLatexType::CENTER, PLatexType::CHAPTER, PLatexType::CHAPTERSTAR, PLatexType::CITATION, PLatexType::COLUMN, PLatexType::COLUMNS, PLatexType::COMMENT, PLatexType::DEBUG, PLatexType::DISPLAYMATH, PLatexType::ENUMERATE, PLatexType::ENVIRONEMENT, PLatexType::EQNARRAY, PLatexType::FIGURE, PLatexType::FILE, PLatexType::FOOTNOTE, PLatexType::FUNCTION, PLatexType::GETENV, PLatexObj::getType(), PLatexObj::getVecContent(), PLatexType::HREF, PLatexType::IMAGE, PLatexType::INLINEMATH, POutputTex::isLastObjInline, isPLatexObjInline(), PLatexType::ITEM, PLatexType::ITEMIZE, PLatexType::PARAGRAPHE, PLatexType::PARSER, PLatexType::PART, PLatexType::PARTSTAR, PLatexType::PERCENT, platexobj_indexTex(), platexobj_texStrAllPart(), platexobj_texStrBasicEnv(), platexobj_texStrCaption(), platexobj_texStrCitation(), platexobj_texStrColumns(), platexobj_texStrComment(), platexobj_texStrEnumerate(), platexobj_texStrExtraEnvironement(), platexobj_texStrExtraFunction(), platexobj_texStrExtraParser(), platexobj_texStrGetenv(), platexobj_texStrHref(), platexobj_texStrImage(), platexobj_texStrInlineMath(), platexobj_texStrItem(), platexobj_texStrItemize(), platexobj_texStrMathEnv(), platexobj_texStrRef(), platexobj_texStrSection(), platexobj_texStrSpaceParagraph(), platexobj_texStrTabCell(), platexobj_texStrTabRow(), platexobj_texStrTabular(), platexobj_texStrText(), platexobj_texStrTextBf(), platexobj_texStrTextDebug(), platexobj_texStrTextFootnote(), platexobj_texStrTextIt(), platexobj_texStrUrl(), platexobj_texStrVideo(), platexobj_texStrWip(), PLatexType::REF, PLatexType::SECTION, PLatexType::SECTIONSTAR, PLatexType::SPACEPARAGRAPH, PLatexType::SUBSECTION, PLatexType::SUBSECTIONSTAR, PLatexType::SUBSUBSECTION, PLatexType::SUBSUBSECTIONSTAR, PLatexType::TABCELL, PLatexType::TABLE, PLatexType::TABROW, PLatexType::TABULAR, PLatexType::TEXT, PLatexType::TEXTBF, PLatexType::TEXTIT, PLatexType::URL, PLatexType::VIDEO, and PLatexType::WORK_IN_PROGRESS.

Referenced by platexobj_indexTex(), platexobj_tex(), platexobj_texStr(), platexobj_texStrAllPart(), platexobj_texStrBasicEnv(), platexobj_texStrCaption(), platexobj_texStrColumns(), platexobj_texStrEnumerate(), platexobj_texStrExtraEnvironement(), platexobj_texStrExtraFunction(), platexobj_texStrItem(), platexobj_texStrItemize(), platexobj_texStrSection(), platexobj_texStrTabCell(), platexobj_texStrTabRow(), platexobj_texStrTabular(), platexobj_texStrTextFootnote(), and platexobj_texStrWip().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ platexobj_texStr() [2/2]

PString platexobj_texStr ( POutputTex outputMode,
const PVecLatexObj vecObj,
const PString indentation,
bool  allowText 
)

Save a vector of PLatexObj in tex.

Parameters
[out]outputMode: output mode of the tex backend
vecObj: vector of PLatexObj to be saved in tex
allowText: true if the TEXT PLatexObj are allowed, false if not
indentation: indentation of the text
Returns
tex string

Definition at line 553 of file platexobj_tex.cpp.

553  {
554  PString body("");
555  for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
556  body += platexobj_texStr(outputMode, *it, indentation, allowText);
557  }
558  return body;
559 }

References platexobj_texStr().

+ Here is the call graph for this function: