PhoenixLecture  2.0.0
Set of tools to make lectures
PGenericParser.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #include "data_all.h"
8 #include "pxml_utils.h"
9 #include "PConfigParser.h"
11 
12 #include "PGenericParser.h"
13 
15 
18 bool wgetFile(const PString& url){
19  PString command("wget \""+url+"\"");
20  return system(command.c_str()) != 0;
21 }
22 
24 
28  PVecString vecEndPatern;
29  vecEndPatern.push_back("\\begin");
30  vecEndPatern.push_back("{");
31  vecEndPatern.push_back(envName);
32  vecEndPatern.push_back("}");
33  return vecEndPatern;
34 }
35 
37 
40 PVecString getEndSeqEnv(const PString & envName){
41  PVecString vecEndPatern;
42  vecEndPatern.push_back("\\end");
43  vecEndPatern.push_back("{");
44  vecEndPatern.push_back(envName);
45  vecEndPatern.push_back("}");
46  return vecEndPatern;
47 }
48 
50 
52 PGenericParser::PGenericParser(const PString & installPrefix){
53  initialisationPGenericParser(installPrefix);
54 }
55 
57 
60  copyPGenericParser(other);
61 }
62 
65 
66 }
67 
69 
73  copyPGenericParser(other);
74  return *this;
75 }
76 
78 
80 void PGenericParser::setDebugMode(bool isDebugMode){
81  p_isDebugMode = isDebugMode;
82 }
83 
85 
88  return p_currentSource;
89 }
90 
92 
95  return p_currentSource;
96 }
97 
99 
102  return p_vecIncludeDir;
103 }
104 
106 
109  return p_vecIncludeDir;
110 }
111 
113 
116 
118 
121 
123 
126  return p_bookSideBarWidth;
127 }
128 
130 
133  return p_bookGitlabUrl;
134 }
135 
137 
140  return p_isEnableBookFeedback;
141 }
142 
144 
147  return p_bookMail;
148 }
149 
151 
154  return p_bookMasterProjectUrl;
155 }
156 
158 
161  return p_bookMainPageLink;
162 }
163 
165 
168  PVecString vecTheme;
169  for(std::map<PString, PString>::iterator itStyle(p_cssContent.begin()); itStyle != p_cssContent.end(); ++itStyle){
170  vecTheme.push_back(itStyle->first);
171  }
172 
173  for(std::map<PString, PString>::iterator itStyle(p_cssContent.begin()); itStyle != p_cssContent.end(); ++itStyle){
174  PString cssStyle(itStyle->second), cssThemeName(itStyle->first);
175  if(p_vecExtraEnv.size() != 0lu){
176  for(PMapExtraEnv::iterator it(p_vecExtraEnv.begin()); it != p_vecExtraEnv.end(); ++it){
177  cssStyle += "." + it->second.getName() + "Style{\n";
178  cssStyle += select_css_theme(vecTheme, cssThemeName, it->second.getCss());
179  cssStyle += "}\n\n";
180  }
181  }
182  if(p_vecExtraFunction.size() != 0lu){
183  for(PMapExtraEnv::iterator it(p_vecExtraFunction.begin()); it != p_vecExtraFunction.end(); ++it){
184  cssStyle += "." + it->second.getName() + "Style{\n";
185  cssStyle += select_css_theme(vecTheme, cssThemeName, it->second.getCss());
186  cssStyle += "}\n\n";
187  }
188  }
189  PPath fileName(cssThemeName + "_style.css");
190  if(!fileName.saveFileContent(cssStyle)){
191  std::cerr << "PGenericParser::saveCss : can't save the file '"<<fileName<<"'" << std::endl;
192  return false;
193  }
194  }
195  return true;
196 }
197 
199 
203 
205  p_vecEnv = other.p_vecEnv;
207  p_vecFunc = other.p_vecFunc;
208 
211 
220 
225 
236 
238  p_cssContent = other.p_cssContent;
243 
247  p_bookMail = other.p_bookMail;
250 }
251 
253 
256  obj.getVecContent().clear();
257  obj.setLabelName("");
258  obj.setText("");
259  obj.setName("");
261 }
262 
264 
267  //If nothing is known I need to save the current char in the MACRO TEXT
268  char ch = p_parser->getCurrentCh();
269  textObj.getText() += ch;
271 }
272 
274 
279 bool PGenericParser::playTextLatexObj(PLatexObj & parent, PLatexObj & textObj, bool isRemoveFirstLastSpace){
280  if(isRemoveFirstLastSpace){
281  textObj.setText(textObj.getText().eraseFirstLastChar(" \t\n"));
282  }
283  if(textObj.getText() != ""){
284  parent.getVecContent().push_back(textObj);
285  clearLatexObj(textObj);
286  return true;
287  }
288  return false;
289 }
290 
291 
293 
296 void PGenericParser::addLatexObj(PLatexObj & parent, const PLatexObj & obj){
297  parent.getVecContent().push_back(obj);
298 }
299 
301 
305  PConfigParser parser;
306  parser.setFileContent(inputStr + "\n");
307  PString out("");
308  if(parser.fullParsing()){
309  out = platexobj_text(parser.getSource());
310  }else{
311  out = inputStr;
312  }
313  return out;
314 }
315 
317 
321  if(!isMatch("{")){
322  errorAt();
323  std::cerr << "PGenericParser::getStringBetweenBraces : expect '{' after '"<<previousToken<<"' instead of '"<<p_parser->getNextChar()<<"'" << std::endl;
324  stopParsing();
325  return "";
326  }
327 // PString link(p_parser->getUntilKeyWithoutPatern("}"));
329  return link;
330 }
331 
333 
336  if(!isMatch("{")){ //No hook => empty string
337  return "";
338  }
340  return link;
341 }
342 
344 
348  char ch = p_parser->getCurrentCh();
349  if(ch != '['){ //No hook => empty string
350  return "";
351  }
354  return link;
355 }
356 
358 
364 bool PGenericParser::parseMonoParam(PLatexObj & parent, PLatexObj & textObj, const PString & functionName, PLatexType::PLatexType type){
365  if(!p_parser->isMatch(functionName)){return false;}
366  playTextLatexObj(parent, textObj);
367  PLatexObj tmp;
368  tmp.setType(type);
369 
370  PString textOption(getOptionStringBetweenHook());
371  tmp.setText(textOption);
372 
373  PString title(getStringBetweenBraces(functionName));
374  tmp.setName(title);
375 
376  addLatexObj(parent, tmp);
377  return true;
378 }
379 
381 
386  if(parseMonoParam(parent, textObj, "\\updateStyle", PLatexType::UPDATESTYLE)){}
387  else if(parseMonoParam(parent, textObj, "\\ref", PLatexType::REF)){}
388  else if(parseMonoParam(parent, textObj, "\\cite", PLatexType::CITATION)){}
389  else if(parseLabel(parent, textObj)){}
390  else if(parserGetEnv(parent, textObj)){}
391  else if(parseMainTitle(parent, textObj)){}
392  else if(parseMainSubTitle(parent, textObj)){}
393  else if(parseMainAuthor(parent, textObj)){}
394  else if(parseMainDate(parent, textObj)){}
395  else if(parseBookSizeBarWidth(parent, textObj)){}
396  else if(parseBookGitlabUrl(parent, textObj)){}
397  else if(parseBookEnableFeedback(parent, textObj)){}
398  else if(parseBookMail(parent, textObj)){}
399  else if(parseBookMasterProject(parent, textObj)){}
400  else{return false;}
401  return true;
402 }
403 
405 
410  if(!p_parser->isMatchToken("\\label")){return false;}
411  playTextLatexObj(parent, textObj);
412  PString link(getStringBetweenBraces("\\label"));
413 
414  PLatexObj* ptrLatex = getLastPLatexObj(parent);
415  if(ptrLatex != NULL){
416  ptrLatex->setLabelName(link);
417  }
418  return true;
419 }
420 
422 
427  if(!p_parser->isMatchToken("\\getenv")){return false;}
428  playTextLatexObj(parent, textObj);
429  PString title(getStringBetweenBraces("\\getenv"));
430  PLatexObj tmp;
432  tmp.setName(title);
433  addLatexObj(parent, tmp);
434 
435  return true;
436 }
437 
439 
444  if(!p_parser->isMatchToken("\\title")){return false;}
445  playTextLatexObj(parent, textObj);
446  PString title(getStringBetweenBraces("\\title"));
447  parent.setName(executeLatexCommand(title));
448  return true;
449 }
450 
452 
457  if(!p_parser->isMatchToken("\\subtitle")){return false;}
458  playTextLatexObj(parent, textObj);
459  PString title(getStringBetweenBraces("\\subtitle"));
460  parent.setSubTitle(executeLatexCommand(title));
461  return true;
462 }
463 
465 
470  if(!p_parser->isMatchToken("\\author")){return false;}
471  playTextLatexObj(parent, textObj);
472  PString title(getStringBetweenBraces("\\author"));
473  parent.setAuthor(executeLatexCommand(title));
474  return true;
475 }
476 
478 
483  if(!p_parser->isMatchToken("\\date")){return false;}
484  playTextLatexObj(parent, textObj);
485  PString title(getStringBetweenBraces("\\date"));
486  parent.setDate(executeLatexCommand(title));
487  return true;
488 }
489 
491 
496  if(!p_parser->isMatchToken("\\bookSizebarWidth")){return false;}
497  playTextLatexObj(parent, textObj);
498  PString title(getStringBetweenBraces("\\bookSizebarWidth"));
500  return true;
501 }
502 
504 
509  if(!p_parser->isMatchToken("\\bookGitlabUrl")){return false;}
510  playTextLatexObj(parent, textObj);
511  PString title(getStringBetweenBraces("\\bookGitlabUrl"));
513  return true;
514 }
515 
517 
522  if(!p_parser->isMatchToken("\\bookEnableFeedback")){return false;}
523  playTextLatexObj(parent, textObj);
524  PString title(getStringBetweenBraces("\\bookEnableFeedback").toLower());
525  title = executeLatexCommand(title);
526  p_isEnableBookFeedback = (title == "true" || title == "yes" || title == "1");
527  return true;
528 }
529 
531 
536  if(!p_parser->isMatchToken("\\bookMail")){return false;}
537  playTextLatexObj(parent, textObj);
538  PString title(getStringBetweenBraces("\\bookMail"));
540  return true;
541 }
542 
544 
549  if(!p_parser->isMatchToken("\\bookMasterProject")){return false;}
550  playTextLatexObj(parent, textObj);
551  PString title(getStringBetweenBraces("\\bookMasterProject"));
553  return true;
554 }
555 
557 
561 void setBoolFromAttr(bool & isAllowComment, const PXml & xml, const PString & name){
562  PXmlAttr attr;
563  if(pxml_getAttrIfExist(attr, xml, name)){
564  PString value = attr.getValue().toLower();
565  isAllowComment = value == "yes" || value == "1" || value == "y";
566  }
567 }
568 
570 
573  PXml root;
574  if(!pxml_parserFile(root, inputFile)){
575  std::cerr << "PGenericParser::loadDirExtraEnvironementFile : can't read file '"<<inputFile<<"'" << std::endl;
576  return;
577  }
578  PXml & childXml = root.getVecChild().front();
579  if(!pxml_getChildIfExist(childXml, root, "environement")){
580  std::cerr << "PGenericParser::loadDirExtraEnvironementFile : can't find <environement> </environement> balise in file '"<<inputFile<<"'" << std::endl;
581  return;
582  }
583  PVecXml listEnv;
584  if(pxml_getVecChildIfExist(listEnv, childXml, "env")){
585  for(PVecXml::iterator it(listEnv.begin()); it != listEnv.end(); ++it){
586  PXmlAttr attrName;
587  if(!pxml_getAttrIfExist(attrName, *it, "name")){continue;}
588  PString name(attrName.getValue());
589  if(name == ""){
590  std::cerr << "PGenericParser::loadDirExtraEnvironementFile : expect name in balise" << std::endl;
591  continue;
592  }
593  PString balise("div");
594  PXmlAttr attr;
595  if(pxml_getAttrIfExist(attr, *it, "balise")){
596  balise = attr.getValue();
597  }
598  bool isAllowComment(true), isAllowMath(true);
599  setBoolFromAttr(isAllowComment, *it, "comment");
600  setBoolFromAttr(isAllowMath, *it, "math");
601 
602  PString contentStr(pxml_getFullContent(*it));
603 
604  PEnvironement tmp;
605  tmp.setName(name);
606  tmp.setBalise(balise);
607  tmp.setCss(contentStr);
608  tmp.setIsAllowComment(isAllowComment);
609  tmp.setIsAlloxMath(isAllowMath);
610 
611  p_vecExtraEnv[name] = tmp;
612  p_vecNameExtraEnv.push_back(name);
613  p_vecNameFunctionExtraEnv.push_back("\\" + name);
614  p_vecNameMarkdownExtraEnv.push_back("```" + name);
615  }
616  }
617 }
618 
620 
623  PListFile listInputFile = inputDir.getAllElementInDir();
624  if(listInputFile.size() == 0lu){
625  std::cerr << "PGenericParser::loadDirExtraEnvironement : can't read directory '"<<inputDir<<"'" << std::endl;
626  return;
627  }
628  for(PListFile::iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
629  loadDirExtraEnvironementFile(inputDir / (*it));
630  }
631 }
632 
634 
637  PXml root;
638  if(!pxml_parserFile(root, inputFile)){
639  std::cerr << "PGenericParser::loadDirExtraFunctionFile : can't read file '"<<inputFile<<"'" << std::endl;
640  return;
641  }
642  PXml & childXml = root.getVecChild().front();
643  if(!pxml_getChildIfExist(childXml, root, "function")){
644  std::cerr << "PGenericParser::loadDirExtraFunctionFile : can't find <function> </function> balise in file '"<<inputFile<<"'" << std::endl;
645  return;
646  }
647  PVecXml listEnv;
648  if(pxml_getVecChildIfExist(listEnv, childXml, "fct")){
649  for(PVecXml::iterator it(listEnv.begin()); it != listEnv.end(); ++it){
650  PXmlAttr attrName;
651  if(!pxml_getAttrIfExist(attrName, *it, "name")){continue;}
652  PString name(attrName.getValue());
653  if(name == ""){
654  std::cerr << "PGenericParser::loadDirExtraFunctionFile : expect name in balise" << std::endl;
655  continue;
656  }
657  PString balise("span");
658  PXmlAttr attr;
659  if(pxml_getAttrIfExist(attr, *it, "balise")){
660  balise = attr.getValue();
661  }
662  PString contentStr(pxml_getFullContent(*it));
663  PEnvironement tmp;
664  tmp.setName(name);
665  tmp.setBalise(balise);
666  tmp.setCss(contentStr);
667 
668  p_vecExtraFunction[name] = tmp;
669  p_vecNameExtraFunction.push_back("\\" + name);
670  }
671  }
672 }
673 
675 
678  PListFile listInputFile = inputDir.getAllElementInDir();
679  if(listInputFile.size() == 0lu){
680  std::cerr << "PGenericParser::loadDirExtraFunction : can't read directory '"<<inputDir<<"'" << std::endl;
681  return;
682  }
683  for(PListFile::iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
684  loadDirExtraFunctionFile(inputDir / (*it));
685  }
686 }
687 
689 
692  PXml root;
693  if(!pxml_parserFile(root, inputFile)){
694  std::cerr << "PGenericParser::loadDirExtraParserFile : can't read file '"<<inputFile<<"'" << std::endl;
695  return;
696  }
697  PXml & childXml = root.getVecChild().front();
698  if(!pxml_getChildIfExist(childXml, root, "highlighting")){
699  std::cerr << "PGenericParser::loadDirExtraParserFile : can't find <highlighting> </highlighting> balise in file '"<<inputFile<<"'" << std::endl;
700  return;
701  }
702  PString environementName(inputFile.getFileName().eraseExtension());
703  p_vecNameExtraParser.push_back(environementName);
704  p_vecNameFunctionExtraParser.push_back("\\" + environementName);
705  p_vecNameMarkdownExtraParser.push_back("```" + environementName);
706 
707  PParserEnv parserEnv;
708  parserEnv.setName(environementName);
709 
710  PXml matchPlainText;
711  if(pxml_getChildIfExist(matchPlainText, childXml, "plainText")){
712  parserEnv.setPlainText(convertBackSlahedStr(pxml_getFullContent(matchPlainText)));
713  }
714  PVecXml listEnv;
715  if(pxml_getVecChildIfExist(listEnv, childXml, "context")){
716  for(PVecXml::iterator itBalise(listEnv.begin()); itBalise != listEnv.end(); ++itBalise){
717  PXmlAttr attrClass;
718  if(!pxml_getAttrIfExist(attrClass, *itBalise, "class")){continue;}
719  PString nameClass(attrClass.getValue());
720  if(nameClass == ""){
721  std::cerr << "PGenericParser::loadDirExtraEnvironementFile : expect 'class' in balise" << std::endl;
722  continue;
723  }
724  PContext tmp;
725  tmp.setName(nameClass);
726 
727  PXml matchBegin;
728  if(pxml_getChildIfExist(matchBegin, *itBalise, "begin")){
730  }
731  PXml matchEnd;
732  if(pxml_getChildIfExist(matchEnd, *itBalise, "end")){
734  }
735  PXml matchNotBeforeBegin;
736  if(pxml_getChildIfExist(matchNotBeforeBegin, *itBalise, "notBeforeBegin")){
738  }
739  PXml matchNotAfterBegin;
740  if(pxml_getChildIfExist(matchNotAfterBegin, *itBalise, "notAfterBegin")){
742  }
743  PXml matchNotBeforEnd;
744  if(pxml_getChildIfExist(matchNotBeforEnd, *itBalise, "notBeforeEnd")){
746  }
747  PVecXml listKw;
748  if(pxml_getVecChildIfExist(listKw, *itBalise, "keyword")){
749  for(PVecXml::iterator it(listKw.begin()); it != listKw.end(); ++it){
751  }
752  }
753 
754  PXml matchSequence;
755  if(pxml_getChildIfExist(matchSequence, *itBalise, "sequence")){
756  PParseSeq seq;
757  if(loadParserSeq(seq, matchSequence)){
758  tmp.setSeq(seq);
759  }else{
760  std::cerr << "PGenericParser::loadDirExtraParserFile : can't initialise sequence with balise in file '"<<inputFile<<"'" << std::endl;
761  }
762  }
763  parserEnv.getVecContext().push_back(tmp);
764  }
765  p_vecExtraParser.getVecEnv().push_back(parserEnv);
766  }
767 }
768 
770 
773  PListFile listInputFile = inputDir.getAllElementInDir();
774  if(listInputFile.size() == 0lu){
775  std::cerr << "PGenericParser::loadDirExtraParser : can't read directory '"<<inputDir<<"'" << std::endl;
776  return;
777  }
778  for(PListFile::iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
779  loadDirExtraParserFile(inputDir / (*it));
780  }
781 }
782 
784 
786 void PGenericParser::loadCss(const PPath & inputDir){
787  PListFile listInputFile = inputDir.getAllElementInDir();
788  if(listInputFile.size() == 0lu){
789  std::cerr << "PGenericParser::loadCss : can't read directory '"<<inputDir<<"'" << std::endl;
790  return;
791  }
792  for(PListFile::iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
793  PString styleName(it->getFileName().eraseExtension());
794  PPath tmpFile(inputDir / (*it));
795  p_cssContent[styleName] = tmpFile.loadFileContent();
796  }
797 }
798 
801  PString fileName(COPIED_RECOVER_FILE);
802  if(!data_load(fileName, p_mapCopiedFile)){return;}
803 }
804 
807  PString fileName(COPIED_RECOVER_FILE);
808  if(!data_save(fileName, p_mapCopiedFile)){return;}
809 }
810 
812 
816  PPath fileToBeCopied(fileName);
817  if(!fileToBeCopied.isFileExist()){ //If the fileName does not exists, it is relative to the current parsed file
818  fileToBeCopied = p_parser->getFileName().getParentDirectory() / fileName;
819  if(!fileToBeCopied.isFileExist()){ //Il the fileName still does not exists, we have to complain
820  std::cerr << "PGenericParser::getAbsoluteFileName : file '"<<fileName<<"' does not exists, even relative to the current parsed file that gives '"<<fileToBeCopied<<"'" << std::endl;
821  return PPath("");
822  }
823  }
824  return fileToBeCopied;
825 }
826 
828 
832 PPath PGenericParser::copyFile(const PPath & outputDir, const PPath & fileName){
833  if(fileName == ""){
834  std::cerr << "PGenericParser::copyFile : fileName is empty" << std::endl;
835  return PPath("");
836  }
837  PPath fileToBeCopied(getAbsoluteFileName(fileName));
838  if(fileToBeCopied == ""){ //If the fileName does not exists, it is relative to the current parsed file
839  std::cerr << "PGenericParser::copyFile : file '"<<fileName<<"' does not exists, even relative to the current parsed file that gives '"<<fileToBeCopied<<"'" << std::endl;
840  return PPath("");
841  }
842 
843  PString baseFileName(fileToBeCopied.getFileName());
844  PString linkDir(fileName.getParentDirectory().replace("../", ""));
845  PPath buildFileName(outputDir + PPath("/") + linkDir + PPath("/") + baseFileName);
846 
847  //Do we know the input file (did we already copy it)
848  PMapFile::iterator it(p_mapCopiedFile.find(fileName));
849  if(it != p_mapCopiedFile.end()){
850  //Let's check if the copied file still exists
851  if(buildFileName.isFileExist()){
852  //Ok, now let's get it's last modification time to be sure
853  time_t currentModifTime = fileToBeCopied.getFileModificationTime();
854  //Now let's check if it is the same one
855  if(currentModifTime == it->second && currentModifTime > 0){ //negative value is an error
856  //Ok, no need to copy, we already did it and the file if up to date
857  std::cout << "PGenericParser::copyFile : no need to copy file '"<<fileName<<"' already updated at time " << currentModifTime << std::endl;
858  return buildFileName;
859  }
860  }
861  }
862 
863  if(linkDir != ""){ //If there is other directories
864  if(!PPath(outputDir + "/" + linkDir).createDirectory()){
865  std::cerr << "PGenericParser::copyFile : cannot create directory '"<<(outputDir + "/" + linkDir)<<"'" << std::endl;
866  return PPath("");
867  }
868  }else{
869  if(!outputDir.createDirectory()){
870  std::cerr << "PGenericParser::copyFile : cannot create directory '"<<outputDir<<"'" << std::endl;
871  return PPath("");
872  }
873  }
874 
875  //Set the modification time
876  time_t lastModifTime = fileToBeCopied.getFileModificationTime();
877 
878  PString command("cp "+fileToBeCopied+" " + buildFileName);
879  if(system(command.c_str()) != 0){
880  errorAt();
881  std::cerr << "PGenericParser::copyFile : can't copy file '"<<fileToBeCopied<<"' into '"<<buildFileName<<"' directory" << std::endl;
882  stopParsing();
883  return PPath("");
884  }
885 // std::cout << "PGenericParser::copyFile : copy file '"<<fileToBeCopied<<"' at time " << lastModifTime << std::endl;
886  p_mapCopiedFile[fileToBeCopied] = lastModifTime;
887  return buildFileName;
888 }
889 
891 
894  p_isDebugMode = false;
897 
898  PString installPrefix(CMAKE_INSTALL_PREFIX);
899  if(baseInstallPrefix != ""){
900  installPrefix = baseInstallPrefix;
901  }
902 
903  PPath dirExtraEnv(installPrefix+"/share/PhoenixTex2Html/ENVIRONEMENT");
904  loadDirExtraEnvironement(dirExtraEnv);
905 
906  PPath dirExtraFunction(installPrefix+"/share/PhoenixTex2Html/FUNCTION");
907  loadDirExtraFunction(dirExtraFunction);
908 
909  PPath dirExtraParser(installPrefix+"/share/PhoenixTex2Html/PARSER");
910  loadDirExtraParser(dirExtraParser);
911 
912  PPath dirCss(installPrefix+"/share/PhoenixTex2Html/STYLE");
913  loadCss(dirCss);
914 
915  p_vecRemoveLatexKeyword.push_back("\\toprule");
916  p_vecRemoveLatexKeyword.push_back("\\midrule");
917  p_vecRemoveLatexKeyword.push_back("\\bottomrule");
918  p_vecRemoveLatexKeyword.push_back("\\hline");
919  loadMapFile();
920 
921  p_bookSideBarWidth = "300px";
922  p_isEnableBookFeedback = false;
923 
924  p_bookMainPageLink.setType(PLatexType::NONE); //None by default, type will be updated on update
925 }
926 
927 
928 
929 
930 
PVecString getEndSeqEnv(const PString &envName)
Get the sequence of the ending of an environement.
bool wgetFile(const PString &url)
Do a wget of a file.
void setBoolFromAttr(bool &isAllowComment, const PXml &xml, const PString &name)
Get a boolean from xml attribute.
PVecString getBeginSeqEnv(const PString &envName)
Get the sequence of the begining of an environement.
#define COPIED_RECOVER_FILE
Define the name of the file which contains the formulae and the path to the created file.
#define PARSER_SKIP_SPACE
Macro to skip space.
bool loadParserSeq(PParseSeq &seq, const PXml &xmlSeq)
Load a ParseSeq with a XML balise.
std::vector< PString > PVecString
Definition: PString.h:96
Parse the pdata confguration file.
Definition: PConfigParser.h:13
Context for parser environement.
Definition: PLatexObj.h:310
void setBegin(const PString &begin)
Sets the begin of the PContext.
Definition: PLatexObj.cpp:1240
void setNotBeforeBegin(const PString &notBeforeBegin)
Sets the notBeforeBegin of the PContext.
Definition: PLatexObj.cpp:1254
void setSeq(const PParseSeq &seq)
Sets the seq of the PContext.
Definition: PLatexObj.cpp:1282
void setNotBeforeEnd(const PString &notBeforeEnd)
Sets the notBeforeEnd of the PContext.
Definition: PLatexObj.cpp:1268
const std::vector< PString > & getVecKeyword() const
Gets the vecKeyword of the PContext.
Definition: PLatexObj.cpp:1373
void setEnd(const PString &end)
Sets the end of the PContext.
Definition: PLatexObj.cpp:1247
void setNotAfterBegin(const PString &notAfterBegin)
Sets the notAfterBegin of the PContext.
Definition: PLatexObj.cpp:1261
void setName(const PString &name)
Sets the name of the PContext.
Definition: PLatexObj.cpp:1233
describe a CSS environement for latex
Definition: PLatexObj.h:272
void setName(const PString &name)
Sets the name of the PEnvironement.
Definition: PLatexObj.cpp:1082
void setCss(const PString &css)
Sets the css of the PEnvironement.
Definition: PLatexObj.cpp:1089
void setBalise(const PString &balise)
Sets the balise of the PEnvironement.
Definition: PLatexObj.cpp:1096
void setIsAllowComment(bool isAllowComment)
Sets the isAllowComment of the PEnvironement.
Definition: PLatexObj.cpp:1103
void setIsAlloxMath(bool isAlloxMath)
Sets the isAlloxMath of the PEnvironement.
Definition: PLatexObj.cpp:1110
PString getUntilKeyWithoutPatern(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern exclu.
PString getUntilKeyWithoutPaternRecurse(const PString &patern, const PString &beginPatern, const PString &allowedCharAfterBegin)
Get the string until end sequence and take account recursive patern (embeded strings)
bool isMatchToken(const PString &patern)
Says if the patern match with the current caracters of the PFileParser but treats the string as a tok...
bool isMatch(const PString &patern)
Says if the patern match with the current caracters of the PFileParser.
char getCurrentCh() const
Renvoie le caractère courant.
PPath getFileName() const
Fonction qui renvoie le nom du fichier que l'on a ouvert.
char getNextChar()
Fonction qui renvoie le prochain caractère du fichier courant.
Generic parser.
PGenericParser & operator=(const PGenericParser &other)
Definition of equal operator of PGenericParser.
void loadDirExtraParser(const PPath &inputDir)
Load the extra parsers.
bool parserGetEnv(PLatexObj &parent, PLatexObj &textObj)
Parse a getenv function.
bool parseBookMail(PLatexObj &parent, PLatexObj &textObj)
Parse the mail in book mode.
PLatexObj p_bookMainPageLink
Main page definition of the full site.
std::vector< PString > p_vecNameExtraParser
Vector of the name of the extra environement.
PMapExtraEnv p_vecExtraEnv
Vector of extra environements.
PLatexObj p_currentSource
Current completed source.
bool parseBookSizeBarWidth(PLatexObj &parent, PLatexObj &textObj)
Parse the width of the book sidebar.
void copyPGenericParser(const PGenericParser &other)
Copy function of PGenericParser.
void incrementCurrentChar(PLatexObj &textObj)
Increment current char position.
const PString & getBookSideBarWidth() const
Get the width of the book sidebar.
const PMapBiblioEntry & getMapBiblioEntry() const
Get the map of all bibliography entries.
void loadDirExtraEnvironementFile(const PPath &inputFile)
Load the extra environements with input file.
bool parseBookGitlabUrl(PLatexObj &parent, PLatexObj &textObj)
Parse the gitlab url in book mode.
const PLatexObj & getSource() const
Get the current source.
std::map< PString, PString > p_cssContent
Css of all the configurations.
PMapExtraEnv p_vecExtraFunction
Vector of extra function.
PPath copyFile(const PPath &outputDir, const PPath &fileName)
Copy a file.
bool saveCss()
Save the css file.
const std::vector< PString > & getVecIncludeDir() const
Get the vector of include directories.
void loadDirExtraFunction(const PPath &inputDir)
Load the extra functions.
std::vector< PString > p_vecNameFunctionExtraParser
Vector of the function name of the extra environement.
void setDebugMode(bool isDebugMode)
Set if the PGenericParser is in debug mode.
bool parseMainDate(PLatexObj &parent, PLatexObj &textObj)
Parse the main date of the site.
PPath getAbsoluteFileName(const PPath &fileName)
Get the absolute path of a file.
const PLatexObj & getBookMainPageLink() const
Get the book main page link.
PLatexObj p_currentText
Current text.
bool parseMainSubTitle(PLatexObj &parent, PLatexObj &textObj)
Parse the main title of the site.
bool playTextLatexObj(PLatexObj &parent, PLatexObj &textObj, bool isRemoveFirstLastSpace=false)
Play the text latex obj.
PString p_bookMasterProjectUrl
Master project url in book mode.
void clearLatexObj(PLatexObj &obj)
Clear a latex obj.
void loadCss(const PPath &inputDir)
Load the css.
const PString & getBookGitlabUrl() const
Get the book gitlab url.
bool parseMainAuthor(PLatexObj &parent, PLatexObj &textObj)
Parse the main author of the site.
PMapBiblioEntry p_mapBiblioEntry
Map of all bibliography entries.
std::vector< PString > p_vecIncludeDir
Vector of the include directories.
bool parseBookEnableFeedback(PLatexObj &parent, PLatexObj &textObj)
Parse the book enable feedback mode.
bool parseMainTitle(PLatexObj &parent, PLatexObj &textObj)
Parse the main title of the site.
PVecLatexEnv p_vecEnv
Vector of all the environements.
PString executeLatexCommand(const PString &inputStr)
Execute the given latex command.
void loadMapFile()
Load the map of copied files.
PString p_bookSideBarWidth
Witdh of the book side bar.
std::vector< PString > p_vecNameExtraFunction
Vector of the name of the extra function.
PGenericParser(const PString &installPrefix="")
Default constructor of PGenericParser.
std::vector< PString > p_vecNameExtraEnv
Vector of the name of the extra environement.
bool p_isEnableBookFeedback
True to enable feedback in book mode.
void addLatexObj(PLatexObj &parent, const PLatexObj &obj)
Add latex obj in parent.
std::vector< PString > p_vecNameMarkdownExtraParser
Vector of the markdown name of the extra environement.
bool parseBookMasterProject(PLatexObj &parent, PLatexObj &textObj)
Parse the master project in book mode.
virtual ~PGenericParser()
Destructor of PGenericParser.
bool parseMonoParam(PLatexObj &parent, PLatexObj &textObj, const PString &functionName, PLatexType::PLatexType type)
Parse all the functions which have mono parameter in braces {...}.
void initialisationPGenericParser(const PString &baseInstallPrefix)
Initialisation function of the class PGenericParser.
PString p_bookGitlabUrl
Gitlab url of the current sources of the project.
bool getBookEnableFeedback() const
Say if the book feedback if enable or not.
const PString & getBookMail() const
Get the book mail list.
const PString & getBookMasterProjectUrl() const
Get the book master project url.
bool parseLabel(PLatexObj &parent, PLatexObj &textObj)
Parse latex label.
void loadDirExtraEnvironement(const PPath &inputDir)
Load the extra environements.
std::vector< PString > p_vecNameFunctionExtraEnv
Vector of the name of the extra environement.
void saveMapFile()
Save the map of copied files.
PVecLatexFunc p_vecFunc
Vector of all the functions.
void loadDirExtraFunctionFile(const PPath &inputFile)
Load the extra functions with input file.
PString getOptionStringBetweenHook()
Get optional string between hooks [...].
PMapFile p_mapCopiedFile
Map of copied files.
void loadDirExtraParserFile(const PPath &inputFile)
Load the extra environements with input file.
PString getOptionStringBetweenBraces()
Get optional string between braces {...}.
std::vector< PString > p_vecNameMarkdownExtraEnv
Vector of the name of the extra environement (for markdown)
PString p_bookMail
Mail to be used to contact authors in book mode.
bool parseGenericLatexObj(PLatexObj &parent, PLatexObj &textObj)
Parse the generic latex function which have to be used in the latex parser and the markdown parser to...
bool p_isDebugMode
True if be parse in debug mode.
PString getStringBetweenBraces(const PString &previousToken)
Get the string between the braces {...}.
std::vector< PString > p_vecRemoveLatexKeyword
Vector of removed latex functions.
PVecParserEnv p_vecExtraParser
Vector of extra parser.
Describe a latex object.
Definition: PLatexObj.h:40
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
void setLabelName(const PString &labelName)
Sets the labelName of the PLatexObj.
Definition: PLatexObj.cpp:158
void setName(const PString &name)
Sets the name of the PLatexObj.
Definition: PLatexObj.cpp:144
void setType(const PLatexType::PLatexType &type)
Sets the type of the PLatexObj.
Definition: PLatexObj.cpp:130
void setDate(const PString &date)
Sets the date of the PLatexObj.
Definition: PLatexObj.cpp:242
void setAuthor(const PString &author)
Sets the author of the PLatexObj.
Definition: PLatexObj.cpp:235
void setText(const PString &text)
Sets the text of the PLatexObj.
Definition: PLatexObj.cpp:137
const PString & getText() const
Gets the text of the PLatexObj.
Definition: PLatexObj.cpp:312
void setSubTitle(const PString &subTitle)
Sets the subTitle of the PLatexObj.
Definition: PLatexObj.cpp:151
void setFileContent(const PString &fileContent)
Set the file content to be parsed.
bool isMatch(const PString &token)
Check if the given token matches the current read file.
void errorAt()
Write a parsing error.
PFileParser * p_parser
Parser helper for the config file.
bool fullParsing()
Perform the full parsing pf data.
void stopParsing()
Stop the parsing of all the files.
Parsing sequence.
Definition: PParseSeq.h:77
Parser environement.
Definition: PLatexObj.h:363
void setName(const PString &name)
Sets the name of the PParserEnv.
Definition: PLatexObj.cpp:1451
void setPlainText(const PString &plainText)
Sets the plainText of the PParserEnv.
Definition: PLatexObj.cpp:1458
const std::vector< PContext > & getVecContext() const
Gets the vecContext of the PParserEnv.
Definition: PLatexObj.cpp:1500
Path of a directory or a file.
Definition: PPath.h:17
bool saveFileContent(const PString &content) const
Save a PString in a file.
Definition: PPath.cpp:395
PPath & eraseExtension()
Erase the extension of the PPath.
Definition: PPath.cpp:292
bool createDirectory(mode_t mode=0755) const
Create the current directory.
Definition: PPath.cpp:331
PPath getParentDirectory() const
Get path of parent directory of current path.
Definition: PPath.cpp:207
time_t getFileModificationTime() const
Get the last modification time of the given file.
Definition: PPath.cpp:441
bool isFileExist() const
Say if the current file path does exist.
Definition: PPath.cpp:139
PString loadFileContent() const
Get the file content in a PString.
Definition: PPath.cpp:382
std::vector< PPath > getAllElementInDir() const
Get the list of all elements in a directory.
Definition: PPath.cpp:503
PPath getFileName() const
Get the name of the file, from last char to /.
Definition: PPath.cpp:172
Extends the std::string.
Definition: PString.h:16
PString replace(const PString &pattern, const PString &replaceStr) const
Replace a PString into an other PString.
Definition: PString.cpp:204
PString toLower() const
Convert PString in lower case.
Definition: PString.cpp:598
PString eraseFirstLastChar(const PString &vecChar) const
Erase first and last char in a string.
Definition: PString.cpp:545
PString eraseLastChar(const PString &vecChar) const
Erase first and last char in a string.
Definition: PString.cpp:521
const std::vector< PParserEnv > & getVecEnv() const
Gets the vecEnv of the PVecParserEnv.
Definition: PLatexObj.cpp:1562
Attribute from xml.
Definition: PXml.h:30
const PString & getValue() const
Get the variable p_value.
Definition: PXml.cpp:82
Class used to parse xml.
Definition: PXml.h:54
const std ::vector< PXml > & getVecChild() const
Get the variable p_vecChild.
Definition: PXml.cpp:264
bool data_load(FILE *iter, T &data)
Load data from a message.
Definition: data_file.h:39
bool data_save(FILE *iter, const T &data)
Save data in a message.
Definition: data_file.h:18
PLatexType
Type of the PLatexObj.
Definition: PLatexType.h:12
PLatexObj * getLastPLatexObj(PLatexObj &obj)
Get the last PLatexObj of the given one.
std::map< PString, PBiblioEntry > PMapBiblioEntry
Describes the map for all PBiblioEntry.
PString platexobj_text(const std::vector< PLatexObj > &vecObj)
Convert a PLatexObj in text.
PString convertBackSlahedStr(const PString &str)
Convert all the echaped char.
PVecPath PListFile
List of file.
bool pxml_getVecChildIfExist(PVecXml &vecMatch, const PXml &xml, const PString &childName)
Get the vector of childs with given name if exist.
Definition: pxml_utils.cpp:197
bool pxml_getAttrIfExist(PXmlAttr &attr, const PXml &xml, const PString &attrName)
Get the attribute with given name if exist.
Definition: pxml_utils.cpp:251
PString pxml_getFullContent(const PXml &xml)
Get the content of the PXml (children or value)
Definition: pxml_utils.cpp:395
bool pxml_parserFile(PXml &xml, const PPath &fileName, bool isSvg)
Parse a PXml with a file.
Definition: pxml_utils.cpp:38
bool pxml_getChildIfExist(PXml &match, const PXml &xml, const PString &childName)
Get the child with given name if exist.
Definition: pxml_utils.cpp:215
std::vector< PXml > PVecXml
Vector of PXml.
Definition: pxml_utils.h:14
PString select_css_theme(const PVecString &vecTheme, const PString &themeName, const PString &css)
Select the right css option by respect to the given theme.