12 #include <sys/types.h>
65 if(!
p_run)
return false;
113 if(fileName ==
"")
return false;
114 PPath fileToBeUsed(fileName);
115 bool removeTmpFilename(
false);
119 std::cerr <<
"PConfigParser::loadInclude : cannot get file with url = '"<<fileName<<
"'" << std::endl;
123 removeTmpFilename =
true;
127 if(fileExtension ==
"md"){
130 bool b = mdParser.
load(fileToBeUsed);
133 std::vector<PLatexObj> & vecObj = mainLatexObj.
getVecContent();
134 for(std::vector<PLatexObj>::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
146 std::cerr <<
"PMultiFileParser::load : can't open file '" << fileToBeUsed <<
"'" << std::endl;
159 std::cerr <<
"PMultiFileParser::load : the parser is stucked at the position :" << std::endl <<
"\t" <<
p_parser->
getLocation() << std::endl;
167 if(removeTmpFilename){
168 remove(fileToBeUsed.c_str());
296 std::cout <<
"PConfigParser::parseBookMainPageLink : Update main page link (nb element = "<<tmpParent.
getVecContent().size()<<
")" << std::endl;
311 if(!
isMatch(
"\\spaceparagraphe")){
return false;}
354 if(!
isMatch(
"\\dots")){
return false;}
373 PPath fileToBeLoaded(fileName);
374 if(fileToBeLoaded.size() != 0lu){
375 if(fileToBeLoaded[0] !=
'/'){
379 return loadInclude(parent, textObj, fileToBeLoaded);
392 PPath fileToBeLoaded(fileName);
393 if(fileToBeLoaded.size() != 0lu){
394 if(fileToBeLoaded[0] !=
'/'){
398 return loadInclude(parent, textObj, fileToBeLoaded);
411 PString prevToken(
""), option(
"400");
422 std::cerr <<
"PConfigParser::parseVideo : expect '{' after '"+prevToken+
"' instead of '"<<ch<<
"'" << std::endl;
431 std::cerr <<
"PConfigParser::parseVideo : use video '"<<fileName<<
"' because the extension has to be '.mp4'" << std::endl;
449 buildFileName = fileName;
451 if(buildFileName ==
""){
return true;}
508 authorQuote.
setName(
"rightline");
623 if(buildFileName ==
""){
629 buildFileName = link;
682 if(beginPatern !=
""){
696 std::cerr <<
"PConfigParser::parseVecLatexObj : the parser is stucked at the position :" << std::endl <<
"\t" <<
p_parser->
getLocation() << std::endl;
713 PString prevToken(
""),option(
"");
724 std::cerr <<
"PConfigParser::parseIncludeGraphic : expect '{' after '"+prevToken+
"' instead of '"<<ch<<
"'" << std::endl;
737 buildFileName = imageFile;
739 if(buildFileName ==
""){
return true;}
760 std::cerr <<
"PConfigParser::parseTimeTable : cannot parse speakers configuration '"+speakerFile+
"'" << std::endl;
797 bool isAlreadyDefinedSpeaker =
p_vecSpeaker.size() != 0lu;
798 if(isAlreadyDefinedSpeaker){
803 std::cerr <<
"PConfigParser::parseTimeTable : cannot parse timetable configuration '"+timeTableFile+
"'" << std::endl;
812 std::cerr <<
"PConfigParser::parseTimeTable : cannot save timetable '"+timeTableFile+
"'" << std::endl;
851 std::vector<PString> vecPatern(
getEndSeqEnv(environementName));
884 std::vector<PString> vecEndPatern(
getEndSeqEnv(
"tabular"));
932 if(environementName != envName){
1009 std::vector<PString> vecPaternItemize;
1010 vecPaternItemize.push_back(
"\\end");
1011 vecPaternItemize.push_back(
"{");
1012 vecPaternItemize.push_back(
"itemize");
1013 vecPaternItemize.push_back(
"}");
1015 std::vector<PString> vecPaternEnumerate;
1016 vecPaternEnumerate.push_back(
"\\end");
1017 vecPaternEnumerate.push_back(
"{");
1018 vecPaternEnumerate.push_back(
"enumerate");
1019 vecPaternEnumerate.push_back(
"}");
1094 if(matchFunc ==
""){
1112 PPath fileName(baseContent);
1114 if(fileName[0] !=
'/'){
1122 inputFileContent = baseContent +
" ";
1148 std::cerr <<
"PConfigParser::parseExtraEnvironement : expect '{' after '\\begin' instead of '"<<ch<<
"'" << std::endl;
1162 std::cerr <<
"PConfigParser::parseExtraEnvironement : expect '}' after '\\begin{matchEnv' instead of '"<<ch<<
"'" << std::endl;
1193 if(matchFunc ==
""){
1216 if(fileName[0] !=
'/'){
1238 if(matchFunc ==
""){
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
#define LATEX_IMAGE_OUTPUT_DIR
#define LATEX_RESSOURCES_OUTPUT_DIR
#define LATEX_VIDEO_OUTPUT_DIR
#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.
Parse the pdata confguration file.
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.
bool p_isAllowMath
True to allow math.
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
bool getIsAllowComment() const
Gets the isAllowComment of the PEnvironement.
bool getIsAlloxMath() const
Gets the isAlloxMath of the PEnvironement.
const PString & getBalise() const
Gets the balise of the PEnvironement.
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
void setSeparator(const PString &separator)
Initialise la liste des caractères séparateurs.
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.
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.
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.
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.
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.
size_t getCurrentCharIdx() const
Return the index of the current character.
bool isEndOfFile() const
Dit si on est à la fin du fichier.
char getEscapeChar() const
Gets the escape character of the PFileParser.
char getNextChar()
Fonction qui renvoie le prochain caractère du fichier courant.
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.
void setLink(const PString &link)
Sets the link of the PLatexObj.
void setSourceFile(const PString &sourceFile)
Sets the sourceFile of the PLatexObj.
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
void setComplexTitle(const std::vector< PLatexObj > &complexTitle)
Sets the complexTitle of the PLatexObj.
void setBalise(const PString &balise)
Sets the balise of the PLatexObj.
const PString & getName() const
Gets the name of the PLatexObj.
void setNbline(long unsigned int nbline)
Sets the nbline of the PLatexObj.
void setName(const PString &name)
Sets the name of the PLatexObj.
void setType(const PLatexType::PLatexType &type)
Sets the type of the PLatexObj.
void setText(const PString &text)
Sets the text of the PLatexObj.
void setSourceLine(size_t sourceLine)
Sets the sourceLine of the PLatexObj.
size_t getLine() const
renvoie la ligne du PLocation
PPath getFileName() const
renvoie le fichier du PLocation
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.
Path of a directory or a file.
bool checkFileBegning(const PString &expectedBegining) const
Check if the given file starts with the given begning.
PPath & eraseExtension()
Erase the extension of the PPath.
PString getExtension() const
Get file extension.
PPath getParentDirectory() const
Get path of parent directory of current path.
bool isFileExist() const
Say if the current file path does exist.
PString loadFileContent() const
Get the file content in a PString.
PPath getFileName() const
Get the name of the file, from last char to /.
PString eraseChar(char ch) const
Erase char ch of current string.
bool isSameBegining(const PString &beginStr) const
Say if the current PString has the same begining of beginStr.
size_t count(char ch) const
Count the number of char ch in the current PString.
PString eraseFirstLastChar(const PString &vecChar) const
Erase first and last char in a string.
PLatexType
Type of the PLatexObj.
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 §ionLabel)
Save all speakers of the given PTimeTable into a vector of PLatexObj.
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.