PhoenixLecture  2.0.0
Set of tools to make lectures
PMarkdownParser.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 "PMarkdownParser.h"
9 
11 
14  :PGenericParser(installPrefix)
15 {
17 }
18 
20 
23  :PGenericParser(other)
24 {
25 
26 }
27 
29 
32  :PGenericParser(other)
33 {
34  copyPMarkdownParser(other);
35 }
36 
39 
40 }
41 
43 
47  copyPMarkdownParser(other);
48  return *this;
49 }
50 
52 
55 
56 }
57 
59 
62  if(!p_run) return false;
64  p_currentSource.setLink("index.html");
68 
69  //To parse the file we need to read char by char until we get something we know
70  while(!p_parser->isEndOfFile() && p_run){ //If we are not at the end of the file
72  else{
74  }
75  }
77  return true;
78 }
79 
82  //Save the current source
87 }
88 
91 
92 }
93 
96 
97 }
98 
100 
106 bool PMarkdownParser::parseComplexMonoParam(PLatexObj & parent, PLatexObj & textObj, const PString & functionName, PLatexType::PLatexType type){
107  if(!p_parser->isMatchToken(functionName)){return false;}
108  playTextLatexObj(parent, textObj);
109  PLatexObj tmp;
110  tmp.setType(type);
111 
112  PString textOption(getOptionStringBetweenHook());
113  tmp.setText(textOption);
114 
115  parseVecLatexObj(tmp, textObj, "{", "}");
116 
117  addLatexObj(parent, tmp);
118  return true;
119 }
120 
122 
127  if(parseSectionTitle(parent, textObj, "##### ", PLatexType::SUBSUBSECTION)){}
128  else if(parseSectionTitle(parent, textObj, "#### ", PLatexType::SUBSECTION)){}
129  else if(parseSectionTitle(parent, textObj, "### ", PLatexType::SECTION)){}
130  else if(parseSectionTitle(parent, textObj, "## ", PLatexType::CHAPTER)){}
131  else if(parseSectionTitle(parent, textObj, "# ", PLatexType::PART)){}
132 
133  else if(parseExtraEnvironement(parent, textObj)){}
134  else if(parseExtraParser(parent, textObj)){}
135  else if(parseWip(parent, textObj)){}
136  else if(parseEnvDecoration(parent, textObj, "```", "terminal", PLatexType::ENVIRONEMENT, "pre")){}
137 
138  else if(parseGenericLatexObj(parent, textObj)){}
139  else if(parseComplexMonoParam(parent, textObj, "\\footnote", PLatexType::FOOTNOTE)){}
140  else if(parseComplexMonoParam(parent, textObj, "\\caption", PLatexType::CAPTION)){}
141 
142  else if(parseEnvLatexObj(parent, textObj)){}
143  else{
144  return false;
145  }
146  return true;
147 }
148 
150 
155  if(parseItemize(parent, textObj)){}
156  else if(parseEnumerate(parent, textObj)){}
157  else if(parseNewLine(parent, textObj)){}
158  else if(parseItemLatexObj(parent, textObj)){}
159  else{
160  return false;
161  }
162 
163  return true;
164 }
165 
167 
172  if(parseComment(parent, textObj)){}
173  else if(parseTextDecoration(parent, textObj, "***", "textbfit", PLatexType::FUNCTION, "span")){}
174  else if(parseTextDecoration(parent, textObj, "**", "textbf", PLatexType::FUNCTION, "span")){}
175  else if(parseTextDecoration(parent, textObj, "*", "textit", PLatexType::FUNCTION, "span")){}
176  else if(parseTextDecoration(parent, textObj, "`", "code", PLatexType::FUNCTION, "span")){}
177 
178  else if(parseHref(parent, textObj)){}
179  else if(parseIncludeGraphic(parent, textObj)){}
180  else if(parseUrl(parent, textObj)){}
181  else if(parsePercent(parent, textObj)){}
182  else{
183  return false;
184  }
185  return true;
186 }
187 
189 
195 bool PMarkdownParser::parseSectionTitle(PLatexObj & parent, PLatexObj & textObj, const PString & functionName, PLatexType::PLatexType type){
196  if(!p_parser->isMatch(functionName)){return false;}
197  playTextLatexObj(parent, textObj);
198  PLatexObj tmp;
199  tmp.setType(type);
202 
203  PLatexObj objTitle;
204  parseVecLatexObj(objTitle, textObj, "", "\n");
205  tmp.setComplexTitle(objTitle.getVecContent());
206  addLatexObj(parent, tmp);
207  return true;
208 }
209 
211 
219 bool PMarkdownParser::parseTextDecoration(PLatexObj & parent, PLatexObj & textObj, const PString & patern, const PString & cssStyle,
220  PLatexType::PLatexType type, const PString & balise)
221 {
222  if(p_parser->isMatch("```")){return false;}
223  if(!p_parser->isMatch(patern)){return false;}
224  playTextLatexObj(parent, textObj);
225  PLatexObj tmp;
226  tmp.setType(type);
227  tmp.setName(cssStyle);
228  tmp.setBalise(balise);
229 
230  parseVecLatexObj(tmp, textObj, "", patern);
231  addLatexObj(parent, tmp);
232  return true;
233 }
234 
236 
244 bool PMarkdownParser::parseEnvDecoration(PLatexObj & parent, PLatexObj & textObj, const PString & patern, const PString & cssStyle,
245  PLatexType::PLatexType type, const PString & balise)
246 {
247  if(!p_parser->isMatch(patern)){return false;}
248  playTextLatexObj(parent, textObj);
249  PLatexObj tmp;
250  tmp.setType(type);
251  tmp.setName(cssStyle);
252  tmp.setBalise(balise);
253 
254  parseVecLatexObj(tmp, textObj, "", patern);
255  addLatexObj(parent, tmp);
256  return true;
257 }
258 
260 
265  if(!p_parser->isMatch("![")){return false;}
266  playTextLatexObj(parent, textObj);
268  if(!p_parser->isMatch("(")){
269  errorAt();
270  std::cerr << "PMarkdownParser::parseIncludeGraphic : expect '(' after '!["+option+"]' instead of '"<<p_parser->getNextChar()<<"'" << std::endl;
271  stopParsing();
272  return "";
273  }
274  PPath imageFile(p_parser->getUntilKeyWithoutPatern(")"));
275  PLatexObj tmp;
276  bool isVideo(imageFile.getExtension() == "mp4");
277  if(isVideo){ //This is not an image
279  }else{
281  }
282  PString outputDir(LATEX_IMAGE_OUTPUT_DIR);
283  if(isVideo){
284  outputDir = LATEX_VIDEO_OUTPUT_DIR;
285  }
286  PString buildFileName(copyFile(outputDir, imageFile));
287  if(buildFileName == ""){return true;}
288  tmp.setName(buildFileName);
289  tmp.setText(option);
290 
291  addLatexObj(parent, tmp);
292  return true;
293 }
294 
296 
301  if(!p_parser->isMatch("http")){return false;}
302  playTextLatexObj(parent, textObj);
303  PLatexObj tmp;
305 
306  PString link("http" + p_parser->getUntilKeyWithoutPatern(" "));
307  tmp.setName(link);
308 
309  addLatexObj(parent, tmp);
310  return true;
311 }
312 
314 
320  if(!p_parser->isMatch("[")){return false;}
321  playTextLatexObj(parent, textObj);
322  PLatexObj tmp;
324 
325  parseVecLatexObj(tmp, textObj, "", "]"); //We alrday parse the begin patern at the begining of this method
326  if(!p_parser->isMatch("(")){
328  return false;
329  }
331  tmp.setName(link);
332 
333  if(!tmp.getName().isSameBegining("http") && !tmp.getName().isSameBegining("https")){
334  PString buildFileName(copyFile(PPath(LATEX_RESSOURCES_OUTPUT_DIR), link));
335  if(buildFileName == ""){
336  if(PPath(tmp.getName()).getExtension() != "html"){
337  errorAt();
338  std::cerr << "PMarkdownParser::parseHref : cannot copy file '"<<link<<"' in '" LATEX_RESSOURCES_OUTPUT_DIR "'" << std::endl;
339  return true;
340  }
341  buildFileName = link;
342  }
343  tmp.setName(buildFileName);
344  }
345  addLatexObj(parent, tmp);
346  return true;
347 }
348 
350 
355  if(!p_parser->isMatch("%")){return false;}
356  playTextLatexObj(parent, textObj);
357  PLatexObj tmp;
359  addLatexObj(parent, tmp);
360  return true;
361 }
362 
364 
369  if(!p_parser->isMatch("\n\n")){return false;}
370  playTextLatexObj(parent, textObj);
371  PLatexObj tmp;
373  addLatexObj(parent, tmp);
374  return true;
375 }
376 
378 
383  if(!p_parser->isMatch("<!--")){return false;}
384  playTextLatexObj(parent, textObj);
385  PString comment(p_parser->getUntilKeyWithoutPatern("-->"));
386  PLatexObj tmp;
388  tmp.setName(comment);
389  addLatexObj(parent, tmp);
390  return true;
391 }
392 
394 
397 bool PMarkdownParser::parseItem(std::vector<std::pair<size_t, PLatexObj> > & vecItemLevel){
398  if(p_parser->isMatchRewind("\n\n")){return false;}
399  if(!isItem()){
400  return false;
401  }
402  size_t itemLevel(p_parser->getColumn());
403  PLatexObj itemObj;
404  itemObj.setType(PLatexType::ITEM);
405 
406  PLatexObj tmpText;
407  tmpText.setType(PLatexType::TEXT);
408 
409  //Do some loop to fill the item
410  while(!p_parser->isEndOfFile() && !p_parser->isMatchRewind("\n\n") && !isItem(true) && p_run){
411  if(parseItemLatexObj(itemObj, tmpText)){}
412  else{
413  incrementCurrentChar(tmpText);
414  }
415  }
416  playTextLatexObj(itemObj, tmpText);
417  vecItemLevel.push_back(std::pair<size_t, PLatexObj>(itemLevel, itemObj));
418  return true;
419 }
420 
422 
425 bool PMarkdownParser::isItem(bool rewind){
426  size_t currentCol(p_parser->getColumn());
428  if(!p_parser->isMatch("-")){
430  return false;
431  }
432  PString space(" \t"), currentRow(p_parser->getCurrentRow());
433  size_t i(0lu);
434  while(i < currentCol){
435  char ch = currentRow[i];
436  if(!space.find(ch)){
438  return false;
439  }
440  ++i;
441  }
442  if(rewind){
444  }
445  return true;
446 }
447 
449 
455 PLatexObj * PMarkdownParser::getProperParent(PLatexObj & parent, std::vector<size_t> & vecLevel, size_t itemLevel, PLatexType::PLatexType listItemType){
456  PLatexObj * currentParent = &parent;
457  if(vecLevel.back() >= itemLevel){ //The current parent level is too high
458  while(vecLevel.back() > itemLevel && vecLevel.size() > 1lu){
459  vecLevel.pop_back();
460  }
461  if(vecLevel.size() <= 1lu){
462  return currentParent;
463  }
464  for(size_t i(1lu); i < vecLevel.size(); ++i){
465  PLatexObj * tmpParent = currentParent;
466  PLatexObj & lastItemize = tmpParent->getVecContent().back();
467  if(lastItemize.getType() == listItemType){
468  currentParent = &lastItemize;
469  }else{
470  errorAt();
471  std::cerr << "PMarkdownParser::getProperParent : unextected PLatexObj of type " << lastItemize.getType() << std::endl;
472  stopParsing();
473  return NULL;
474  }
475  }
476  return currentParent;
477  }
478  //Only if the level has to increase of one (vecLevel.back() < itemLevel)
479  //Let's take the last parent we know
480  for(size_t i(1lu); i < vecLevel.size(); ++i){
481  PLatexObj * tmpParent = currentParent;
482  PLatexObj & lastItemize = tmpParent->getVecContent().back();
483  if(lastItemize.getType() == listItemType){
484  currentParent = &lastItemize;
485  }else{
486  errorAt();
487  std::cerr << "PMarkdownParser::getProperParent : unextected PLatexObj of type " << lastItemize.getType() << std::endl;
488  stopParsing();
489  return NULL;
490  }
491  }
492  PLatexObj newItemize;
493  newItemize.setType(listItemType);
494 
495  PLatexObj * tmpParent = currentParent;
496  addLatexObj(*tmpParent, newItemize);
497 
498  currentParent = &(tmpParent->getVecContent().back());
499  vecLevel.push_back(itemLevel);
500  return currentParent;
501 }
502 
504 
508 void PMarkdownParser::insertItemInItemize(PLatexObj & parent, const std::vector<std::pair<size_t, PLatexObj> > & vecItemLevel, PLatexType::PLatexType listItemType){
509  std::vector<size_t> parentLevel;
510  parentLevel.push_back(vecItemLevel.front().first);
511  for(std::vector<std::pair<size_t, PLatexObj> >::const_iterator it(vecItemLevel.begin()); it != vecItemLevel.end(); ++it){
512  //Get the proper parent
513  PLatexObj * currentParent = getProperParent(parent, parentLevel, it->first, listItemType);
514  if(currentParent == NULL){return;}
515  //Add the current item to it
516  addLatexObj(*currentParent, it->second);
517  }
518 }
519 
521 
526  if(!isItem(true)){return false;}
527  playTextLatexObj(parent, textObj);
528  PLatexObj tmp;
530  std::vector<std::pair<size_t, PLatexObj> > vecItemLevel;
531  while(!p_parser->isEndOfFile() && p_run && !p_parser->isMatch("\n\n")){
532  //Let's parse the current item
533  parseItem(vecItemLevel);
534  }
535 
536  insertItemInItemize(tmp, vecItemLevel, PLatexType::ITEMIZE);
537 
538  addLatexObj(parent, tmp);
539  return true;
540 }
541 
543 
546 bool PMarkdownParser::parseEnumerateItem(std::vector<std::pair<size_t, PLatexObj> > & vecItemLevel){
547  if(p_parser->isMatchRewind("\n\n")){return false;}
548  if(!isEnumerateItem()){
549  return false;
550  }
551  size_t itemLevel(p_parser->getColumn());
552  PLatexObj itemObj;
553  itemObj.setType(PLatexType::ITEM);
554 
555  PLatexObj tmpText;
556  tmpText.setType(PLatexType::TEXT);
557 
558  //Do some loop to fill the item
559  while(!p_parser->isEndOfFile() && !p_parser->isMatchRewind("\n\n") && !isEnumerateItem(true) && p_run){
560  if(parseItemLatexObj(itemObj, tmpText)){}
561  else{
562  incrementCurrentChar(tmpText);
563  }
564  }
565  playTextLatexObj(itemObj, tmpText);
566  vecItemLevel.push_back(std::pair<size_t, PLatexObj>(itemLevel, itemObj));
567  return true;
568 }
569 
571 
576  size_t currentCol(p_parser->getColumn());
577  PString listFigure(p_parser->getStrComposedOf("0123456789"));
578  if(listFigure == ""){
580  return false;
581  }
582  if(!p_parser->isMatch(". ")){
584  return false;
585  }
586  PString space(" \t"), currentRow(p_parser->getCurrentRow());
587  size_t i(0lu);
588  while(i < currentCol){
589  char ch = currentRow[i];
590  if(!space.find(ch)){
592  return false;
593  }
594  ++i;
595  }
596  if(rewind){
598  }
599  return true;
600 }
601 
603 
608  if(!isEnumerateItem(true)){return false;}
609  playTextLatexObj(parent, textObj);
610  PLatexObj tmp;
612  std::vector<std::pair<size_t, PLatexObj> > vecItemLevel;
613  while(!p_parser->isEndOfFile() && p_run && !p_parser->isMatch("\n\n")){
614  //Let's parse the current item
615  parseEnumerateItem(vecItemLevel);
616  }
617  insertItemInItemize(tmp, vecItemLevel, PLatexType::ENUMERATE);
618 
619  addLatexObj(parent, tmp);
620  return true;
621 }
622 
624 
629 void PMarkdownParser::parseVecLatexObj(PLatexObj & parent, PLatexObj & textObj, const PString & beginPatern, const PString & endPatern){
630  if(beginPatern != ""){ //If we check the begin patern
631  if(!p_parser->isMatch(beginPatern)){ //And it does not match
632  return; //We stop
633  }
634  }
635  while(!p_parser->isEndOfFile() && p_run && !p_parser->isMatch(endPatern)){
636  long unsigned int currentPos = p_parser->getCurrentCharIdx();
637 
638  if(parseAllLatexObj(parent, textObj)){}
639  else{
640  incrementCurrentChar(textObj);
641  }
642  if(currentPos == p_parser->getCurrentCharIdx() && !p_parser->isEndOfFile()){
643  std::cerr << "PMarkdownParser::parseVecLatexObj : the parser is stucked at the position :" << std::endl << "\t" << p_parser->getLocation() << std::endl;
644  p_run = false;
645  }
646  }
647  if(p_run) playTextLatexObj(parent, textObj);
648 }
649 
651 
656  if(p_vecNameMarkdownExtraEnv.size() == 0lu){return false;}
659  if(matchFunc == ""){
661  return false;
662  }
663 
664  playTextLatexObj(parent, textObj);
665  PLatexObj env;
667  PString matchEnv(matchFunc.eraseChar('`'));
668  env.setName(matchEnv);
669 
670  PEnvironement & configEnv = p_vecExtraEnv[matchEnv];
671  env.setBalise(configEnv.getBalise());
672  PLatexObj tmpText;
673  tmpText.setType(PLatexType::TEXT);
674 
675  while(!p_parser->isEndOfFile() && !p_parser->isMatch("```") && p_run){
676  if(parseEnvLatexObj(env, tmpText)){}
677  else{
678  incrementCurrentChar(tmpText);
679  }
680  }
681  playTextLatexObj(env, tmpText);
682 
683  addLatexObj(parent, env);
684  return true;
685 }
686 
687 
689 
694  if(p_vecNameMarkdownExtraParser.size() == 0lu){return false;}
697  if(matchFunc == ""){
699  return false;
700  }
701 
702  playTextLatexObj(parent, textObj);
703  PLatexObj tmp;
705  PString matchEnv(matchFunc.eraseChar('`'));
706  tmp.setName(matchEnv);
707 
708  PParserEnv parser(getParserEnv(p_vecExtraParser, matchEnv));
709 
710  PString inputFileContent(p_parser->getUntilKeyWithoutPatern("```").eraseFirstLastChar(" \n") + "\n");
711 
712  tmp.setNbline(inputFileContent.count('\n'));
713 
714  PString envContent(parser_makeHighlighting(inputFileContent, parser));
715  tmp.setText(envContent);
716  tmp.setSubTitle(inputFileContent);
717  addLatexObj(parent, tmp);
718  return true;
719 }
720 
722 
727  if(!p_parser->isMatch("```wip")){return false;}
728 
729  playTextLatexObj(parent, textObj);
730  PLatexObj env;
732 
733  PLatexObj tmpText;
734  tmpText.setType(PLatexType::TEXT);
735 
736  while(!p_parser->isEndOfFile() && !p_parser->isMatch("```") && p_run){
737  if(parseEnvLatexObj(env, tmpText)){}
738  else{
739  incrementCurrentChar(tmpText);
740  }
741  }
742  playTextLatexObj(env, tmpText);
743 
744  addLatexObj(parent, env);
745  return true;
746 }
747 
748 
749 
750 
#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
describe a CSS environement for latex
Definition: PLatexObj.h:272
const PString & getBalise() const
Gets the balise of the PEnvironement.
Definition: PLatexObj.cpp:1145
void setSeparator(const PString &separator)
Initialise la liste des caractères séparateurs.
Definition: PFileParser.cpp:43
PString getCurrentRow() const
Get the current parsed row.
size_t getColumn() const
Fonction qui renvoie le numéro de la colonne du caractère courant.
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)
PString getStrComposedOf(const PString &charset)
Get string composed of the characters in the string charset.
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.
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 getNextChar()
Fonction qui renvoie le prochain caractère du fichier courant.
Generic parser.
PMapExtraEnv p_vecExtraEnv
Vector of extra environements.
PLatexObj p_currentSource
Current completed source.
void incrementCurrentChar(PLatexObj &textObj)
Increment current char position.
PPath copyFile(const PPath &outputDir, const PPath &fileName)
Copy 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.
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.
PString getOptionStringBetweenHook()
Get optional string between hooks [...].
std::vector< PString > p_vecNameMarkdownExtraEnv
Vector of the name of the extra environement (for markdown)
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...
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 PLatexType::PLatexType & getType() const
Gets the type of the PLatexObj.
Definition: PLatexObj.cpp:298
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
void setSubTitle(const PString &subTitle)
Sets the subTitle of the PLatexObj.
Definition: PLatexObj.cpp:151
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 parseEnvDecoration(PLatexObj &parent, PLatexObj &textObj, const PString &patern, const PString &cssStyle, PLatexType::PLatexType type, const PString &balise)
Parse a text decoration (bold, italic, etc)
bool parseItemize(PLatexObj &parent, PLatexObj &textObj)
Parse some itemize.
bool parseSectionTitle(PLatexObj &parent, PLatexObj &textObj, const PString &functionName, PLatexType::PLatexType type)
Parse all the functions which have complex mono parameter in braces.
PLatexObj * getProperParent(PLatexObj &parent, std::vector< size_t > &vecLevel, size_t itemLevel, PLatexType::PLatexType listItemType)
Get the proper parent for the item with the given level.
void copyPMarkdownParser(const PMarkdownParser &other)
Copy function of PMarkdownParser.
bool parseItem(std::vector< std::pair< size_t, PLatexObj > > &vecItemLevel)
Parse an item in the markdown itemize.
virtual void preLoadFile()
Initialisation to be done just before loading a file.
bool parseHref(PLatexObj &parent, PLatexObj &textObj)
Parse latex Href.
bool parseUrl(PLatexObj &parent, PLatexObj &textObj)
Parse latex url.
virtual ~PMarkdownParser()
Destructor of PMarkdownParser.
bool parseExtraEnvironement(PLatexObj &parent, PLatexObj &textObj)
Parse extra environement (terminal, cplusplus, cmake, conseil, attention, ...)
bool parseEnumerateItem(std::vector< std::pair< size_t, PLatexObj > > &vecItemLevel)
Parse an item in the markdown enumerate.
bool parseTextDecoration(PLatexObj &parent, PLatexObj &textObj, const PString &patern, const PString &cssStyle, PLatexType::PLatexType type, const PString &balise)
Parse a text decoration (bold, italic, etc)
bool parseItemLatexObj(PLatexObj &parent, PLatexObj &textObj)
Parse all the latex obj in item, but in markdown style.
bool parseWip(PLatexObj &parent, PLatexObj &textObj)
Parse a work in progress.
bool parseEnvLatexObj(PLatexObj &parent, PLatexObj &textObj)
Parse all the latex obj in environement, but in markdown style.
bool parsePercent(PLatexObj &parent, PLatexObj &textObj)
Parse latex percent.
bool isItem(bool rewind=false)
Say if there is no space between the last return and the current char.
bool parseComment(PLatexObj &parent, PLatexObj &textObj)
Parse a new line.
bool parseIncludeGraphic(PLatexObj &parent, PLatexObj &textObj)
Parse the includegraphic command.
bool parseNewLine(PLatexObj &parent, PLatexObj &textObj)
Parse a new line.
bool parseComplexMonoParam(PLatexObj &parent, PLatexObj &textObj, const PString &functionName, PLatexType::PLatexType type)
Parse all the functions which have complex mono parameter in braces {...}.
virtual bool parseFile()
Parse the input file.
virtual void postLoadFile()
Initialisation to be done just after loading a file.
PMarkdownParser(const PString &installPrefix="")
Default constructor of PMarkdownParser.
bool isEnumerateItem(bool rewind=false)
Say if there is no space between the last return and the current char.
PMarkdownParser & operator=(const PMarkdownParser &other)
Definition of equal operator of PMarkdownParser.
bool parseEnumerate(PLatexObj &parent, PLatexObj &textObj)
Parse some enumerate.
void parseVecLatexObj(PLatexObj &parent, PLatexObj &textObj, const PString &beginPatern, const PString &endPatern)
Parse a vector of latex object.
bool parseAllLatexObj(PLatexObj &parent, PLatexObj &textObj)
Parse all the latex obj, but in markdown style.
void initialisationPMarkdownParser()
Initialisation function of the class PMarkdownParser.
bool parseExtraParser(PLatexObj &parent, PLatexObj &textObj)
Parse extra environement (terminal, cplusplus, cmake, conseil, attention, ...)
void insertItemInItemize(PLatexObj &parent, const std::vector< std::pair< size_t, PLatexObj > > &vecItemLevel, PLatexType::PLatexType listItemType)
Insert the item in the proper itemize.
void errorAt()
Write a parsing error.
PFileParser * p_parser
Parser helper for the config file.
bool p_run
Run the parsing if true.
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
PPath & eraseExtension()
Erase the extension of the PPath.
Definition: PPath.cpp:292
PString getExtension() const
Get file extension.
Definition: PPath.cpp:252
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
PLatexType
Type of the PLatexObj.
Definition: PLatexType.h:12
@ SUBSUBSECTION
Definition: PLatexType.h:54
@ AUTOSPACEPARAGRAPH
Definition: PLatexType.h:28
@ ENVIRONEMENT
Definition: PLatexType.h:85
@ 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.