PhoenixLecture  2.0.0
Set of tools to make lectures
createOutlineHtml.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 "parser_utils.h"
8 #include "platexobj_html.h"
9 #include "createOutlineHtml.h"
10 
12 
17  if(!isSection(obj) && obj.getType() != PLatexType::FILE){return "";}
18  PString body("");
19  body += "\t\t\t<li><a href=\""+obj.getLink()+"\">"+vecNumberToString(obj.getVecSecNumber())+" : "+getSectionTitle(outputMode, obj)+"</a></li>\n";
20  const PVecLatexObj & vecObj = obj.getVecContent();
21  if(vecObj.size() != 0lu){
22  body += "\t\t\t\t<ul>\n";
23  for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
24  body += createOutlineHtmlStr(outputMode, *it);
25  }
26  body += "\t\t\t\t</ul>\n";
27  }
28  return body;
29 }
30 
32 
37 bool createOutlineHtml(POutoutMode & outputMode, const PLatexObj & obj, bool isBibliography){
38  if(outputMode.isBookTheme){return false;}
39  PString body("");
40  body += getHtmlHeader("Outline", false, false, outputMode.currentStyle);
41  body += "\t\t<h1 class=\"mainTitle\">Outline</h1>\n";
42  body += "\t\t<ul class=\"sommairePage\">\n";
43  body += "\t\t\t<ul>\n";
44  body += "\t\t\t\t<li><a href=\"index.html\">Main Page</a></li>\n";
45  if(isBibliography){
46  body += "\t\t\t\t<li><a href=\"bibliography.html\">Bibliographie</a></li>\n";
47  }
48 
49  const PVecLatexObj & vecObj = obj.getVecContent();
50  if(vecObj.size() != 0lu){
51  for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
52  body += createOutlineHtmlStr(outputMode, *it);
53  }
54  }
55  body += "\t\t\t</ul>\n";
56  body += "\t\t</ul>\n";
57  body += getHtmlFooter();
58  PPath fileName("outline.html");
59  if(!fileName.saveFileContent(body)){
60  std::cerr << "createOutlineHtml : can't save file name '"<<fileName<<"'" << std::endl;
61  return false;
62  }else{
63  std::cerr << "createOutlineHtml : save file name '"<<fileName<<"'" << std::endl;
64  }
65 
66  return true;
67 }
68 
69 
70 
Describe a latex object.
Definition: PLatexObj.h:40
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
const PLatexType::PLatexType & getType() const
Gets the type of the PLatexObj.
Definition: PLatexObj.cpp:298
const PString & getLink() const
Gets the link of the PLatexObj.
Definition: PLatexObj.cpp:368
const std::vector< long unsigned int > & getVecSecNumber() const
Gets the vecSecNumber of the PLatexObj.
Definition: PLatexObj.cpp:438
Path of a directory or a file.
Definition: PPath.h:17
bool saveFileContent(const PString &content) const
Save a PString in a file.
Definition: PPath.cpp:395
Extends the std::string.
Definition: PString.h:16
bool createOutlineHtml(POutoutMode &outputMode, const PLatexObj &obj, bool isBibliography)
Create the outline.
PString createOutlineHtmlStr(POutoutMode &outputMode, const PLatexObj &obj)
Create the outline.
PString vecNumberToString(const std::vector< long unsigned int > &vecNb)
Convert a vector of numbers into a string.
PString getHtmlHeader(const PString &title, bool useMathJax, bool useRemoteMathjax, const PString &currentStyle)
Get the html header.
PString getHtmlFooter()
bool isSection(const PLatexObj &obj)
Say if the PLatexObj is a part, charpter, section, subsection or subsubsection.
PString getSectionTitle(POutoutMode &outputMode, const PLatexObj &obj)
Get the title of a part/chapter/section etc.
std::vector< PLatexObj > PVecLatexObj
Vector of obj.
Output mode of the html backend.
bool isBookTheme
True to activate the book theme.
PString currentStyle
Current style to be used for the generated pages of the site.