19 PString command(
"wget \""+url+
"\"");
20 return system(command.c_str()) != 0;
29 vecEndPatern.push_back(
"\\begin");
30 vecEndPatern.push_back(
"{");
31 vecEndPatern.push_back(envName);
32 vecEndPatern.push_back(
"}");
42 vecEndPatern.push_back(
"\\end");
43 vecEndPatern.push_back(
"{");
44 vecEndPatern.push_back(envName);
45 vecEndPatern.push_back(
"}");
170 vecTheme.push_back(itStyle->first);
174 PString cssStyle(itStyle->second), cssThemeName(itStyle->first);
177 cssStyle +=
"." + it->second.getName() +
"Style{\n";
184 cssStyle +=
"." + it->second.getName() +
"Style{\n";
189 PPath fileName(cssThemeName +
"_style.css");
191 std::cerr <<
"PGenericParser::saveCss : can't save the file '"<<fileName<<
"'" << std::endl;
280 if(isRemoveFirstLastSpace){
323 std::cerr <<
"PGenericParser::getStringBetweenBraces : expect '{' after '"<<previousToken<<
"' instead of '"<<
p_parser->
getNextChar()<<
"'" << std::endl;
415 if(ptrLatex != NULL){
565 isAllowComment = value ==
"yes" || value ==
"1" || value ==
"y";
575 std::cerr <<
"PGenericParser::loadDirExtraEnvironementFile : can't read file '"<<inputFile<<
"'" << std::endl;
580 std::cerr <<
"PGenericParser::loadDirExtraEnvironementFile : can't find <environement> </environement> balise in file '"<<inputFile<<
"'" << std::endl;
585 for(PVecXml::iterator it(listEnv.begin()); it != listEnv.end(); ++it){
590 std::cerr <<
"PGenericParser::loadDirExtraEnvironementFile : expect name in balise" << std::endl;
598 bool isAllowComment(
true), isAllowMath(
true);
624 if(listInputFile.size() == 0lu){
625 std::cerr <<
"PGenericParser::loadDirExtraEnvironement : can't read directory '"<<inputDir<<
"'" << std::endl;
628 for(PListFile::iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
639 std::cerr <<
"PGenericParser::loadDirExtraFunctionFile : can't read file '"<<inputFile<<
"'" << std::endl;
644 std::cerr <<
"PGenericParser::loadDirExtraFunctionFile : can't find <function> </function> balise in file '"<<inputFile<<
"'" << std::endl;
649 for(PVecXml::iterator it(listEnv.begin()); it != listEnv.end(); ++it){
654 std::cerr <<
"PGenericParser::loadDirExtraFunctionFile : expect name in balise" << std::endl;
679 if(listInputFile.size() == 0lu){
680 std::cerr <<
"PGenericParser::loadDirExtraFunction : can't read directory '"<<inputDir<<
"'" << std::endl;
683 for(PListFile::iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
694 std::cerr <<
"PGenericParser::loadDirExtraParserFile : can't read file '"<<inputFile<<
"'" << std::endl;
699 std::cerr <<
"PGenericParser::loadDirExtraParserFile : can't find <highlighting> </highlighting> balise in file '"<<inputFile<<
"'" << std::endl;
708 parserEnv.
setName(environementName);
716 for(PVecXml::iterator itBalise(listEnv.begin()); itBalise != listEnv.end(); ++itBalise){
721 std::cerr <<
"PGenericParser::loadDirExtraEnvironementFile : expect 'class' in balise" << std::endl;
735 PXml matchNotBeforeBegin;
739 PXml matchNotAfterBegin;
743 PXml matchNotBeforEnd;
749 for(PVecXml::iterator it(listKw.begin()); it != listKw.end(); ++it){
760 std::cerr <<
"PGenericParser::loadDirExtraParserFile : can't initialise sequence with balise in file '"<<inputFile<<
"'" << std::endl;
774 if(listInputFile.size() == 0lu){
775 std::cerr <<
"PGenericParser::loadDirExtraParser : can't read directory '"<<inputDir<<
"'" << std::endl;
778 for(PListFile::iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
788 if(listInputFile.size() == 0lu){
789 std::cerr <<
"PGenericParser::loadCss : can't read directory '"<<inputDir<<
"'" << std::endl;
792 for(PListFile::iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
793 PString styleName(it->getFileName().eraseExtension());
794 PPath tmpFile(inputDir / (*it));
816 PPath fileToBeCopied(fileName);
820 std::cerr <<
"PGenericParser::getAbsoluteFileName : file '"<<fileName<<
"' does not exists, even relative to the current parsed file that gives '"<<fileToBeCopied<<
"'" << std::endl;
824 return fileToBeCopied;
834 std::cerr <<
"PGenericParser::copyFile : fileName is empty" << std::endl;
838 if(fileToBeCopied ==
""){
839 std::cerr <<
"PGenericParser::copyFile : file '"<<fileName<<
"' does not exists, even relative to the current parsed file that gives '"<<fileToBeCopied<<
"'" << std::endl;
845 PPath buildFileName(outputDir +
PPath(
"/") + linkDir +
PPath(
"/") + baseFileName);
855 if(currentModifTime == it->second && currentModifTime > 0){
857 std::cout <<
"PGenericParser::copyFile : no need to copy file '"<<fileName<<
"' already updated at time " << currentModifTime << std::endl;
858 return buildFileName;
864 if(!
PPath(outputDir +
"/" + linkDir).createDirectory()){
865 std::cerr <<
"PGenericParser::copyFile : cannot create directory '"<<(outputDir +
"/" + linkDir)<<
"'" << std::endl;
870 std::cerr <<
"PGenericParser::copyFile : cannot create directory '"<<outputDir<<
"'" << std::endl;
878 PString command(
"cp "+fileToBeCopied+
" " + buildFileName);
879 if(system(command.c_str()) != 0){
881 std::cerr <<
"PGenericParser::copyFile : can't copy file '"<<fileToBeCopied<<
"' into '"<<buildFileName<<
"' directory" << std::endl;
887 return buildFileName;
898 PString installPrefix(CMAKE_INSTALL_PREFIX);
899 if(baseInstallPrefix !=
""){
900 installPrefix = baseInstallPrefix;
903 PPath dirExtraEnv(installPrefix+
"/share/PhoenixTex2Html/ENVIRONEMENT");
906 PPath dirExtraFunction(installPrefix+
"/share/PhoenixTex2Html/FUNCTION");
909 PPath dirExtraParser(installPrefix+
"/share/PhoenixTex2Html/PARSER");
912 PPath dirCss(installPrefix+
"/share/PhoenixTex2Html/STYLE");
PVecString getEndSeqEnv(const PString &envName)
Get the sequence of the ending of an environement.
bool wgetFile(const PString &url)
Do a wget of a file.
void setBoolFromAttr(bool &isAllowComment, const PXml &xml, const PString &name)
Get a boolean from xml attribute.
PVecString getBeginSeqEnv(const PString &envName)
Get the sequence of the begining of an environement.
#define COPIED_RECOVER_FILE
Define the name of the file which contains the formulae and the path to the created file.
#define PARSER_SKIP_SPACE
Macro to skip space.
bool loadParserSeq(PParseSeq &seq, const PXml &xmlSeq)
Load a ParseSeq with a XML balise.
std::vector< PString > PVecString
Parse the pdata confguration file.
Context for parser environement.
void setBegin(const PString &begin)
Sets the begin of the PContext.
void setNotBeforeBegin(const PString ¬BeforeBegin)
Sets the notBeforeBegin of the PContext.
void setSeq(const PParseSeq &seq)
Sets the seq of the PContext.
void setNotBeforeEnd(const PString ¬BeforeEnd)
Sets the notBeforeEnd of the PContext.
const std::vector< PString > & getVecKeyword() const
Gets the vecKeyword of the PContext.
void setEnd(const PString &end)
Sets the end of the PContext.
void setNotAfterBegin(const PString ¬AfterBegin)
Sets the notAfterBegin of the PContext.
void setName(const PString &name)
Sets the name of the PContext.
describe a CSS environement for latex
void setName(const PString &name)
Sets the name of the PEnvironement.
void setCss(const PString &css)
Sets the css of the PEnvironement.
void setBalise(const PString &balise)
Sets the balise of the PEnvironement.
void setIsAllowComment(bool isAllowComment)
Sets the isAllowComment of the PEnvironement.
void setIsAlloxMath(bool isAlloxMath)
Sets the isAlloxMath of the PEnvironement.
PString getUntilKeyWithoutPatern(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern exclu.
PString getUntilKeyWithoutPaternRecurse(const PString &patern, const PString &beginPatern, const PString &allowedCharAfterBegin)
Get the string until end sequence and take account recursive patern (embeded strings)
bool isMatchToken(const PString &patern)
Says if the patern match with the current caracters of the PFileParser but treats the string as a tok...
bool isMatch(const PString &patern)
Says if the patern match with the current caracters of the PFileParser.
char getCurrentCh() const
Renvoie le caractère courant.
PPath getFileName() const
Fonction qui renvoie le nom du fichier que l'on a ouvert.
char getNextChar()
Fonction qui renvoie le prochain caractère du fichier courant.
PGenericParser & operator=(const PGenericParser &other)
Definition of equal operator of PGenericParser.
void loadDirExtraParser(const PPath &inputDir)
Load the extra parsers.
bool parserGetEnv(PLatexObj &parent, PLatexObj &textObj)
Parse a getenv function.
bool parseBookMail(PLatexObj &parent, PLatexObj &textObj)
Parse the mail in book mode.
PLatexObj p_bookMainPageLink
Main page definition of the full site.
std::vector< PString > p_vecNameExtraParser
Vector of the name of the extra environement.
PMapExtraEnv p_vecExtraEnv
Vector of extra environements.
PLatexObj p_currentSource
Current completed source.
bool parseBookSizeBarWidth(PLatexObj &parent, PLatexObj &textObj)
Parse the width of the book sidebar.
void copyPGenericParser(const PGenericParser &other)
Copy function of PGenericParser.
void incrementCurrentChar(PLatexObj &textObj)
Increment current char position.
const PString & getBookSideBarWidth() const
Get the width of the book sidebar.
const PMapBiblioEntry & getMapBiblioEntry() const
Get the map of all bibliography entries.
void loadDirExtraEnvironementFile(const PPath &inputFile)
Load the extra environements with input file.
bool parseBookGitlabUrl(PLatexObj &parent, PLatexObj &textObj)
Parse the gitlab url in book mode.
const PLatexObj & getSource() const
Get the current source.
std::map< PString, PString > p_cssContent
Css of all the configurations.
PMapExtraEnv p_vecExtraFunction
Vector of extra function.
PPath copyFile(const PPath &outputDir, const PPath &fileName)
Copy a file.
bool saveCss()
Save the css file.
const std::vector< PString > & getVecIncludeDir() const
Get the vector of include directories.
void loadDirExtraFunction(const PPath &inputDir)
Load the extra functions.
std::vector< PString > p_vecNameFunctionExtraParser
Vector of the function name of the extra environement.
void setDebugMode(bool isDebugMode)
Set if the PGenericParser is in debug mode.
bool parseMainDate(PLatexObj &parent, PLatexObj &textObj)
Parse the main date of the site.
PPath getAbsoluteFileName(const PPath &fileName)
Get the absolute path of a file.
const PLatexObj & getBookMainPageLink() const
Get the book main page link.
PLatexObj p_currentText
Current text.
bool parseMainSubTitle(PLatexObj &parent, PLatexObj &textObj)
Parse the main title of the site.
bool playTextLatexObj(PLatexObj &parent, PLatexObj &textObj, bool isRemoveFirstLastSpace=false)
Play the text latex obj.
PString p_bookMasterProjectUrl
Master project url in book mode.
void clearLatexObj(PLatexObj &obj)
Clear a latex obj.
void loadCss(const PPath &inputDir)
Load the css.
const PString & getBookGitlabUrl() const
Get the book gitlab url.
bool parseMainAuthor(PLatexObj &parent, PLatexObj &textObj)
Parse the main author of the site.
PMapBiblioEntry p_mapBiblioEntry
Map of all bibliography entries.
std::vector< PString > p_vecIncludeDir
Vector of the include directories.
bool parseBookEnableFeedback(PLatexObj &parent, PLatexObj &textObj)
Parse the book enable feedback mode.
bool parseMainTitle(PLatexObj &parent, PLatexObj &textObj)
Parse the main title of the site.
PVecLatexEnv p_vecEnv
Vector of all the environements.
PString executeLatexCommand(const PString &inputStr)
Execute the given latex command.
void loadMapFile()
Load the map of copied files.
PString p_bookSideBarWidth
Witdh of the book side bar.
std::vector< PString > p_vecNameExtraFunction
Vector of the name of the extra function.
PGenericParser(const PString &installPrefix="")
Default constructor of PGenericParser.
std::vector< PString > p_vecNameExtraEnv
Vector of the name of the extra environement.
bool p_isEnableBookFeedback
True to enable feedback in book mode.
void addLatexObj(PLatexObj &parent, const PLatexObj &obj)
Add latex obj in parent.
std::vector< PString > p_vecNameMarkdownExtraParser
Vector of the markdown name of the extra environement.
bool parseBookMasterProject(PLatexObj &parent, PLatexObj &textObj)
Parse the master project in book mode.
virtual ~PGenericParser()
Destructor of PGenericParser.
bool parseMonoParam(PLatexObj &parent, PLatexObj &textObj, const PString &functionName, PLatexType::PLatexType type)
Parse all the functions which have mono parameter in braces {...}.
void initialisationPGenericParser(const PString &baseInstallPrefix)
Initialisation function of the class PGenericParser.
PString p_bookGitlabUrl
Gitlab url of the current sources of the project.
bool getBookEnableFeedback() const
Say if the book feedback if enable or not.
const PString & getBookMail() const
Get the book mail list.
const PString & getBookMasterProjectUrl() const
Get the book master project url.
bool parseLabel(PLatexObj &parent, PLatexObj &textObj)
Parse latex label.
void loadDirExtraEnvironement(const PPath &inputDir)
Load the extra environements.
std::vector< PString > p_vecNameFunctionExtraEnv
Vector of the name of the extra environement.
void saveMapFile()
Save the map of copied files.
PVecLatexFunc p_vecFunc
Vector of all the functions.
void loadDirExtraFunctionFile(const PPath &inputFile)
Load the extra functions with input file.
PString getOptionStringBetweenHook()
Get optional string between hooks [...].
PMapFile p_mapCopiedFile
Map of copied files.
void loadDirExtraParserFile(const PPath &inputFile)
Load the extra environements with input file.
PString getOptionStringBetweenBraces()
Get optional string between braces {...}.
std::vector< PString > p_vecNameMarkdownExtraEnv
Vector of the name of the extra environement (for markdown)
PString p_bookMail
Mail to be used to contact authors in book mode.
bool parseGenericLatexObj(PLatexObj &parent, PLatexObj &textObj)
Parse the generic latex function which have to be used in the latex parser and the markdown parser to...
bool p_isDebugMode
True if be parse in debug mode.
PString getStringBetweenBraces(const PString &previousToken)
Get the string between the braces {...}.
std::vector< PString > p_vecRemoveLatexKeyword
Vector of removed latex functions.
PVecParserEnv p_vecExtraParser
Vector of extra parser.
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
void setLabelName(const PString &labelName)
Sets the labelName 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 setDate(const PString &date)
Sets the date of the PLatexObj.
void setAuthor(const PString &author)
Sets the author of the PLatexObj.
void setText(const PString &text)
Sets the text of the PLatexObj.
const PString & getText() const
Gets the text of the PLatexObj.
void setSubTitle(const PString &subTitle)
Sets the subTitle of the PLatexObj.
void setFileContent(const PString &fileContent)
Set the file content to be parsed.
bool isMatch(const PString &token)
Check if the given token matches the current read file.
void errorAt()
Write a parsing error.
PFileParser * p_parser
Parser helper for the config file.
bool fullParsing()
Perform the full parsing pf data.
void stopParsing()
Stop the parsing of all the files.
void setName(const PString &name)
Sets the name of the PParserEnv.
void setPlainText(const PString &plainText)
Sets the plainText of the PParserEnv.
const std::vector< PContext > & getVecContext() const
Gets the vecContext of the PParserEnv.
Path of a directory or a file.
bool saveFileContent(const PString &content) const
Save a PString in a file.
PPath & eraseExtension()
Erase the extension of the PPath.
bool createDirectory(mode_t mode=0755) const
Create the current directory.
PPath getParentDirectory() const
Get path of parent directory of current path.
time_t getFileModificationTime() const
Get the last modification time of the given file.
bool isFileExist() const
Say if the current file path does exist.
PString loadFileContent() const
Get the file content in a PString.
std::vector< PPath > getAllElementInDir() const
Get the list of all elements in a directory.
PPath getFileName() const
Get the name of the file, from last char to /.
PString replace(const PString &pattern, const PString &replaceStr) const
Replace a PString into an other PString.
PString toLower() const
Convert PString in lower case.
PString eraseFirstLastChar(const PString &vecChar) const
Erase first and last char in a string.
PString eraseLastChar(const PString &vecChar) const
Erase first and last char in a string.
const std::vector< PParserEnv > & getVecEnv() const
Gets the vecEnv of the PVecParserEnv.
const PString & getValue() const
Get the variable p_value.
const std ::vector< PXml > & getVecChild() const
Get the variable p_vecChild.
bool data_load(FILE *iter, T &data)
Load data from a message.
bool data_save(FILE *iter, const T &data)
Save data in a message.
PLatexType
Type of the PLatexObj.
PLatexObj * getLastPLatexObj(PLatexObj &obj)
Get the last PLatexObj of the given one.
std::map< PString, PBiblioEntry > PMapBiblioEntry
Describes the map for all PBiblioEntry.
PString platexobj_text(const std::vector< PLatexObj > &vecObj)
Convert a PLatexObj in text.
PString convertBackSlahedStr(const PString &str)
Convert all the echaped char.
PVecPath PListFile
List of file.
bool pxml_getVecChildIfExist(PVecXml &vecMatch, const PXml &xml, const PString &childName)
Get the vector of childs with given name if exist.
bool pxml_getAttrIfExist(PXmlAttr &attr, const PXml &xml, const PString &attrName)
Get the attribute with given name if exist.
PString pxml_getFullContent(const PXml &xml)
Get the content of the PXml (children or value)
bool pxml_parserFile(PXml &xml, const PPath &fileName, bool isSvg)
Parse a PXml with a file.
bool pxml_getChildIfExist(PXml &match, const PXml &xml, const PString &childName)
Get the child with given name if exist.
std::vector< PXml > PVecXml
Vector of PXml.
PString select_css_theme(const PVecString &vecTheme, const PString &themeName, const PString &css)
Select the right css option by respect to the given theme.