Directory: | ./ |
---|---|
File: | tmp_project/PhoenixTex2Html/src/PLatexObj/platexobj_html_book.cpp |
Date: | 2025-03-24 18:12:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 54 | 56 | 96.4% |
Branches: | 139 | 163 | 85.3% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #include "phoenix_system.h" | ||
8 | #include "platexobj_html.h" | ||
9 | #include "platexobj_menu.h" | ||
10 | #include "platexobj_rawtext.h" | ||
11 | |||
12 | #include "platexobj_html_book.h" | ||
13 | |||
14 | |||
15 | ///Create a page with book theme | ||
16 | /** @param[out] outputMode : output mode of the html backend | ||
17 | * @param obj : PLatexObj to be saved | ||
18 | * @param baliseName : name of the title balise | ||
19 | * @param cssClassName : css class to be used | ||
20 | * @param prefixTitle : prefix of the title (Part or Chapter) | ||
21 | * @param isBibliography : true if there is a bibliography, false if not | ||
22 | * @return true on success, false otherwise | ||
23 | */ | ||
24 | 238 | bool platexobj_book_createPage(POutoutMode & outputMode, const PLatexObj & obj, | |
25 | const PString & baliseName, const PString & cssClassName, const PString & prefixTitle, bool isBibliography) | ||
26 | { | ||
27 |
1/1✓ Branch 1 taken 238 times.
|
238 | PString body(""); |
28 |
1/1✓ Branch 1 taken 238 times.
|
238 | const PVecLatexObj & vecObj = obj.getVecContent(); |
29 |
2/2✓ Branch 3 taken 2833 times.
✓ Branch 4 taken 238 times.
|
3071 | for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
30 |
2/2✓ Branch 2 taken 2833 times.
✓ Branch 5 taken 2833 times.
|
2833 | body += platexobj_bookHtml(outputMode, *it, isBibliography, true); |
31 | } | ||
32 |
1/1✓ Branch 1 taken 238 times.
|
238 | PString objTitle(getSectionTitle(outputMode, obj)); //Content of the section title |
33 |
7/7✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
✓ Branch 7 taken 238 times.
✓ Branch 10 taken 238 times.
✓ Branch 13 taken 238 times.
✓ Branch 16 taken 238 times.
✓ Branch 19 taken 238 times.
|
476 | platexobj_theme_update_var(outputMode, obj.getLink(), platexobj_rawtext(obj.getComplexTitle()), |
34 |
4/4✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
✓ Branch 7 taken 238 times.
✓ Branch 10 taken 238 times.
|
238 | obj.getPrevSec().getLink(), obj.getPrevSec().getText(), |
35 |
4/4✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
✓ Branch 7 taken 238 times.
✓ Branch 10 taken 238 times.
|
238 | obj.getNextSec().getLink(), obj.getNextSec().getText(), |
36 |
4/4✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
✓ Branch 7 taken 238 times.
✓ Branch 10 taken 238 times.
|
238 | obj.getParentSec().getLink(), obj.getParentSec().getText(), |
37 | obj.getSourceFile(), obj.getSourceLine()); | ||
38 | |||
39 |
6/6✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
✓ Branch 7 taken 238 times.
✓ Branch 10 taken 238 times.
✓ Branch 13 taken 238 times.
✓ Branch 16 taken 238 times.
|
238 | outputMode.mapVar["${MAIN_TITLE}"] = "\t\t" + platexobj_createTitle(obj, baliseName, cssClassName, objTitle, prefixTitle, true); |
40 | // outputMode.mapVar["${SUB_MENU}"] = vecMenuToHtml(obj.getVecMenu()); | ||
41 |
3/3✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
✓ Branch 7 taken 238 times.
|
238 | outputMode.mapVar["${SUB_MENU}"] = ""; |
42 |
3/3✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
✓ Branch 7 taken 238 times.
|
238 | outputMode.mapVar["${PAGE_CONTENT}"] = body; |
43 | |||
44 |
2/2✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
|
238 | PPath fileName(obj.getLink()); |
45 |
3/4✓ Branch 1 taken 238 times.
✓ Branch 4 taken 238 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 238 times.
|
238 | if(!fileName.saveFileContent(platexobj_theme_createPage(outputMode))){ |
46 | ✗ | std::cerr << "platexobj_book_createPage : can't save file '"<<fileName<<"' for object '" << obj.getName() << "'" << std::endl; | |
47 | ✗ | return false; | |
48 | }else{ | ||
49 | // std::cout << "platexobj_book_createPage : save file '"<<fileName<<"'" << std::endl; | ||
50 | 238 | return true; | |
51 | } | ||
52 | 238 | } | |
53 | |||
54 | ///Save the index.html file | ||
55 | /** @param[out] outputMode : output mode of the html backend | ||
56 | * @param obj : PLatexObj to be used | ||
57 | * @param isBibliography : true if there is a bibliography, false otherwise | ||
58 | */ | ||
59 | 11 | PString platexobj_bookIndexHtml(POutoutMode & outputMode, const PLatexObj & obj, bool isBibliography){ | |
60 |
1/1✓ Branch 1 taken 11 times.
|
11 | PString body(""); |
61 |
1/1✓ Branch 1 taken 11 times.
|
11 | const PVecLatexObj & vecObj = obj.getVecContent(); |
62 |
2/2✓ Branch 3 taken 333 times.
✓ Branch 4 taken 11 times.
|
344 | for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
63 |
2/2✓ Branch 2 taken 333 times.
✓ Branch 5 taken 333 times.
|
333 | body += platexobj_bookHtml(outputMode, *it, isBibliography, true); |
64 | } | ||
65 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | PString objTitle(obj.getName()); //Content of the section title |
66 |
5/5✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 13 taken 11 times.
|
22 | platexobj_theme_update_var(outputMode, obj.getLink(), objTitle, |
67 |
4/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
|
11 | obj.getPrevSec().getLink(), obj.getPrevSec().getText(), |
68 |
4/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
|
11 | obj.getNextSec().getLink(), obj.getNextSec().getText(), |
69 |
4/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
|
11 | obj.getParentSec().getLink(), obj.getParentSec().getText(), |
70 | obj.getSourceFile(), obj.getSourceLine()); | ||
71 |
1/1✓ Branch 1 taken 11 times.
|
11 | PString bodyTitle(""); |
72 |
5/5✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 13 taken 11 times.
|
11 | bodyTitle += platexobj_htmlMainTitle(obj.getName(), "h1", "mainTitle"); |
73 |
5/5✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 13 taken 11 times.
|
11 | bodyTitle += platexobj_htmlMainTitle(obj.getSubTitle(), "h2", "mainSubTitle"); |
74 |
5/5✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 13 taken 11 times.
|
11 | bodyTitle += platexobj_htmlMainTitle(obj.getAuthor(), "h5", "author"); |
75 |
5/5✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 13 taken 11 times.
|
11 | bodyTitle += platexobj_htmlMainTitle(obj.getDate(), "h6", "date"); |
76 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | outputMode.mapVar["${MAIN_TITLE}"] = bodyTitle; |
77 | // outputMode.mapVar["${SUB_MENU}"] = vecMenuToHtml(obj.getVecMenu()); | ||
78 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | outputMode.mapVar["${SUB_MENU}"] = ""; |
79 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | outputMode.mapVar["${PAGE_CONTENT}"] = body; |
80 |
1/1✓ Branch 1 taken 11 times.
|
22 | return platexobj_theme_createPage(outputMode); |
81 | 11 | } | |
82 | |||
83 | ///Convert a PLatexObj into a string with book theme | ||
84 | /** @param[out] outputMode : output mode of the html backend | ||
85 | * @param vecObj : vector of PLatexObj to be converted into a string | ||
86 | * @param isBibliography : true if there is a bibliography, false otherwise | ||
87 | * @param allowText : true if the TEXT PLatexObj are allowed, false if not | ||
88 | * @return output string which contains the PLatexObj | ||
89 | */ | ||
90 | 125 | PString platexobj_bookHtml(POutoutMode & outputMode, const std::vector<PLatexObj> & vecObj, bool isBibliography, bool allowText){ | |
91 | 125 | PString body(""); | |
92 |
2/2✓ Branch 3 taken 123 times.
✓ Branch 4 taken 125 times.
|
248 | for(std::vector<PLatexObj>::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
93 |
2/2✓ Branch 2 taken 123 times.
✓ Branch 5 taken 123 times.
|
123 | body += platexobj_bookHtml(outputMode, *it, isBibliography, allowText); |
94 | } | ||
95 | 125 | return body; | |
96 | } | ||
97 | |||
98 | ///Convert a PLatexObj into a string with book theme | ||
99 | /** @param[out] outputMode : output mode of the html backend | ||
100 | * @param obj : PLatexObj to be converted into a string | ||
101 | * @param isBibliography : true if there is a bibliography, false otherwise | ||
102 | * @param allowText : true if the TEXT PLatexObj are allowed, false if not | ||
103 | * @return output string which contains the PLatexObj | ||
104 | */ | ||
105 | 3300 | PString platexobj_bookHtml(POutoutMode & outputMode, const PLatexObj & obj, bool isBibliography, bool allowText){ | |
106 | 3300 | PString body(""); | |
107 |
1/1✓ Branch 1 taken 3300 times.
|
3300 | PLatexType::PLatexType type(obj.getType()); |
108 |
6/6✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3276 times.
✓ Branch 3 taken 24 times.
✓ Branch 6 taken 24 times.
✓ Branch 9 taken 24 times.
✓ Branch 12 taken 24 times.
|
3300 | if(type == PLatexType::PART){platexobj_book_createPage(outputMode, obj, "h1", "ptexpart", "Part", isBibliography);} |
109 |
6/6✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3246 times.
✓ Branch 3 taken 30 times.
✓ Branch 6 taken 30 times.
✓ Branch 9 taken 30 times.
✓ Branch 12 taken 30 times.
|
3276 | else if(type == PLatexType::CHAPTER){platexobj_book_createPage(outputMode, obj, "h2", "ptexchapter", "Chapter", isBibliography);} |
110 |
6/6✓ Branch 0 taken 66 times.
✓ Branch 1 taken 3180 times.
✓ Branch 3 taken 66 times.
✓ Branch 6 taken 66 times.
✓ Branch 9 taken 66 times.
✓ Branch 12 taken 66 times.
|
3246 | else if(type == PLatexType::SECTION){platexobj_book_createPage(outputMode, obj, "h3", "ptexsection", "", isBibliography);} |
111 |
6/6✓ Branch 0 taken 118 times.
✓ Branch 1 taken 3062 times.
✓ Branch 3 taken 118 times.
✓ Branch 6 taken 118 times.
✓ Branch 9 taken 118 times.
✓ Branch 12 taken 118 times.
|
3180 | else if(type == PLatexType::SUBSECTION){platexobj_book_createPage(outputMode, obj, "h4", "ptexsubsection", "", isBibliography);} |
112 |
1/10✗ Branch 0 not taken.
✓ Branch 1 taken 3062 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
3062 | else if(type == PLatexType::SUBSUBSECTION){platexobj_book_createPage(outputMode, obj, "h5", "ptexsubsubsection", "", isBibliography);} |
113 |
4/4✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3051 times.
✓ Branch 3 taken 11 times.
✓ Branch 6 taken 11 times.
|
3062 | else if(type == PLatexType::FILE){body = platexobj_bookIndexHtml(outputMode, obj, isBibliography);} |
114 |
3/3✓ Branch 1 taken 3051 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 2926 times.
|
3051 | else if(!platexobj_htmlStrBase(body, outputMode, obj, isBibliography, allowText)){ |
115 |
3/3✓ Branch 1 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 7 taken 125 times.
|
125 | body = platexobj_bookHtml(outputMode, obj.getVecContent(), isBibliography, allowText); |
116 | } | ||
117 | 3300 | return body; | |
118 | } | ||
119 | |||
120 | |||
121 | |||
122 |