PhoenixLecture  2.0.0
Set of tools to make lectures
PConfigParser.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 <stdio.h>
8 #include <stdlib.h>
9 #include <time.h>
10 
11 #include <sys/stat.h>
12 #include <sys/types.h>
13 
14 #include "data_all.h"
15 #include "pxml_utils.h"
16 
17 #include "PMarkdownParser.h"
18 
19 #include "PConfigParser.h"
20 
22 
24 PConfigParser::PConfigParser(const PString & installPrefix)
25  :PGenericParser(installPrefix)
26 {
27  initialisationPConfigParser(installPrefix);
28 }
29 
31 
34  :PGenericParser(other)
35 {
36  copyPConfigParser(other);
37 }
38 
41  saveMapFile();
42 }
43 
45 
49  copyPConfigParser(other);
50  return *this;
51 }
52 
54 
59 }
60 
62 
65  if(!p_run) return false;
69  p_currentSource.setLink("index.html");
71 
72  //To parse the file we need to read char by char until we get something we know
73  while(!p_parser->isEndOfFile() && p_run){ //If we are not at the end of the file
75  else{
77  }
78  }
80 
81  return true;
82 }
83 
86  //Save the current source
91 }
92 
95 
96 }
97 
99 
101 void PConfigParser::initialisationPConfigParser(const PString & baseInstallPrefix){
102  p_isAllowMath = true;
103  p_isAllowComment = true;
104 }
105 
107 
112 bool PConfigParser::loadInclude(PLatexObj & parent, PLatexObj & textObj, const PPath & fileName){
113  if(fileName == "") return false;
114  PPath fileToBeUsed(fileName);
115  bool removeTmpFilename(false);
116  if(fileName.isSameBegining("http")){
117  if(!wgetFile(fileName)){
118  errorAt();
119  std::cerr << "PConfigParser::loadInclude : cannot get file with url = '"<<fileName<<"'" << std::endl;
120  return true;
121  }
122  fileToBeUsed = fileName.getFileName();
123  removeTmpFilename = true;
124  }
125 
126  PString fileExtension(fileToBeUsed.getExtension());
127  if(fileExtension == "md"){
128  PMarkdownParser mdParser(*this);
129 
130  bool b = mdParser.load(fileToBeUsed);
131  if(!b){return b;}
132  PLatexObj & mainLatexObj = mdParser.getSource();
133  std::vector<PLatexObj> & vecObj = mainLatexObj.getVecContent();
134  for(std::vector<PLatexObj>::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
135  addLatexObj(parent, *it);
136  }
137  copyPGenericParser(mdParser);
138  return b;
139  }
140 
141  PFileParser parser;
142  p_listFileParser.push_back(parser);
144  p_parser = &p_listFileParser.back();
145  if(!p_parser->open(fileToBeUsed)){
146  std::cerr << "PMultiFileParser::load : can't open file '" << fileToBeUsed << "'" << std::endl;
147  return false;
148  }
149  p_parser->setWhiteSpace("");
150  p_parser->setSeparator("");
151  while(!p_parser->isEndOfFile() && p_run){
152  long unsigned int currentPos = p_parser->getCurrentCharIdx();
153  if(parseAllLatexObj(parent, textObj)){}
154  else{
155  incrementCurrentChar(textObj);
156  }
157 
158  if(currentPos == p_parser->getCurrentCharIdx() && !p_parser->isEndOfFile()){
159  std::cerr << "PMultiFileParser::load : the parser is stucked at the position :" << std::endl << "\t" << p_parser->getLocation() << std::endl;
160  p_run = false;
161  }
162  }
163  if(p_run) playTextLatexObj(parent, textObj);
164  p_listFileParser.pop_back();
165  if(p_listFileParser.size() > 0lu) p_parser = &p_listFileParser.back();
166  else p_parser = NULL;
167  if(removeTmpFilename){
168  remove(fileToBeUsed.c_str());
169  }
170  return p_run;
171 }
172 
174 
180 bool PConfigParser::parseComplexMonoParam(PLatexObj & parent, PLatexObj & textObj, const PString & functionName, PLatexType::PLatexType type){
181  if(!p_parser->isMatchToken(functionName)){return false;}
182  playTextLatexObj(parent, textObj);
183  PLatexObj tmp;
184  tmp.setType(type);
185 
186  PString textOption(getOptionStringBetweenHook());
187  tmp.setText(textOption);
188 
189  parseVecLatexObj(tmp, textObj, "{", "}");
190 
191  addLatexObj(parent, tmp);
192  return true;
193 }
194 
196 
201  if(p_parser->isMatch("{")){}
202  else if(p_parser->isMatch("}")){}
203  else if(skipMonoParam("\\minitoc")){}
204  else if(skipMonoParam("\\newpage")){}
205  else if(skipMonoParam("\\centering")){}
206  else if(skipMonoParam("\\def\\sgn")){}
207  else if(skipMonoParam("\\,")){}
208  else if(parsePercent(parent, textObj)){}
209  else if(p_parser->isMatch(p_vecRemoveLatexKeyword) != ""){}
210  else if(parseSpaceParagraphe(parent, textObj)){}
211  else if(parseNewLine(parent, textObj)){}
212  else if(parseRealNewLine(parent, textObj)){}
213  else if(parseDots(parent, textObj)){}
214 
215  else if(parseMonoParam(parent, textObj, "\\url", PLatexType::URL)){}
216  else if(parseGenericLatexObj(parent, textObj)){}
217  else if(parseComplexMonoParam(parent, textObj, "\\footnote", PLatexType::FOOTNOTE)){}
218  else if(parseComplexMonoParam(parent, textObj, "\\caption", PLatexType::CAPTION)){}
219 
220  else if(parseComplexMonoParam(parent, textObj, "\\wip", PLatexType::WORK_IN_PROGRESS)){}
221  else if(parseComplexMonoParam(parent, textObj, "\\workinprogress", PLatexType::WORK_IN_PROGRESS)){}
222  else if(parserDetails(parent, textObj)){}
223  else if(parserQuote(parent, textObj)){}
224  else if(parseComment(parent, textObj)){}
225  else if(parseDebug(parent, textObj)){}
226  else if(parseHref(parent, textObj)){}
227  else if(parseIncludeGraphic(parent, textObj)){}
228  else if(parseAddSpeaker(parent, textObj)){}
229  else if(parseSaveSpeaker(parent, textObj)){}
230  else if(parseTimeTable(parent, textObj)){}
231 
232  else if(parseSectionTitle(parent, textObj, "\\part*", PLatexType::PARTSTAR)){}
233  else if(parseSectionTitle(parent, textObj, "\\chapter*", PLatexType::CHAPTERSTAR)){}
234  else if(parseSectionTitle(parent, textObj, "\\section*", PLatexType::SECTIONSTAR)){}
235  else if(parseSectionTitle(parent, textObj, "\\subsection*", PLatexType::SUBSECTIONSTAR)){}
236  else if(parseSectionTitle(parent, textObj, "\\subsubsection*", PLatexType::SUBSUBSECTIONSTAR)){}
237 
238  else if(parseSectionTitle(parent, textObj, "\\part", PLatexType::PART)){}
239  else if(parseSectionTitle(parent, textObj, "\\chapter", PLatexType::CHAPTER)){}
240  else if(parseSectionTitle(parent, textObj, "\\section", PLatexType::SECTION)){}
241  else if(parseSectionTitle(parent, textObj, "\\subsection", PLatexType::SUBSECTION)){}
242  else if(parseSectionTitle(parent, textObj, "\\subsubsection", PLatexType::SUBSUBSECTION)){}
243 
244  else if(parseSectionTitle(parent, textObj, "\\bookpartseparator", PLatexType::BOOKPARTSEPARATOR)){}
245 
246  else if(parseEnvStringOnly(parent, textObj, "displaymath", PLatexType::DISPLAYMATH)){}
247  else if(parseEnvStringOnly(parent, textObj, "equation", PLatexType::DISPLAYMATH)){}
248  else if(parseEnvStringOnly(parent, textObj, "equation*", PLatexType::DISPLAYMATH)){}
249  else if(parseEnvStringOnly(parent, textObj, "eqnarray", PLatexType::EQNARRAY)){}
250  else if(parseEnvStringOnly(parent, textObj, "align*", PLatexType::EQNARRAY)){}
251  else if(parseDoubleInlineMath(parent, textObj)){}
252  else if(parseInlineMath(parent, textObj)){}
253 
254  else if(parseEnvironement(parent, textObj, "paragraph", PLatexType::PARAGRAPHE)){}
255  else if(parseEnvironement(parent, textObj, "center", PLatexType::CENTER)){}
256  else if(parseEnvironement(parent, textObj, "columns", PLatexType::COLUMNS)){}
257  else if(parseEnvironement(parent, textObj, "column", PLatexType::COLUMN)){}
258 
259  else if(parseEnvironement(parent, textObj, "figure", PLatexType::FIGURE)){}
260  else if(parseEnvironement(parent, textObj, "wrapfigure", PLatexType::FIGURE)){}
261  else if(parseEnvironement(parent, textObj, "table", PLatexType::TABLE)){}
262  else if(parseTabular(parent, textObj)){}
263  else if(parseEnvironement(parent, textObj, "itemize", PLatexType::ITEMIZE)){}
264  else if(parseEnvironement(parent, textObj, "enumerate", PLatexType::ENUMERATE)){}
265  else if(parseItem(parent, textObj)){}
266 
267  else if(parserCallDot(parent, textObj)){}
268  else if(parserSvgToPng(parent, textObj)){}
269 
270  else if(parseExtraEnvironement(parent, textObj)){}
271  else if(parseExtraEnvironementFunction(parent, textObj)){}
272  else if(parseExtraFunction(parent, textObj)){}
273  else if(parseParserLanguage(parent, textObj)){}
274  else if(parseParserLanguageFunction(parent, textObj)){}
275 
276  else if(parseIncludeFile(parent, textObj)){}
277  else if(parseInputFile(parent, textObj)){} //An other non sens of latex
278  else if(parseVideo(parent, textObj)){}
279  else if(parseBookMainPageLink(parent, textObj)){}
280  else{
281  return false;
282  }
283  return true;
284 }
285 
287 
292  PLatexObj tmpParent;
293  if(parseComplexMonoParam(tmpParent, textObj, "\\bookMainPageLink", PLatexType::BOOKMAINPAGELINK)){
294  if(tmpParent.getVecContent().size() != 0lu){
295  p_bookMainPageLink = tmpParent.getVecContent().back();
296  std::cout << "PConfigParser::parseBookMainPageLink : Update main page link (nb element = "<<tmpParent.getVecContent().size()<<")" << std::endl;
297  }
298  return true;
299  }else{
300  return false;
301  }
302 }
303 
304 
306 
311  if(!isMatch("\\spaceparagraphe")){return false;}
312  playTextLatexObj(parent, textObj);
314  PLatexObj tmp;
316  addLatexObj(parent, tmp);
317  return true;
318 }
319 
321 
326  if(!p_parser->isMatch("\n\n")){return false;}
327  playTextLatexObj(parent, textObj);
328  PLatexObj tmp;
330  addLatexObj(parent, tmp);
331  return true;
332 }
333 
335 
340  if(!p_parser->isMatch("\\\\")){return false;}
341  playTextLatexObj(parent, textObj);
342  PLatexObj tmp;
344  addLatexObj(parent, tmp);
345  return true;
346 }
347 
349 
353 bool PConfigParser::parseDots(PLatexObj & parent, PLatexObj & textObj){
354  if(!isMatch("\\dots")){return false;}
355  playTextLatexObj(parent, textObj);
357  PLatexObj tmp;
359  tmp.setText("... ");
360  addLatexObj(parent, tmp);
361  return true;
362 }
364 
369  if(!p_parser->isMatchToken("\\include")){return false;}
370  playTextLatexObj(parent, textObj);
371  PString fileName(getStringBetweenBraces("\\include"));
372 
373  PPath fileToBeLoaded(fileName);
374  if(fileToBeLoaded.size() != 0lu){
375  if(fileToBeLoaded[0] != '/'){
376  fileToBeLoaded = p_parser->getFileName().getParentDirectory() / fileToBeLoaded;
377  }
378  }
379  return loadInclude(parent, textObj, fileToBeLoaded);
380 }
381 
383 
388  if(!p_parser->isMatchToken("\\input")){return false;}
389  playTextLatexObj(parent, textObj);
390  PString fileName(getStringBetweenBraces("\\input"));
391 
392  PPath fileToBeLoaded(fileName);
393  if(fileToBeLoaded.size() != 0lu){
394  if(fileToBeLoaded[0] != '/'){
395  fileToBeLoaded = p_parser->getFileName().getParentDirectory() / fileToBeLoaded;
396  }
397  }
398  return loadInclude(parent, textObj, fileToBeLoaded);
399 }
400 
402 
407  if(!p_parser->isMatchToken("\\video")){return false;}
408  playTextLatexObj(parent, textObj);
410  char ch = p_parser->getCurrentCh();
411  PString prevToken(""), option("400");
412  prevToken += ch;
413  if(ch == '['){ //We skip the options for now
415  option = p_parser->getUntilKeyWithoutPatern("]");
416  prevToken += option;
417  ch = p_parser->getCurrentCh();
418  }
420  if(ch != '{'){
421  errorAt();
422  std::cerr << "PConfigParser::parseVideo : expect '{' after '"+prevToken+"' instead of '"<<ch<<"'" << std::endl;
423  stopParsing();
424  return true;
425  }
427  PPath fileName(p_parser->getUntilKeyWithoutPatern("}"));
428 
429  if(fileName.getExtension() != "mp4"){
430  errorAt();
431  std::cerr << "PConfigParser::parseVideo : use video '"<<fileName<<"' because the extension has to be '.mp4'" << std::endl;
432  stopParsing();
433  return true;
434  }
435 
436  PLatexObj tmp;
437  tmp.setText(option);
439 
440  PString buildFileName("");
441  if(!fileName.isSameBegining("http")){
442  PPath fileToBeUsed(getAbsoluteFileName(fileName));
443  if(fileToBeUsed.checkFileBegning("http")){ //If the file contains an url, we replace it by the url
444  buildFileName = fileToBeUsed.loadFileContent();
445  }else{ //Otherwise, we just copy the file
446  buildFileName = copyFile(PPath(LATEX_VIDEO_OUTPUT_DIR), fileName);
447  }
448  }else{
449  buildFileName = fileName;
450  }
451  if(buildFileName == ""){return true;}
452  tmp.setName(buildFileName);
453  addLatexObj(parent, tmp);
454  return true;
455 }
456 
458 
463  std::vector<PString> vecBeginPatern(getBeginSeqEnv("detail"));
464  if(!p_parser->isMatchSeq(vecBeginPatern)){return false;}
465  playTextLatexObj(parent, textObj);
466  //Parse the summary
467  PLatexObj summaryObj;
468  summaryObj.setType(PLatexType::SUMMARY);
469  parseVecLatexObj(summaryObj, textObj, "{", "}");
470 
471  PLatexObj env;
473  env.setName("details");
474  env.setBalise("details");
475 
476  addLatexObj(env, summaryObj);
477  //Parse the environement
478  PLatexObj tmpText;
479  tmpText.setType(PLatexType::TEXT);
480  std::vector<PString> vecPatern(getEndSeqEnv("detail"));
481 
482  while(!p_parser->isEndOfFile() && !p_parser->isMatchSeq(vecPatern) && p_run){
483  if(parseAllLatexObj(env, tmpText)){}
484  else{
485  incrementCurrentChar(tmpText);
486  }
487  }
488  playTextLatexObj(env, tmpText);
489  addLatexObj(parent, env);
490  return true;
491 }
492 
494 
499  std::vector<PString> vecBeginPatern(getBeginSeqEnv("quote"));
500  if(!p_parser->isMatchSeq(vecBeginPatern)){return false;}
501  playTextLatexObj(parent, textObj);
502 
503  PLatexObj env;
505 
506  PLatexObj authorQuote;
507  authorQuote.setType(PLatexType::FUNCTION);
508  authorQuote.setName("rightline");
509  authorQuote.setBalise("div");
510  parseVecLatexObj(authorQuote, textObj, "{", "}");
511 
512  PLatexObj contentQuote;
513  contentQuote.setType(PLatexType::CENTER);
514 
515  //Parse the environement
516  PLatexObj tmpText;
517  tmpText.setType(PLatexType::TEXT);
518  std::vector<PString> vecPatern(getEndSeqEnv("quote"));
519 
520  while(!p_parser->isEndOfFile() && !p_parser->isMatchSeq(vecPatern) && p_run){
521  if(parseAllLatexObj(contentQuote, tmpText)){}
522  else{
523  incrementCurrentChar(tmpText);
524  }
525  }
526  playTextLatexObj(contentQuote, tmpText);
527 
528  addLatexObj(env, contentQuote);
529  addLatexObj(env, authorQuote);
530 
531  addLatexObj(parent, env);
532  return true;
533 }
534 
536 
541  if(!p_parser->isMatchToken("\\calldot")){return false;}
542  playTextLatexObj(parent, textObj);
544  PLatexObj tmp;
546  PString baseContent(p_parser->getUntilKeyWithoutPaternRecurse("}", "{"));
547  PString fileName(baseContent);
548  tmp.setName(fileName);
549  tmp.setText(p_parser->getFileName());
550  addLatexObj(parent, tmp);
551  return true;
552 }
553 
555 
560  if(!p_parser->isMatchToken("\\svgtopng")){return false;}
561  playTextLatexObj(parent, textObj);
563  PLatexObj tmp;
565  PString fileName(p_parser->getUntilKeyWithoutPatern("}"));
566  tmp.setName(fileName);
567  tmp.setText(p_parser->getFileName());
568  addLatexObj(parent, tmp);
569  return true;
570 }
571 
573 
578  if(!p_isAllowComment){return false;}
579  if(!p_parser->isMatch("%")){return false;}
580  playTextLatexObj(parent, textObj);
581  PString comment(p_parser->getUntilKeyWithoutPatern("\n"));
582  PLatexObj tmp;
584  tmp.setName(comment);
585  addLatexObj(parent, tmp);
586  return true;
587 }
588 
590 
595  if(!p_parser->isMatchToken("\\debug")){return false;}
596  if(p_isDebugMode){
597  playTextLatexObj(parent, textObj);
598  PLatexObj tmp;
600  PString text(getStringBetweenBraces("\\debug"));
601  tmp.setName(text);
602  addLatexObj(parent, tmp);
603  }
604  return true;
605 }
606 
608 
612 bool PConfigParser::parseHref(PLatexObj & parent, PLatexObj & textObj){
613  if(!p_parser->isMatchToken("\\href")){return false;}
614  playTextLatexObj(parent, textObj);
615  PLatexObj tmp;
617  PString link(getStringBetweenBraces("\\href"));
618  tmp.setName(link);
619 
620  parseVecLatexObj(tmp, textObj, "{", "}");
621  if(!tmp.getName().isSameBegining("http") && !tmp.getName().isSameBegining("https")){
622  PPath buildFileName(copyFile(PPath(LATEX_RESSOURCES_OUTPUT_DIR), link));
623  if(buildFileName == ""){
624  if(PPath(tmp.getName()).getExtension() != "html"){
625  errorAt();
626  std::cerr << "PConfigParser::parseHref : cannot copy file '"<<link<<"' in '" LATEX_RESSOURCES_OUTPUT_DIR "'" << std::endl;
627  return true;
628  }
629  buildFileName = link;
630  }
631  tmp.setName(buildFileName);
632  }
633  addLatexObj(parent, tmp);
634  return true;
635 }
636 
638 
643  if(!p_parser->isMatch("\\%")){return false;}
644  playTextLatexObj(parent, textObj);
645  PLatexObj tmp;
647  addLatexObj(parent, tmp);
648  return true;
649 }
650 
652 
658 bool PConfigParser::parseSectionTitle(PLatexObj & parent, PLatexObj & textObj, const PString & functionName, PLatexType::PLatexType type){
659  if(!p_parser->isMatchToken(functionName)){return false;}
660  playTextLatexObj(parent, textObj);
661  PLatexObj tmp;
662  tmp.setType(type);
665 
666  PString textOption(getOptionStringBetweenHook());
667  tmp.setText(textOption);
668  PLatexObj objTitle;
669  parseVecLatexObj(objTitle, textObj, "{", "}");
670  tmp.setComplexTitle(objTitle.getVecContent());
671  addLatexObj(parent, tmp);
672  return true;
673 }
674 
676 
681 void PConfigParser::parseVecLatexObj(PLatexObj & parent, PLatexObj & textObj, const PString & beginPatern, const PString & endPatern){
682  if(beginPatern != ""){ //If we check the begin patern
683  if(!p_parser->isMatch(beginPatern)){ //And it does not match
684  return; //We stop
685  }
686  }
688  while(!p_parser->isEndOfFile() && p_run && !p_parser->isMatch(endPatern)){
689  long unsigned int currentPos = p_parser->getCurrentCharIdx();
690 
691  if(parseAllLatexObj(parent, textObj)){}
692  else{
693  incrementCurrentChar(textObj);
694  }
695  if(currentPos == p_parser->getCurrentCharIdx() && !p_parser->isEndOfFile()){
696  std::cerr << "PConfigParser::parseVecLatexObj : the parser is stucked at the position :" << std::endl << "\t" << p_parser->getLocation() << std::endl;
697  p_run = false;
698  }
699  }
700  if(p_run) playTextLatexObj(parent, textObj);
701 }
702 
704 
709  if(!p_parser->isMatchToken("\\includegraphics")){return false;}
710  playTextLatexObj(parent, textObj);
712  char ch = p_parser->getCurrentCh();
713  PString prevToken(""),option("");
714  prevToken += ch;
715  if(ch == '['){ //We skip the options for now
717  option = p_parser->getUntilKeyWithoutPatern("]");
718  prevToken += option;
719  ch = p_parser->getCurrentCh();
720  }
722  if(ch != '{'){
723  errorAt();
724  std::cerr << "PConfigParser::parseIncludeGraphic : expect '{' after '"+prevToken+"' instead of '"<<ch<<"'" << std::endl;
725  stopParsing();
726  return "";
727  }
729  PString imageFile(p_parser->getUntilKeyWithoutPatern("}"));
730  PLatexObj tmp;
732 
733  PString buildFileName("");
734  if(!imageFile.isSameBegining("http")){
735  buildFileName = copyFile(PPath(LATEX_IMAGE_OUTPUT_DIR), imageFile);
736  }else{
737  buildFileName = imageFile;
738  }
739  if(buildFileName == ""){return true;}
740  tmp.setName(buildFileName);
741  tmp.setText(option);
742 
743  addLatexObj(parent, tmp);
744  return true;
745 }
746 
748 
753  if(!p_parser->isMatchToken("\\addspeakers")){return false;}
754  playTextLatexObj(parent, textObj);
755  PPath speakerConfig = getOptionStringBetweenBraces();
756  PPath speakerFile = p_parser->getFileName().getParentDirectory() / speakerConfig;
757 
758  if(!ptimetable_loadSpeaker(p_vecSpeaker, speakerFile)){
759  errorAt();
760  std::cerr << "PConfigParser::parseTimeTable : cannot parse speakers configuration '"+speakerFile+"'" << std::endl;
761  stopParsing();
762  return true;
763  }
764 
765  return true;
766 }
767 
769 
774  if(!p_parser->isMatchToken("\\savespeakers")){return false;}
775  playTextLatexObj(parent, textObj);
777 
778  pspeaker_tex(parent.getVecContent(), p_vecSpeaker, "sec_full_speakers");
779  return true;
780 }
781 
783 
788  if(!p_parser->isMatchToken("\\timetable")){return false;}
789  playTextLatexObj(parent, textObj);
790  PPath timetableConfig = getOptionStringBetweenBraces();
791  PPath timeTableFile = p_parser->getFileName().getParentDirectory() / timetableConfig;
792  //We have to try to load speakers in some are defined in the timetable configuration
793  //But we need also to add \addspeakers function to update a map of speakers in the PGenericParser
794 
795  //Load the timetable toml config
796  PTimeTable timetable;
797  bool isAlreadyDefinedSpeaker = p_vecSpeaker.size() != 0lu;
798  if(isAlreadyDefinedSpeaker){
799  timetable.setVecSpeaker(p_vecSpeaker);
800  }
801  if(!ptimetable_load(timetable, timeTableFile)){
802  errorAt();
803  std::cerr << "PConfigParser::parseTimeTable : cannot parse timetable configuration '"+timeTableFile+"'" << std::endl;
804  stopParsing();
805  return true;
806  }
807  //Update begin and end time of blocks
808  ptimetable_updateEndTime(timetable);
809  //Create the HTML PLatexObj
810  if(!ptimetable_tex(parent.getVecContent(), timetable, PPath(LATEX_INVITATION_OUTPUT_DIR), !isAlreadyDefinedSpeaker)){
811  errorAt();
812  std::cerr << "PConfigParser::parseTimeTable : cannot save timetable '"+timeTableFile+"'" << std::endl;
813  stopParsing();
814  }
815  return true;
816 }
817 
819 
825 bool PConfigParser::parseEnvironement(PLatexObj & parent, PLatexObj & textObj, const PString & environementName, PLatexType::PLatexType type){
826  std::vector<PString> vecPatern(getBeginSeqEnv(environementName));
827  if(!p_parser->isMatchSeq(vecPatern)){return false;}
828  return parseEnvironementContent(parent, textObj, environementName, type, true, true, "div");
829 }
830 
832 
841 bool PConfigParser::parseEnvironementContent(PLatexObj & parent, PLatexObj & textObj, const PString & environementName,
842  PLatexType::PLatexType type, bool isAllowComment, bool isAllowMath, const PString & envBalise)
843 {
844  playTextLatexObj(parent, textObj);
845  PLatexObj env;
846  env.setType(type);
847  env.setName(environementName);
848  env.setBalise(envBalise);
849  PLatexObj tmpText;
850  tmpText.setType(PLatexType::TEXT);
851  std::vector<PString> vecPatern(getEndSeqEnv(environementName));
852 
853  bool saveIsAllowComment(p_isAllowComment), saveIsAllowMath(p_isAllowMath);
854  p_isAllowComment = isAllowComment;
855  p_isAllowMath = isAllowMath;
856  while(!p_parser->isEndOfFile() && !p_parser->isMatchSeq(vecPatern) && p_run){
857  if(parseAllLatexObj(env, tmpText)){}
858  else{
859  incrementCurrentChar(tmpText);
860  }
861  }
862  p_isAllowComment = saveIsAllowComment;
863  p_isAllowMath = saveIsAllowMath;
864 
865  playTextLatexObj(env, tmpText);
866  addLatexObj(parent, env);
867  return true;
868 }
869 
871 
876  std::vector<PString> vecBeginPatern(getBeginSeqEnv("tabular"));
877  if(!p_parser->isMatchSeq(vecBeginPatern)){return false;}
878  playTextLatexObj(parent, textObj);
879  getOptionStringBetweenBraces(); //Remove tabular option
880  PLatexObj envTabular;
881  envTabular.setType(PLatexType::TABULAR);
882  envTabular.setName("tabular");
883 
884  std::vector<PString> vecEndPatern(getEndSeqEnv("tabular"));
885 
886  while(!p_parser->isEndOfFile() && !p_parser->isMatchSeq(vecEndPatern) && p_run){ //Parse all rows
887  PLatexObj rowObj;
888  rowObj.setType(PLatexType::TABROW);
889  while(!p_parser->isEndOfFile() && !p_parser->isMatchSeq(vecEndPatern, true) &&
890  !p_parser->isMatch("\\\\") && p_run) //Parse one row
891  {
892  PLatexObj cellObj;
893  cellObj.setType(PLatexType::TABCELL);
894 
895  PLatexObj tmpText;
896  tmpText.setType(PLatexType::TEXT);
897  //Parse all cells
898  while(!p_parser->isEndOfFile() && !p_parser->isMatchSeq(vecEndPatern, true) &&
899  !p_parser->isMatchRewind("\\\\") &&
900  !p_parser->isMatch("&") && p_run) //Parse one cell
901  {
902  if(parseAllLatexObj(cellObj, tmpText)){}
903  else{
904  incrementCurrentChar(tmpText);
905  }
906  }
907  playTextLatexObj(cellObj, tmpText, true);
908  if(cellObj.getVecContent().size() != 0lu){
909  rowObj.getVecContent().push_back(cellObj); //Add cell in row
910  }
911  }
912  if(rowObj.getVecContent().size() != 0lu){
913  envTabular.getVecContent().push_back(rowObj); //Add row in tabular
914  }
915  }
916 
917  addLatexObj(parent, envTabular);
918  return true;
919 }
920 
922 
928 bool PConfigParser::parseEnvStringOnly(PLatexObj & parent, PLatexObj & textObj, const PString & environementName, PLatexType::PLatexType type){
930  if(!p_parser->isMatchToken("\\begin")){return false;}
931  PString envName(getStringBetweenBraces("\\begin").eraseFirstLastChar(" \t\n"));
932  if(environementName != envName){
934  return false;
935  }
936  playTextLatexObj(parent, textObj);
937  PString envContent(p_parser->getUntilKeyWithoutPatern("\\end{"+environementName+"}"));
938 
939  PLatexObj tmp;
940  tmp.setType(type);
941  tmp.setText(envContent);
942 
943  addLatexObj(parent, tmp);
944  return true;
945 }
946 
948 
953  if(!p_isAllowMath){return false;}
954  if(!p_parser->isMatch("$", "\\")){return false;}
955  playTextLatexObj(parent, textObj);
956  PString mathText(p_parser->getUntilKeyWithoutPatern("$"));
957  PLatexObj inlineMath;
958  inlineMath.setType(PLatexType::INLINEMATH);
959  inlineMath.setText(mathText);
960 
961  addLatexObj(parent, inlineMath);
962  return true;
963 }
964 
966 
971  if(!p_isAllowMath){return false;}
972  if(!p_parser->isMatch("$$", "\\")){return false;}
973  playTextLatexObj(parent, textObj);
974  PString mathText(p_parser->getUntilKeyWithoutPatern("$$"));
975  PLatexObj inlineMath;
976  inlineMath.setType(PLatexType::DISPLAYMATH);
977  inlineMath.setText(mathText);
978 
979  addLatexObj(parent, inlineMath);
980  return true;
981 }
982 
984 
989  bool b = p_parser->isMatch(str);
991  return b;
992 }
993 
995 
999 bool PConfigParser::parseItem(PLatexObj & parent, PLatexObj & textObj){
1000  if(!p_parser->isMatch("\\item")){return false;}
1001  playTextLatexObj(parent, textObj);
1002 
1003  PLatexObj env;
1005 
1006  PLatexObj tmpText;
1007  tmpText.setType(PLatexType::TEXT);
1008 
1009  std::vector<PString> vecPaternItemize;
1010  vecPaternItemize.push_back("\\end");
1011  vecPaternItemize.push_back("{");
1012  vecPaternItemize.push_back("itemize");
1013  vecPaternItemize.push_back("}");
1014 
1015  std::vector<PString> vecPaternEnumerate;
1016  vecPaternEnumerate.push_back("\\end");
1017  vecPaternEnumerate.push_back("{");
1018  vecPaternEnumerate.push_back("enumerate");
1019  vecPaternEnumerate.push_back("}");
1020 
1021  while(!p_parser->isEndOfFile() && !p_parser->isMatchSeq(vecPaternItemize, true) &&
1022  !p_parser->isMatchSeq(vecPaternEnumerate, true) &&
1023  !parseStringAndGoBack("\\item") && p_run)
1024  {
1025  if(parseAllLatexObj(env, tmpText)){}
1026  else{
1027  incrementCurrentChar(tmpText);
1028  }
1029  }
1030  playTextLatexObj(env, tmpText);
1031 
1032  addLatexObj(parent, env);
1033 
1034 
1035  return true;
1036 }
1037 
1039 
1044  if(p_vecNameExtraParser.size() == 0lu){return false;}
1046  if(!p_parser->isMatchToken("\\begin")){return false;}
1048  char ch = p_parser->getCurrentCh();
1049  if(ch != '{'){
1050  p_parser->popPosition(); //This is not the expected environement
1051  return false;
1052  }
1053  p_parser->getNextChar();
1055  if(matchEnv == ""){
1056  p_parser->popPosition();
1057  return false;
1058  }
1060  ch = p_parser->getCurrentCh();
1061  if(ch != '}'){
1062  p_parser->popPosition(); //This is not the expected environement
1063  return false;
1064  }
1065  p_parser->getNextChar();
1066  playTextLatexObj(parent, textObj);
1067  PLatexObj tmp;
1069  tmp.setName(matchEnv);
1070 
1071  PParserEnv parser(getParserEnv(p_vecExtraParser, matchEnv));
1072  char saveEscapeChar = p_parser->getEscapeChar();
1073  p_parser->setEscapeChar('\0');
1074  PString inputFileContent(p_parser->getUntilKeyWithoutPatern("\\end{"+matchEnv+"}").eraseFirstLastChar(" \n") + "\n");
1075  p_parser->setEscapeChar(saveEscapeChar);
1076  tmp.setNbline(inputFileContent.count('\n'));
1077 
1078  PString envContent(parser_makeHighlighting(inputFileContent, parser));
1079  tmp.setText(envContent);
1080 
1081  addLatexObj(parent, tmp);
1082  return true;
1083 }
1084 
1086 
1091  if(p_vecNameFunctionExtraParser.size() == 0lu){return false;}
1094  if(matchFunc == ""){
1095  p_parser->popPosition();
1096  return false;
1097  }
1099  char ch = p_parser->getCurrentCh();
1100  if(ch != '{'){
1101  p_parser->popPosition(); //This is not the expected environement
1102  return false;
1103  }
1104  playTextLatexObj(parent, textObj);
1105  PLatexObj tmp;
1107  PString matchEnv(matchFunc.eraseChar('\\'));
1108  tmp.setName(matchEnv);
1109 
1110  p_parser->getNextChar();
1111  PString baseContent(p_parser->getUntilKeyWithoutPaternRecurse("}", "{"));
1112  PPath fileName(baseContent);
1113  if(fileName != ""){
1114  if(fileName[0] != '/'){
1115  fileName = p_parser->getFileName().getParentDirectory() / fileName;
1116  }
1117  PParserEnv parser(getParserEnv(p_vecExtraParser, matchEnv));
1118  PString inputFileContent("");
1119  if(fileName.isFileExist()){
1120  inputFileContent = fileName.loadFileContent().eraseFirstLastChar(" \n") + "\n";
1121  }else{
1122  inputFileContent = baseContent + " ";
1123  }
1124  tmp.setNbline(inputFileContent.count('\n')); //The first line has no \n, if there is a \n there are two lines
1125 
1126  PString envContent(parser_makeHighlighting(inputFileContent, parser));
1127  tmp.setText(envContent);
1128 
1129  addLatexObj(parent, tmp);
1130  }
1131 
1132  return true;
1133 }
1134 
1136 
1141  if(p_vecNameExtraEnv.size() == 0lu){return false;}
1143  if(!p_parser->isMatch("\\begin")){return false;}
1145  char ch = p_parser->getCurrentCh();
1146  if(ch != '{'){
1147  errorAt();
1148  std::cerr << "PConfigParser::parseExtraEnvironement : expect '{' after '\\begin' instead of '"<<ch<<"'" << std::endl;
1149  stopParsing();
1150  return true;
1151  }
1152  p_parser->getNextChar();
1154  if(matchEnv == ""){
1155  p_parser->popPosition();
1156  return false;
1157  }
1159  ch = p_parser->getCurrentCh();
1160  if(ch != '}'){
1161  errorAt();
1162  std::cerr << "PConfigParser::parseExtraEnvironement : expect '}' after '\\begin{matchEnv' instead of '"<<ch<<"'" << std::endl;
1163  stopParsing();
1164  return true;
1165  }
1166  p_parser->getNextChar();
1167  return parseExtraEnvironementContent(parent, textObj, matchEnv, PLatexType::ENVIRONEMENT);
1168 }
1169 
1171 
1177 bool PConfigParser::parseExtraEnvironementContent(PLatexObj & parent, PLatexObj & textObj, const PString & environementName, PLatexType::PLatexType type){
1178  PEnvironement & configEnv = p_vecExtraEnv[environementName];
1179  return parseEnvironementContent(parent, textObj, environementName,
1180  type, configEnv.getIsAllowComment(), configEnv.getIsAlloxMath(), configEnv.getBalise());
1181 }
1182 
1183 
1185 
1190  if(p_vecNameFunctionExtraEnv.size() == 0lu){return false;}
1193  if(matchFunc == ""){
1194  p_parser->popPosition();
1195  return false;
1196  }
1198  char ch = p_parser->getCurrentCh();
1199  if(ch != '{'){
1200  p_parser->popPosition(); //This is not the expected environement
1201  return false;
1202  }
1203  playTextLatexObj(parent, textObj);
1204  PLatexObj tmp;
1206 
1207  PString matchEnv(matchFunc.eraseChar('\\'));
1208  tmp.setName(matchEnv);
1209 
1210  PEnvironement & configEnv = p_vecExtraEnv[matchEnv];
1211  tmp.setBalise(configEnv.getBalise());
1212 
1213  p_parser->getNextChar();
1214  PPath fileName(p_parser->getUntilKeyWithoutPatern("}"));
1215  if(fileName != ""){
1216  if(fileName[0] != '/'){
1217  fileName = p_parser->getFileName().getParentDirectory() / fileName;
1218  }
1219  PString envContent(fileName.loadFileContent().eraseFirstLastChar(" \t\n"));
1220  PLatexObj content;
1221  content.setType(PLatexType::TEXT);
1222  content.setText(envContent);
1223  tmp.getVecContent().push_back(content);
1224  addLatexObj(parent, tmp);
1225  }
1226  return true;
1227 }
1228 
1230 
1235  if(p_vecNameExtraFunction.size() == 0lu){return false;}
1238  if(matchFunc == ""){
1239  p_parser->popPosition();
1240  return false;
1241  }
1242  if(!isMatchRewind("{")){
1243  p_parser->popPosition(); //This is not the expected environement
1244  return false;
1245  }
1246  playTextLatexObj(parent, textObj);
1247  PLatexObj tmp;
1249  PString matchEnv(matchFunc.eraseChar('\\'));
1250  tmp.setName(matchEnv);
1251 
1252  PEnvironement & configEnv = p_vecExtraFunction[matchEnv];
1253  tmp.setBalise(configEnv.getBalise());
1254 
1255  parseVecLatexObj(tmp, textObj, "{", "}");
1256 
1257  addLatexObj(parent, tmp);
1258  return true;
1259 }
1260 
1262 
1265 bool PConfigParser::skipMonoParam(const PString & functionName){
1266  if(!p_parser->isMatchToken(functionName)){return false;}
1267  //Skip hook option
1269  //Skip brace content
1271  return true;
1272 }
1273 
1274 
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.
PVecString getBeginSeqEnv(const PString &envName)
Get the sequence of the begining of an environement.
#define PARSER_SKIP_SPACE
Macro to skip space.
#define LATEX_INVITATION_OUTPUT_DIR
Definition: PLatexObj_def.h:14
#define LATEX_IMAGE_OUTPUT_DIR
Definition: PLatexObj_def.h:11
#define LATEX_RESSOURCES_OUTPUT_DIR
Definition: PLatexObj_def.h:13
#define LATEX_VIDEO_OUTPUT_DIR
Definition: PLatexObj_def.h:12
#define MULTI_PARSER_SEPARATORS_STRING
void eraseFirstLastChar(PVecString &vecOut, const PVecString &vecStr, const PString &vecChar)
Erase first and last characters of all PString in given vector.
Definition: PString.cpp:52
Parse the pdata confguration file.
Definition: PConfigParser.h:13
bool parseIncludeFile(PLatexObj &parent, PLatexObj &textObj)
Parse a file inclusion.
bool parseSpaceParagraphe(PLatexObj &parent, PLatexObj &textObj)
Parse a space paragraphe.
virtual void postLoadFile()
Initialisation to be done just after loading a file.
bool parsePercent(PLatexObj &parent, PLatexObj &textObj)
Parse latex percent.
bool loadInclude(PLatexObj &parent, PLatexObj &textObj, const PPath &fileName)
Load a included file.
bool parseParserLanguageFunction(PLatexObj &parent, PLatexObj &textObj)
Parse a language parser with a function which get an input file.
bool parseExtraEnvironementContent(PLatexObj &parent, PLatexObj &textObj, const PString &environementName, PLatexType::PLatexType type)
Parse latex environement.
bool parseVideo(PLatexObj &parent, PLatexObj &textObj)
Parse a file inclusion.
bool parseComplexMonoParam(PLatexObj &parent, PLatexObj &textObj, const PString &functionName, PLatexType::PLatexType type)
Parse all the functions which have complex mono parameter in braces {...}.
bool parseHref(PLatexObj &parent, PLatexObj &textObj)
Parse latex Href.
bool parseStringAndGoBack(const PString &str)
Parse a string an go back if the string exists.
bool parserDetails(PLatexObj &parent, PLatexObj &textObj)
Parse a detail environement.
PConfigParser(const PString &installPrefix="")
Default constructeur of PConfigParser.
bool parseExtraEnvironementFunction(PLatexObj &parent, PLatexObj &textObj)
Parse extra environement (terminal, cplusplus, cmake, conseil, attention, ...)
bool parseInlineMath(PLatexObj &parent, PLatexObj &textObj)
Parse an inline math formula.
bool parseDots(PLatexObj &parent, PLatexObj &textObj)
Parse a space paragraphe.
bool parseTimeTable(PLatexObj &parent, PLatexObj &textObj)
Parse the timetable command.
bool parserCallDot(PLatexObj &parent, PLatexObj &textObj)
Parse a call to dot.
bool p_isAllowComment
True to allow comments.
Definition: PConfigParser.h:85
bool p_isAllowMath
True to allow math.
Definition: PConfigParser.h:87
PConfigParser & operator=(const PConfigParser &other)
Definition of equal operator of PConfigParser.
virtual ~PConfigParser()
Destructeur of PConfigParser.
bool parserSvgToPng(PLatexObj &parent, PLatexObj &textObj)
Parse a svg to png function.
bool parseNewLine(PLatexObj &parent, PLatexObj &textObj)
Parse a new line.
bool parseEnvironement(PLatexObj &parent, PLatexObj &textObj, const PString &environementName, PLatexType::PLatexType type)
Parse latex environement.
bool parseDoubleInlineMath(PLatexObj &parent, PLatexObj &textObj)
Parse an inline math formula.
bool parserQuote(PLatexObj &parent, PLatexObj &textObj)
Parse a quote environnement.
bool parseComment(PLatexObj &parent, PLatexObj &textObj)
Parse a comment.
bool parseAllLatexObj(PLatexObj &parent, PLatexObj &textObj)
Parse all the latex obj.
bool parseInputFile(PLatexObj &parent, PLatexObj &textObj)
Parse a file inclusion.
bool parseEnvStringOnly(PLatexObj &parent, PLatexObj &textObj, const PString &environementName, PLatexType::PLatexType type)
Parse an environement which contains only a string.
virtual bool parseFile()
Parse the input file.
bool parseDebug(PLatexObj &parent, PLatexObj &textObj)
Parse the debug function.
bool parseRealNewLine(PLatexObj &parent, PLatexObj &textObj)
Parse a new line.
bool parseSectionTitle(PLatexObj &parent, PLatexObj &textObj, const PString &functionName, PLatexType::PLatexType type)
Parse all the functions which have complex mono parameter in braces {...}.
void copyPConfigParser(const PConfigParser &other)
Copy function of PConfigParser.
bool parseSaveSpeaker(PLatexObj &parent, PLatexObj &textObj)
Parse the savespeakers command.
bool parseTabular(PLatexObj &parent, PLatexObj &textObj)
Parse a tabular environement.
bool parseIncludeGraphic(PLatexObj &parent, PLatexObj &textObj)
Parse the includegraphic command.
bool parseParserLanguage(PLatexObj &parent, PLatexObj &textObj)
Parse language parser (cplusplus, cmake, glsl, cuda, ...)
void initialisationPConfigParser(const PString &baseInstallPrefix)
Initialisation function of the class PConfigParser.
bool parseAddSpeaker(PLatexObj &parent, PLatexObj &textObj)
Parse the addspeakers command.
bool parseBookMainPageLink(PLatexObj &parent, PLatexObj &textObj)
Parse the book main page link.
bool parseEnvironementContent(PLatexObj &parent, PLatexObj &textObj, const PString &environementName, PLatexType::PLatexType type, bool isAllowComment, bool isAllowMath, const PString &envBalise)
Parse latex environement.
bool skipMonoParam(const PString &functionName)
Skip a mon parameter.
bool parseExtraEnvironement(PLatexObj &parent, PLatexObj &textObj)
Parse extra environement (terminal, cplusplus, cmake, conseil, attention, ...)
virtual void preLoadFile()
Initialisation to be done just before loading a file.
bool parseExtraFunction(PLatexObj &parent, PLatexObj &textObj)
Parse extra environement (terminal, cplusplus, cmake, conseil, attention, ...)
void parseVecLatexObj(PLatexObj &parent, PLatexObj &textObj, const PString &beginPatern, const PString &endPatern)
Parse a vector of latex object.
bool parseItem(PLatexObj &parent, PLatexObj &textObj)
Parse an item.
describe a CSS environement for latex
Definition: PLatexObj.h:272
bool getIsAllowComment() const
Gets the isAllowComment of the PEnvironement.
Definition: PLatexObj.cpp:1159
bool getIsAlloxMath() const
Gets the isAlloxMath of the PEnvironement.
Definition: PLatexObj.cpp:1173
const PString & getBalise() const
Gets the balise of the PEnvironement.
Definition: PLatexObj.cpp:1145
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
Definition: PFileParser.h:20
void setSeparator(const PString &separator)
Initialise la liste des caractères séparateurs.
Definition: PFileParser.cpp:43
bool isMatchSeq(const PVecString &patern, bool alwaysPopBack=false)
Match a sequence of token in a vector.
bool open(const PPath &fileName)
Fonction qui ouvre le fichier que l'on va parser.
Definition: PFileParser.cpp:24
PString getUntilKeyWithoutPatern(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern exclu.
void setEscapeChar(char escapeChar)
Sets the escape character of the PFileParser.
Definition: PFileParser.cpp:58
PString getUntilKeyWithoutPaternRecurse(const PString &patern, const PString &beginPatern, const PString &allowedCharAfterBegin)
Get the string until end sequence and take account recursive patern (embeded strings)
void setWhiteSpace(const PString &whiteSpace)
Initialise la liste des caractères blancs.
Definition: PFileParser.cpp:35
bool isMatchRewind(const PString &patern)
Do a isMatch and then go back at the previous position.
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.
void popPosition()
Get to the last saved position of the PFileParser in the current file.
Definition: PFileParser.cpp:99
PLocation getLocation() const
Fonction qui renvoie la PLocation du PFileParser.
PPath getFileName() const
Fonction qui renvoie le nom du fichier que l'on a ouvert.
void pushPosition()
Remember the current position of the PFileParser in the current file.
Definition: PFileParser.cpp:93
size_t getCurrentCharIdx() const
Return the index of the current character.
bool isEndOfFile() const
Dit si on est à la fin du fichier.
Definition: PFileParser.cpp:88
char getEscapeChar() const
Gets the escape character of the PFileParser.
char getNextChar()
Fonction qui renvoie le prochain caractère du fichier courant.
Generic parser.
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.
void copyPGenericParser(const PGenericParser &other)
Copy function of PGenericParser.
void incrementCurrentChar(PLatexObj &textObj)
Increment current char position.
const PLatexObj & getSource() const
Get the current source.
std::vector< PLatexSpeaker > p_vecSpeaker
Vector of all Speakers in the project.
PMapExtraEnv p_vecExtraFunction
Vector of extra function.
PPath copyFile(const PPath &outputDir, const PPath &fileName)
Copy a file.
std::vector< PString > p_vecNameFunctionExtraParser
Vector of the function name of the extra environement.
PPath getAbsoluteFileName(const PPath &fileName)
Get the absolute path of a file.
PLatexObj p_currentText
Current text.
bool playTextLatexObj(PLatexObj &parent, PLatexObj &textObj, bool isRemoveFirstLastSpace=false)
Play the text latex obj.
void clearLatexObj(PLatexObj &obj)
Clear a latex obj.
std::vector< PString > p_vecNameExtraFunction
Vector of the name of the extra function.
std::vector< PString > p_vecNameExtraEnv
Vector of the name of the extra environement.
void addLatexObj(PLatexObj &parent, const PLatexObj &obj)
Add latex obj in parent.
bool parseMonoParam(PLatexObj &parent, PLatexObj &textObj, const PString &functionName, PLatexType::PLatexType type)
Parse all the functions which have mono parameter in braces {...}.
std::vector< PString > p_vecNameFunctionExtraEnv
Vector of the name of the extra environement.
void saveMapFile()
Save the map of copied files.
PString getOptionStringBetweenHook()
Get optional string between hooks [...].
PString getOptionStringBetweenBraces()
Get optional string between braces {...}.
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
void setLink(const PString &link)
Sets the link of the PLatexObj.
Definition: PLatexObj.cpp:165
void setSourceFile(const PString &sourceFile)
Sets the sourceFile of the PLatexObj.
Definition: PLatexObj.cpp:249
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
void setComplexTitle(const std::vector< PLatexObj > &complexTitle)
Sets the complexTitle of the PLatexObj.
Definition: PLatexObj.cpp:179
void setBalise(const PString &balise)
Sets the balise of the PLatexObj.
Definition: PLatexObj.cpp:172
const PString & getName() const
Gets the name of the PLatexObj.
Definition: PLatexObj.cpp:326
void setNbline(long unsigned int nbline)
Sets the nbline of the PLatexObj.
Definition: PLatexObj.cpp:193
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 setText(const PString &text)
Sets the text of the PLatexObj.
Definition: PLatexObj.cpp:137
void setSourceLine(size_t sourceLine)
Sets the sourceLine of the PLatexObj.
Definition: PLatexObj.cpp:256
size_t getLine() const
renvoie la ligne du PLocation
Definition: PLocation.cpp:67
PPath getFileName() const
renvoie le fichier du PLocation
Definition: PLocation.cpp:60
Class which parses Markdown as into for web site generator.
bool load(const PPath &configFile)
Load the PMultiFileParser with the configFile.
std::list< PFileParser > p_listFileParser
List of all the parsers for all the loaded files.
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 p_run
Run the parsing if true.
bool isMatchRewind(const PString &token)
Check if the given token matches the current read file and goes back even if the token matches.
void stopParsing()
Stop the parsing of all the files.
Parser environement.
Definition: PLatexObj.h:363
Path of a directory or a file.
Definition: PPath.h:17
bool checkFileBegning(const PString &expectedBegining) const
Check if the given file starts with the given begning.
Definition: PPath.cpp:421
PPath & eraseExtension()
Erase the extension of the PPath.
Definition: PPath.cpp:292
PString getExtension() const
Get file extension.
Definition: PPath.cpp:252
PPath getParentDirectory() const
Get path of parent directory of current path.
Definition: PPath.cpp:207
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
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 eraseChar(char ch) const
Erase char ch of current string.
Definition: PString.cpp:478
bool isSameBegining(const PString &beginStr) const
Say if the current PString has the same begining of beginStr.
Definition: PString.cpp:306
size_t count(char ch) const
Count the number of char ch in the current PString.
Definition: PString.cpp:323
PString eraseFirstLastChar(const PString &vecChar) const
Erase first and last char in a string.
Definition: PString.cpp:545
Timetable.
Definition: PTimeTable.h:197
void setVecSpeaker(const std::vector< PLatexSpeaker > &vecSpeaker)
Sets the vecSpeaker of the PTimeTable.
Definition: PTimeTable.cpp:824
PLatexType
Type of the PLatexObj.
Definition: PLatexType.h:12
@ SUBSUBSECTION
Definition: PLatexType.h:54
@ SUBSECTIONSTAR
Definition: PLatexType.h:60
@ AUTOSPACEPARAGRAPH
Definition: PLatexType.h:28
@ BOOKMAINPAGELINK
Definition: PLatexType.h:65
@ SPACEPARAGRAPH
Definition: PLatexType.h:27
@ ENVIRONEMENT
Definition: PLatexType.h:85
@ SUBSUBSECTIONSTAR
Definition: PLatexType.h:61
@ BOOKPARTSEPARATOR
Definition: PLatexType.h:64
@ WORK_IN_PROGRESS
Definition: PLatexType.h:32
PString parser_makeHighlighting(const PString &strContent, const PParserEnv &parser)
Do the highlighting of the input text.
PParserEnv getParserEnv(const PVecParserEnv &vecParser, const PString &nameParser)
Get the parser env.
void pspeaker_tex(std::vector< PLatexObj > &vecContent, const std::vector< PLatexSpeaker > &vecSpeaker, const PString &sectionLabel)
Save all speakers of the given PTimeTable into a vector of PLatexObj.
bool ptimetable_tex(std::vector< PLatexObj > &vecContent, const PTimeTable &timetable, const PPath &outputDirectory, bool isSaveSpeaker)
Convert a PTimeTable into PLatexObj.
void ptimetable_updateEndTime(PTimeTable &timetable)
Update the end time of the blocks.
bool ptimetable_load(PTimeTable &timetable, const PPath &configFile)
Load the PTimeTable with a toml configuration.
bool ptimetable_loadSpeaker(std::vector< PLatexSpeaker > &vecOutputSpeaker, const DicoValue &dico)
Load the speakers of the PTimeTable.