Directory: | ./ |
---|---|
File: | tmp_project/PhoenixTex2Html/src/PLatexObj/platexobj_tex.cpp |
Date: | 2025-03-24 18:12:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 234 | 251 | 93.2% |
Branches: | 474 | 555 | 85.4% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #include <sys/stat.h> | ||
8 | #include <sys/types.h> | ||
9 | |||
10 | #include "convertToString.h" | ||
11 | #include "parser_utils.h" | ||
12 | |||
13 | #include "platexobj_tex.h" | ||
14 | |||
15 | ///Create a default POutputTex | ||
16 | /** @return default POutputTex | ||
17 | */ | ||
18 | 9 | POutputTex defaultPOutputTex(){ | |
19 | POutputTex out; | ||
20 | 9 | out.isLastObjInline = true; | |
21 | 9 | out.splitPart = false; | |
22 | 9 | out.splitChapter = false; | |
23 | 9 | out.splitSection = false; | |
24 | 9 | out.splitSubSection = false; | |
25 | 9 | out.splitSubSubSection = false; | |
26 | 9 | return out; | |
27 | } | ||
28 | |||
29 | ///Say if the given PLatexObj is inlined | ||
30 | /** @param obj : PLatexObj to be checked | ||
31 | * @return true if the given PLatexObj is inlined, false otherwise | ||
32 | */ | ||
33 | 1047 | bool isPLatexObjInline(const PLatexObj & obj){ | |
34 | 1047 | PLatexType::PLatexType type(obj.getType()); | |
35 |
6/6✓ Branch 0 taken 1043 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1031 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 1001 times.
✓ Branch 5 taken 30 times.
|
1044 | return type == PLatexType::CITATION || type == PLatexType::FOOTNOTE || type == PLatexType::HREF || |
36 |
4/4✓ Branch 0 taken 999 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 464 times.
|
1001 | type == PLatexType::INLINEMATH || type == PLatexType::REF || |
37 |
8/10✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 532 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 532 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 524 times.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 524 times.
|
2091 | type == PLatexType::TEXT || type == PLatexType::TEXTBF || type == PLatexType::TEXTIT || type == PLatexType::URL || |
38 | 1047 | type == PLatexType::VARCALL; | |
39 | } | ||
40 | |||
41 | ///Create the link to the label of the current PLatexObj if it exist | ||
42 | /** @param labelName : name of the label to be used | ||
43 | * @return tex link to search the label or empty string if there is no label | ||
44 | */ | ||
45 | 198 | PString platexobj_texCreateLabelSearchLink(const PString & labelName){ | |
46 |
3/3✓ Branch 1 taken 193 times.
✓ Branch 2 taken 5 times.
✓ Branch 4 taken 193 times.
|
198 | if(labelName == ""){return "";} |
47 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
10 | PString body("\\label{"+labelName+"}"); |
48 |
1/1✓ Branch 1 taken 5 times.
|
5 | return body; |
49 | 5 | } | |
50 | |||
51 | ///Convert a PLatexObj into a string | ||
52 | /** @param obj : PLatexObj to be converted into a string | ||
53 | * @return output string which contains the PLatexObj | ||
54 | */ | ||
55 | 464 | PString platexobj_texStrText(const PLatexObj & obj){ | |
56 |
1/1✓ Branch 3 taken 464 times.
|
464 | return obj.getText().eraseFirstLastChar("\t\n"); |
57 | } | ||
58 | |||
59 | ///Convert a PLatexObj into a string | ||
60 | /** @param obj : PLatexObj to be converted into a string | ||
61 | * @return output string which contains the PLatexObj | ||
62 | */ | ||
63 | 5 | PString platexobj_texStrComment(const PLatexObj & obj){ | |
64 |
1/1✓ Branch 3 taken 5 times.
|
5 | PString body("%" + obj.getName()); |
65 | 5 | return body; | |
66 | } | ||
67 | |||
68 | ///Convert a PLatexObj into a string | ||
69 | /** @param obj : PLatexObj to be converted into a string | ||
70 | * @return output string which contains the PLatexObj | ||
71 | */ | ||
72 | 8 | PString platexobj_texStrUrl(const PLatexObj & obj){ | |
73 |
2/2✓ Branch 3 taken 8 times.
✓ Branch 6 taken 8 times.
|
16 | PString body("\\url{" + obj.getName() + "}"); |
74 | 8 | return body; | |
75 | } | ||
76 | |||
77 | ///Convert a PLatexObj into a string | ||
78 | /** @param obj : PLatexObj to be converted into a string | ||
79 | * @return output string which contains the PLatexObj | ||
80 | */ | ||
81 | ✗ | PString platexobj_texStrGetenv(const PLatexObj & obj){ | |
82 | ✗ | PString body("\\getenv{" + obj.getName() + "}"); | |
83 | ✗ | return body; | |
84 | } | ||
85 | |||
86 | ///Convert a PLatexObj into a string | ||
87 | /** @param obj : PLatexObj to be converted into a string | ||
88 | * @return output string which contains the PLatexObj | ||
89 | */ | ||
90 | 2 | PString platexobj_texStrRef(const PLatexObj & obj){ | |
91 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
|
4 | PString body("\\ref{" + obj.getName() + "}"); |
92 | 2 | return body; | |
93 | } | ||
94 | |||
95 | ///Convert a PLatexObj into a string | ||
96 | /** @param obj : PLatexObj to be converted into a string | ||
97 | * @return output string which contains the PLatexObj | ||
98 | */ | ||
99 | ✗ | PString platexobj_texStrSpaceParagraph(const PLatexObj & obj){ | |
100 | ✗ | PString body("\\spaceparagraph{}\n"); | |
101 | ✗ | return body; | |
102 | } | ||
103 | |||
104 | ///Convert a PLatexObj into a string | ||
105 | /** @param obj : PLatexObj to be converted into a string | ||
106 | * @return output string which contains the PLatexObj | ||
107 | */ | ||
108 | 3 | PString platexobj_texStrCitation(const PLatexObj & obj){ | |
109 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
|
6 | PString body("\\cite{"+obj.getName()+"}"); |
110 | 3 | return body; | |
111 | } | ||
112 | |||
113 | ///Convert a PLatexObj into a string | ||
114 | /** @param obj : PLatexObj to be converted into a string | ||
115 | * @return output string which contains the PLatexObj | ||
116 | */ | ||
117 | 12 | PString platexobj_texStrHref(const PLatexObj & obj){ | |
118 |
4/4✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
|
24 | PString body("\\href{" + obj.getName() + "}{" + obj.getText() + "}"); |
119 | 12 | return body; | |
120 | } | ||
121 | |||
122 | ///Convert a PLatexObj into a string | ||
123 | /** @param obj : PLatexObj to be converted into a string | ||
124 | * @return output string which contains the PLatexObj | ||
125 | */ | ||
126 | 3 | PString platexobj_texStrTextBf(const PLatexObj & obj){ | |
127 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
|
6 | PString body("\\textbf{" + obj.getName() + "}"); |
128 | 3 | return body; | |
129 | } | ||
130 | |||
131 | ///Convert a PLatexObj into a string | ||
132 | /** @param obj : PLatexObj to be converted into a string | ||
133 | * @return output string which contains the PLatexObj | ||
134 | */ | ||
135 | ✗ | PString platexobj_texStrTextIt(const PLatexObj & obj){ | |
136 | ✗ | PString body("\\textit{" + obj.getName() + "}"); | |
137 | ✗ | return body; | |
138 | } | ||
139 | |||
140 | ///Convert a PLatexObj into a string | ||
141 | /** @param obj : PLatexObj to be converted into a string | ||
142 | * @return output string which contains the PLatexObj | ||
143 | */ | ||
144 | 1 | PString platexobj_texStrTextDebug(const PLatexObj & obj){ | |
145 |
2/2✓ Branch 3 taken 1 times.
✓ Branch 6 taken 1 times.
|
2 | PString body("\\debug{" + obj.getName() + "}"); |
146 | 1 | return body; | |
147 | } | ||
148 | |||
149 | ///Convert a PLatexObj into a string | ||
150 | /** @param[out] outputMode : output mode of the tex backend | ||
151 | * @param obj : PLatexObj to be converted into a string | ||
152 | * @return output string which contains the PLatexObj | ||
153 | */ | ||
154 | 1 | PString platexobj_texStrTextFootnote(POutputTex & outputMode, const PLatexObj & obj){ | |
155 | 1 | PString body("\\footnote{"); | |
156 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | body += platexobj_texStr(outputMode, obj.getVecContent(), ""); //Content of the footnote |
157 |
1/1✓ Branch 1 taken 1 times.
|
1 | body += "}"; |
158 | 1 | return body; | |
159 | } | ||
160 | |||
161 | ///Convert a PLatexObj into a string | ||
162 | /** @param[out] outputMode : output mode of the tex backend | ||
163 | * @param obj : PLatexObj to be converted into a string | ||
164 | * @return output string which contains the PLatexObj | ||
165 | */ | ||
166 | 3 | PString platexobj_texStrCaption(POutputTex & outputMode, const PLatexObj & obj){ | |
167 | 3 | PString body("\\caption{"); | |
168 |
5/5✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
|
3 | body += platexobj_texStr(outputMode, obj.getVecContent(), "") + "}\n"; |
169 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | body += platexobj_texCreateLabelSearchLink(obj.getLabelName()); |
170 | 3 | return body; | |
171 | } | ||
172 | |||
173 | ///Convert a PLatexObj into a string | ||
174 | /** @param[out] outputMode : output mode of the tex backend | ||
175 | * @param obj : PLatexObj to be converted into a string | ||
176 | * @return output string which contains the PLatexObj | ||
177 | */ | ||
178 | 2 | PString platexobj_texStrWip(POutputTex & outputMode, const PLatexObj & obj){ | |
179 | 2 | PString body("\\wip{"); | |
180 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | body += platexobj_texStr(outputMode, obj.getVecContent(), ""); |
181 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | body += platexobj_texCreateLabelSearchLink(obj.getLabelName()); |
182 |
1/1✓ Branch 1 taken 2 times.
|
2 | body += "}\n"; |
183 | 2 | return body; | |
184 | } | ||
185 | |||
186 | ///Convert a PLatexObj into a string | ||
187 | /** @param obj : PLatexObj to be converted into a string | ||
188 | * @return output string which contains the PLatexObj | ||
189 | */ | ||
190 | 8 | PString platexobj_texStrImage(const PLatexObj & obj){ | |
191 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | PString option(obj.getText()); |
192 |
1/1✓ Branch 1 taken 8 times.
|
8 | PString body("\\includegraphics"); |
193 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 6 times.
|
8 | if(option != ""){ |
194 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | body += "["+option+"]"; |
195 | } | ||
196 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
|
8 | body += "{" + obj.getName() + "}\n"; |
197 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
|
8 | body += platexobj_texCreateLabelSearchLink(obj.getLabelName()); |
198 | 16 | return body; | |
199 | 8 | } | |
200 | |||
201 | ///Convert a PLatexObj into a string | ||
202 | /** @param[out] outputMode : output mode of the tex backend | ||
203 | * @param obj : PLatexObj to be converted into a string | ||
204 | * @param latexFunction : name of the latex function to be used | ||
205 | * @param indentation : indentation of the section | ||
206 | * @return output string which contains the PLatexObj | ||
207 | */ | ||
208 | 15 | PString platexobj_texStrAllPart(POutputTex & outputMode, const PLatexObj & obj, const PString & latexFunction, const PString & indentation){ | |
209 |
1/1✓ Branch 2 taken 15 times.
|
15 | PString body("\n\n" + indentation); |
210 |
8/8✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
✓ Branch 13 taken 15 times.
✓ Branch 16 taken 15 times.
✓ Branch 19 taken 15 times.
✓ Branch 22 taken 15 times.
|
15 | body += "\\" + latexFunction + "{" + platexobj_texStr(outputMode, obj.getComplexTitle(), "") + "}\n\n"; |
211 |
3/3✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
|
15 | body += platexobj_texCreateLabelSearchLink(obj.getLabelName()); |
212 | 15 | return body; | |
213 | } | ||
214 | |||
215 | ///Convert a PLatexObj into a string | ||
216 | /** @param[out] outputMode : output mode of the tex backend | ||
217 | * @param obj : PLatexObj to be converted into a string | ||
218 | * @param indentation : text indentation | ||
219 | * @return output string which contains the PLatexObj | ||
220 | */ | ||
221 | 29 | PString platexobj_texStrExtraEnvironement(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation){ | |
222 |
3/3✓ Branch 3 taken 29 times.
✓ Branch 6 taken 29 times.
✓ Branch 9 taken 29 times.
|
58 | PString body(indentation + "\\begin{" + obj.getName() + "}\n"); |
223 |
5/5✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
✓ Branch 10 taken 29 times.
✓ Branch 13 taken 29 times.
|
29 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation + "\t"); |
224 |
5/5✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
✓ Branch 10 taken 29 times.
✓ Branch 13 taken 29 times.
|
29 | body += indentation + "\n\\end{" + obj.getName() + "}"; |
225 |
4/4✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
✓ Branch 10 taken 29 times.
|
29 | body += platexobj_texCreateLabelSearchLink(obj.getLabelName()) + "\n\n"; |
226 | 29 | return body; | |
227 | } | ||
228 | |||
229 | ///Convert a PLatexObj into a string | ||
230 | /** @param[out] outputMode : output mode of the tex backend | ||
231 | * @param obj : PLatexObj to be converted into a string | ||
232 | * @param indentation : text indentation | ||
233 | * @return output string which contains the PLatexObj | ||
234 | */ | ||
235 | 39 | PString platexobj_texStrExtraFunction(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation){ | |
236 |
2/2✓ Branch 3 taken 39 times.
✓ Branch 6 taken 39 times.
|
78 | PString body("\\" + obj.getName() + "{"); |
237 |
7/7✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 7 taken 39 times.
✓ Branch 10 taken 39 times.
✓ Branch 13 taken 39 times.
✓ Branch 16 taken 39 times.
✓ Branch 19 taken 39 times.
|
39 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation) + "}" + platexobj_texCreateLabelSearchLink(obj.getLabelName()); |
238 | 39 | return body; | |
239 | } | ||
240 | |||
241 | ///Convert a PLatexObj into a string | ||
242 | /** @param obj : PLatexObj to be converted into a string | ||
243 | * @return output string which contains the PLatexObj | ||
244 | */ | ||
245 | 15 | PString platexobj_texStrExtraParser(const PLatexObj & obj){ | |
246 |
2/2✓ Branch 3 taken 15 times.
✓ Branch 6 taken 15 times.
|
30 | PString body("\\begin{"+obj.getName()+"}\n"); |
247 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | body += obj.getSubTitle(); |
248 |
4/4✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
|
15 | body += "\\end{"+obj.getName()+"}"; |
249 |
4/4✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
|
15 | body += platexobj_texCreateLabelSearchLink(obj.getLabelName())+"\n"; |
250 | 15 | return body; | |
251 | } | ||
252 | |||
253 | ///Convert a basic environement into a string | ||
254 | /** @param[out] outputMode : output mode of the tex backend | ||
255 | * @param obj : PLatexObj to be converted in tex | ||
256 | * @param baliseName : name of the balise environement | ||
257 | * @param indentation : text indentation | ||
258 | * @param allowText : true if the TEXT PLatexObj are allowed, false if not | ||
259 | * @return tex string | ||
260 | */ | ||
261 | ✗ | PString platexobj_texStrBasicEnv(POutputTex & outputMode, const PLatexObj & obj, const PString & baliseName, const PString & indentation, bool allowText){ | |
262 | ✗ | PString body("\\begin{"+baliseName+"}\n"); | |
263 | ✗ | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation, allowText); | |
264 | ✗ | body += "\\end{"+baliseName+"}"; | |
265 | ✗ | body += platexobj_texCreateLabelSearchLink(obj.getLabelName()) + "\n"; | |
266 | ✗ | return body; | |
267 | } | ||
268 | |||
269 | ///Convert a tabular into a tex string | ||
270 | /** @param[out] outputMode : output mode of the tex backend | ||
271 | * @param obj : PLatexObj to be converted in tex | ||
272 | * @param indentation : text indentation | ||
273 | * @return tex string | ||
274 | */ | ||
275 | 1 | PString platexobj_texStrTabular(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation){ | |
276 | 1 | PString body("\\begin{tabular}\n"); | |
277 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation); |
278 |
5/5✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | body += "\\end{tabular}" + platexobj_texCreateLabelSearchLink(obj.getLabelName())+"\n"; |
279 | 1 | return body; | |
280 | } | ||
281 | |||
282 | ///Convert a row into a tex string | ||
283 | /** @param[out] outputMode : output mode of the tex backend | ||
284 | * @param obj : PLatexObj to be converted in tex | ||
285 | * @param indentation : text indentation | ||
286 | * @return tex string | ||
287 | */ | ||
288 | 10 | PString platexobj_texStrTabRow(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation){ | |
289 | 10 | PString body(""); | |
290 |
3/3✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
|
10 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation); |
291 |
1/1✓ Branch 1 taken 10 times.
|
10 | body += "\\\\\n"; |
292 | 10 | return body; | |
293 | } | ||
294 | |||
295 | ///Convert a cell into a tex string | ||
296 | /** @param[out] outputMode : output mode of the tex backend | ||
297 | * @param obj : PLatexObj to be converted in tex | ||
298 | * @param indentation : text indentation | ||
299 | * @return tex string | ||
300 | */ | ||
301 | 50 | PString platexobj_texStrTabCell(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation){ | |
302 | 50 | PString body(""); | |
303 |
3/3✓ Branch 1 taken 50 times.
✓ Branch 4 taken 50 times.
✓ Branch 7 taken 50 times.
|
50 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation); |
304 |
1/1✓ Branch 1 taken 50 times.
|
50 | body += "\t&\t"; |
305 | 50 | return body; | |
306 | } | ||
307 | |||
308 | ///Convert an environement into a tex string | ||
309 | /** @param[out] outputMode : output mode of the tex backend | ||
310 | * @param obj : PLatexObj to be converted in tex | ||
311 | * @param envName : name of the environement to bo used | ||
312 | * @param indentation : text indentation | ||
313 | * @return tex string | ||
314 | */ | ||
315 | 15 | PString platexobj_texStrBasicEnv(POutputTex & outputMode, const PLatexObj & obj, const PString & envName, const PString & indentation){ | |
316 |
3/3✓ Branch 2 taken 15 times.
✓ Branch 5 taken 15 times.
✓ Branch 8 taken 15 times.
|
30 | PString body(indentation + "\\begin{"+envName+"}\n"); |
317 |
5/5✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
✓ Branch 13 taken 15 times.
|
15 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation + "\t"); |
318 |
9/9✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
✓ Branch 13 taken 15 times.
✓ Branch 16 taken 15 times.
✓ Branch 19 taken 15 times.
✓ Branch 22 taken 15 times.
✓ Branch 25 taken 15 times.
|
15 | body += "\n" + indentation + "\\end{"+envName+"}" + platexobj_texCreateLabelSearchLink(obj.getLabelName())+"\n"; |
319 | 15 | return body; | |
320 | } | ||
321 | |||
322 | ///Convert a PLatexObj into a string | ||
323 | /** @param[out] outputMode : output mode of the tex backend | ||
324 | * @param obj : PLatexObj to be converted into a string | ||
325 | * @param indentation : text indentation | ||
326 | * @return output string which contains the PLatexObj | ||
327 | */ | ||
328 | 1 | PString platexobj_texStrColumns(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation){ | |
329 |
1/1✓ Branch 2 taken 1 times.
|
1 | PString body(indentation + "\\begin{columns}\n"); |
330 |
5/5✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation + "\t"); |
331 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | body += indentation + "\\end{columns}\n"; |
332 | 1 | return body; | |
333 | } | ||
334 | |||
335 | ///Save a section in tex | ||
336 | /** @param[out] outputMode : output mode of the tex backend | ||
337 | * @param obj : PLatexObj to be saved | ||
338 | * @param latexFunction : latex function to be used | ||
339 | * @return output string which contains the PLatexObj | ||
340 | */ | ||
341 | 31 | PString platexobj_texStrSection(POutputTex & outputMode, const PLatexObj & obj, const PString & latexFunction){ | |
342 |
2/2✓ Branch 2 taken 31 times.
✓ Branch 5 taken 31 times.
|
62 | PString body("\n\n\\" + latexFunction + "{"); |
343 |
1/1✓ Branch 1 taken 31 times.
|
31 | const PVecLatexObj & vecObj = obj.getComplexTitle(); |
344 |
2/2✓ Branch 3 taken 33 times.
✓ Branch 4 taken 31 times.
|
64 | for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
345 |
3/3✓ Branch 1 taken 33 times.
✓ Branch 5 taken 33 times.
✓ Branch 8 taken 33 times.
|
33 | body += platexobj_texStr(outputMode, *it, ""); |
346 | } | ||
347 |
5/5✓ Branch 1 taken 31 times.
✓ Branch 4 taken 31 times.
✓ Branch 7 taken 31 times.
✓ Branch 10 taken 31 times.
✓ Branch 13 taken 31 times.
|
31 | body += "}" + platexobj_texCreateLabelSearchLink(obj.getLabelName()) + "\n\n"; |
348 | |||
349 |
4/4✓ Branch 1 taken 31 times.
✓ Branch 4 taken 31 times.
✓ Branch 7 taken 31 times.
✓ Branch 10 taken 31 times.
|
31 | body += platexobj_texStr(outputMode, obj.getVecContent(), ""); |
350 | |||
351 | // PString fileName(obj.getLink()); | ||
352 | // if(!saveFileContent(fileName, body)){ | ||
353 | // cerr << "platexobj_texStrSection : can't save file '"<<fileName<<"' for object '" << obj.getName() << "'" << endl; | ||
354 | // }else{ | ||
355 | // cout << "platexobj_texStrSection : save file '"<<fileName<<"'" << endl; | ||
356 | // } | ||
357 | 31 | return body; | |
358 | } | ||
359 | |||
360 | ///Convert a PLatexObj into a string | ||
361 | /** @param title : title name | ||
362 | * @param latexFunction : name of the latex function to be used | ||
363 | * @return output string which contains the PLatexObj | ||
364 | */ | ||
365 | 36 | PString platexobj_texMainTitle(const PString & title, const PString & latexFunction){ | |
366 |
3/3✓ Branch 1 taken 17 times.
✓ Branch 2 taken 19 times.
✓ Branch 4 taken 17 times.
|
36 | if(title == ""){return "";} |
367 |
5/5✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
✓ Branch 10 taken 19 times.
✓ Branch 13 taken 19 times.
|
38 | PString body("\\" + latexFunction + "{"+title+"}\n"); |
368 |
1/1✓ Branch 1 taken 19 times.
|
19 | return body; |
369 | 19 | } | |
370 | |||
371 | ///Save the index.tex file | ||
372 | /** @param[out] outputMode : output mode of the tex backend | ||
373 | * @param obj : PLatexObj to be used | ||
374 | * @param isBibliography : true if there is a bibliography, false otherwise | ||
375 | */ | ||
376 | 9 | PString platexobj_indexTex(POutputTex & outputMode, const PLatexObj & obj){ | |
377 | 9 | PString body(""); | |
378 |
4/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
|
9 | body += platexobj_texMainTitle(obj.getName(), "title"); |
379 |
4/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
|
9 | body += platexobj_texMainTitle(obj.getSubTitle(), "subtitle"); |
380 |
4/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
|
9 | body += platexobj_texMainTitle(obj.getAuthor(), "author"); |
381 |
4/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
|
9 | body += platexobj_texMainTitle(obj.getDate(), "date"); |
382 | |||
383 |
1/1✓ Branch 1 taken 9 times.
|
9 | const PVecLatexObj & vecObj = obj.getVecContent(); |
384 |
2/2✓ Branch 3 taken 324 times.
✓ Branch 4 taken 9 times.
|
333 | for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
385 |
3/3✓ Branch 1 taken 324 times.
✓ Branch 5 taken 324 times.
✓ Branch 8 taken 324 times.
|
324 | body += platexobj_texStr(outputMode, *it, "", true); |
386 | } | ||
387 | 9 | return body; | |
388 | } | ||
389 | |||
390 | ///convert fomulae env into latex | ||
391 | /** @param[out] outputMode : output mode of the tex backend | ||
392 | * @param obj : PLatexObj to be converted | ||
393 | * @param latexEnvName : name of the latex env to be used | ||
394 | */ | ||
395 | 10 | PString platexobj_texStrMathEnv(POutputTex & outputMode, const PLatexObj & obj, const PString & latexEnvName){ | |
396 |
2/2✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
|
20 | PString body("\\begin{"+latexEnvName+"}\n"); |
397 |
2/2✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
|
10 | body += obj.getText(); |
398 |
7/7✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 13 taken 10 times.
✓ Branch 16 taken 10 times.
✓ Branch 19 taken 10 times.
|
10 | body += "\\end{"+latexEnvName+"}" + platexobj_texCreateLabelSearchLink(obj.getLabelName()) + "\n"; |
399 | 10 | return body; | |
400 | } | ||
401 | |||
402 | ///convert inline fomulae into latex | ||
403 | /** @param[out] outputMode : output mode of the tex backend | ||
404 | * @param obj : PLatexObj to be converted | ||
405 | */ | ||
406 | 30 | PString platexobj_texStrInlineMath(POutputTex & outputMode, const PLatexObj & obj){ | |
407 | 30 | PString body("$"); | |
408 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
|
30 | body += obj.getText(); |
409 |
5/5✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
✓ Branch 10 taken 30 times.
✓ Branch 13 taken 30 times.
|
30 | body += "$" + platexobj_texCreateLabelSearchLink(obj.getLabelName()) + "\n"; |
410 | 30 | return body; | |
411 | } | ||
412 | |||
413 | ///Convert an itemize environement in tex | ||
414 | /** @param[out] outputMode : output mode of the tex backend | ||
415 | * @param obj : PLatexObj to be converted | ||
416 | * @param indentation : text indentation | ||
417 | * @return tex string | ||
418 | */ | ||
419 | 14 | PString platexobj_texStrItemize(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation){ | |
420 |
1/1✓ Branch 2 taken 14 times.
|
14 | PString body(indentation + "\\begin{itemize}\n"); |
421 |
5/5✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
✓ Branch 10 taken 14 times.
✓ Branch 13 taken 14 times.
|
14 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation + "\t"); |
422 |
2/2✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
|
14 | body += indentation + "\\end{itemize}\n"; |
423 | 14 | return body; | |
424 | } | ||
425 | |||
426 | ///Convert an itemize environement in tex | ||
427 | /** @param[out] outputMode : output mode of the tex backend | ||
428 | * @param obj : PLatexObj to be converted | ||
429 | * @param indentation : text indentation | ||
430 | * @return tex string | ||
431 | */ | ||
432 | 4 | PString platexobj_texStrEnumerate(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation){ | |
433 |
1/1✓ Branch 2 taken 4 times.
|
4 | PString body(indentation + "\\begin{enumerate}\n"); |
434 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
|
4 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation + "\t"); |
435 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | body += indentation + "\\end{enumerate}\n"; |
436 | 4 | return body; | |
437 | } | ||
438 | |||
439 | ///Convert an itemize environement in tex | ||
440 | /** @param[out] outputMode : output mode of the tex backend | ||
441 | * @param obj : PLatexObj to be converted | ||
442 | * @param indentation : text indentation | ||
443 | * @return tex string | ||
444 | */ | ||
445 | 34 | PString platexobj_texStrItem(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation){ | |
446 | 34 | PString body(indentation); | |
447 |
1/1✓ Branch 1 taken 34 times.
|
34 | body += "\\item "; |
448 |
4/4✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
✓ Branch 7 taken 34 times.
✓ Branch 10 taken 34 times.
|
34 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation) + "\n"; |
449 | 34 | return body; | |
450 | } | ||
451 | |||
452 | ///Convert a video call in tex | ||
453 | /** @param obj : PLatexObj to be converted | ||
454 | * @return tex string | ||
455 | */ | ||
456 | 2 | PString platexobj_texStrVideo(const PLatexObj & obj){ | |
457 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | PString body("\\video"), fileName(obj.getName()); |
458 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | if(obj.getText() != ""){ |
459 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | body += "[" + obj.getText() + "]"; |
460 | } | ||
461 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | body += "{" + fileName + "}\n"; |
462 | 4 | return body; | |
463 | 2 | } | |
464 | |||
465 | ///Convert a PLatexObj into a string | ||
466 | /** @param[out] outputMode : output mode of the tex backend | ||
467 | * @param obj : PLatexObj to be converted into a string | ||
468 | * @param allowText : true if the TEXT PLatexObj are allowed, false if not | ||
469 | * @param indentation : indentation of the text | ||
470 | * @return output string which contains the PLatexObj | ||
471 | */ | ||
472 | 1047 | PString platexobj_texStr(POutputTex & outputMode, const PLatexObj & obj, const PString & indentation, bool allowText){ | |
473 | 1047 | PString body(""); | |
474 |
1/1✓ Branch 1 taken 1047 times.
|
1047 | bool isCurrentObjInlined(isPLatexObjInline(obj)); |
475 | // if(isCurrentObjInlined != outputMode.isLastObjInline){ | ||
476 | // body += "\n"; | ||
477 | // } | ||
478 | 1047 | outputMode.isLastObjInline = isCurrentObjInlined; | |
479 | |||
480 |
1/1✓ Branch 1 taken 1047 times.
|
1047 | PLatexType::PLatexType type(obj.getType()); |
481 |
5/6✓ Branch 0 taken 464 times.
✓ Branch 1 taken 583 times.
✓ Branch 2 taken 464 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 464 times.
✓ Branch 8 taken 464 times.
|
1047 | if(type == PLatexType::TEXT && allowText){body += platexobj_texStrText(obj);} |
482 |
4/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 578 times.
✓ Branch 3 taken 5 times.
✓ Branch 6 taken 5 times.
|
583 | else if(type == PLatexType::COMMENT){body += platexobj_texStrComment(obj);} |
483 |
3/3✓ Branch 0 taken 3 times.
✓ Branch 1 taken 575 times.
✓ Branch 3 taken 3 times.
|
578 | else if(type == PLatexType::PERCENT){body += "\\%";} |
484 |
4/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 567 times.
✓ Branch 3 taken 8 times.
✓ Branch 6 taken 8 times.
|
575 | else if(type == PLatexType::URL){body += platexobj_texStrUrl(obj);} |
485 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 567 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
567 | else if(type == PLatexType::GETENV){body += platexobj_texStrGetenv(obj);} |
486 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 565 times.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
|
567 | else if(type == PLatexType::REF){body += platexobj_texStrRef(obj);} |
487 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
565 | else if(type == PLatexType::SPACEPARAGRAPH){body += platexobj_texStrSpaceParagraph(obj);} |
488 |
3/3✓ Branch 0 taken 220 times.
✓ Branch 1 taken 345 times.
✓ Branch 3 taken 220 times.
|
565 | else if(type == PLatexType::AUTOSPACEPARAGRAPH){body += "\n\n";} |
489 |
4/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 342 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
|
345 | else if(type == PLatexType::CITATION){body += platexobj_texStrCitation(obj);} |
490 | |||
491 |
4/4✓ Branch 0 taken 12 times.
✓ Branch 1 taken 330 times.
✓ Branch 3 taken 12 times.
✓ Branch 6 taken 12 times.
|
342 | else if(type == PLatexType::HREF){body += platexobj_texStrHref(obj);} |
492 |
4/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 327 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
|
330 | else if(type == PLatexType::TEXTBF){body += platexobj_texStrTextBf(obj);} |
493 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
327 | else if(type == PLatexType::TEXTIT){body += platexobj_texStrTextIt(obj);} |
494 |
4/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 1 times.
|
327 | else if(type == PLatexType::DEBUG){body += platexobj_texStrTextDebug(obj);} |
495 |
4/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 325 times.
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 1 times.
|
326 | else if(type == PLatexType::FOOTNOTE){body += platexobj_texStrTextFootnote(outputMode, obj);} |
496 |
4/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 322 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
|
325 | else if(type == PLatexType::CAPTION){body += platexobj_texStrCaption(outputMode, obj);} |
497 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 320 times.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
|
322 | else if(type == PLatexType::WORK_IN_PROGRESS){body += platexobj_texStrWip(outputMode, obj);} |
498 | |||
499 |
4/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 312 times.
✓ Branch 3 taken 8 times.
✓ Branch 6 taken 8 times.
|
320 | else if(type == PLatexType::IMAGE){body += platexobj_texStrImage(obj);} |
500 | |||
501 |
6/6✓ Branch 0 taken 3 times.
✓ Branch 1 taken 309 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 12 taken 3 times.
|
312 | else if(type == PLatexType::PARTSTAR){body += platexobj_texStrAllPart(outputMode, obj, "part*", "");} |
502 |
6/6✓ Branch 0 taken 3 times.
✓ Branch 1 taken 306 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 12 taken 3 times.
|
309 | else if(type == PLatexType::CHAPTERSTAR){body += platexobj_texStrAllPart(outputMode, obj, "chapter*", "\t");} |
503 |
6/6✓ Branch 0 taken 3 times.
✓ Branch 1 taken 303 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 12 taken 3 times.
|
306 | else if(type == PLatexType::SECTIONSTAR){body += platexobj_texStrAllPart(outputMode, obj, "section*", "\t\t");} |
504 |
6/6✓ Branch 0 taken 3 times.
✓ Branch 1 taken 300 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 12 taken 3 times.
|
303 | else if(type == PLatexType::SUBSECTIONSTAR){body += platexobj_texStrAllPart(outputMode, obj, "subsection*", "\t\t\t");} |
505 |
6/6✓ Branch 0 taken 3 times.
✓ Branch 1 taken 297 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 12 taken 3 times.
|
300 | else if(type == PLatexType::SUBSUBSECTIONSTAR){body += platexobj_texStrAllPart(outputMode, obj, "subsubsection*", "\t\t\t\t");} |
506 | |||
507 |
5/5✓ Branch 0 taken 12 times.
✓ Branch 1 taken 285 times.
✓ Branch 3 taken 12 times.
✓ Branch 6 taken 12 times.
✓ Branch 9 taken 12 times.
|
297 | else if(type == PLatexType::PART){body += platexobj_texStrSection(outputMode, obj, "part");} |
508 |
5/5✓ Branch 0 taken 8 times.
✓ Branch 1 taken 277 times.
✓ Branch 3 taken 8 times.
✓ Branch 6 taken 8 times.
✓ Branch 9 taken 8 times.
|
285 | else if(type == PLatexType::CHAPTER){body += platexobj_texStrSection(outputMode, obj, "chapter");} |
509 |
5/5✓ Branch 0 taken 6 times.
✓ Branch 1 taken 271 times.
✓ Branch 3 taken 6 times.
✓ Branch 6 taken 6 times.
✓ Branch 9 taken 6 times.
|
277 | else if(type == PLatexType::SECTION){body += platexobj_texStrSection(outputMode, obj, "section");} |
510 |
5/5✓ Branch 0 taken 3 times.
✓ Branch 1 taken 268 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 9 taken 3 times.
|
271 | else if(type == PLatexType::SUBSECTION){body += platexobj_texStrSection(outputMode, obj, "subsection");} |
511 |
5/5✓ Branch 0 taken 2 times.
✓ Branch 1 taken 266 times.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 9 taken 2 times.
|
268 | else if(type == PLatexType::SUBSUBSECTION){body += platexobj_texStrSection(outputMode, obj, "subsubsection");} |
512 | |||
513 | |||
514 |
1/8✗ Branch 0 not taken.
✓ Branch 1 taken 266 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.
|
266 | else if(type == PLatexType::PARAGRAPHE){body += platexobj_texStrBasicEnv(outputMode, obj, "paragraph", indentation);} |
515 |
5/5✓ Branch 0 taken 7 times.
✓ Branch 1 taken 259 times.
✓ Branch 3 taken 7 times.
✓ Branch 6 taken 7 times.
✓ Branch 9 taken 7 times.
|
266 | else if(type == PLatexType::CENTER){body += platexobj_texStrBasicEnv(outputMode, obj, "center", indentation);} |
516 |
5/5✓ Branch 0 taken 2 times.
✓ Branch 1 taken 257 times.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 9 taken 2 times.
|
259 | else if(type == PLatexType::COLUMN){body += platexobj_texStrBasicEnv(outputMode, obj, "column", indentation);} |
517 | |||
518 |
4/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 256 times.
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 1 times.
|
257 | else if(type == PLatexType::COLUMNS){body += platexobj_texStrColumns(outputMode, obj, indentation);} |
519 | |||
520 |
1/8✗ Branch 0 not taken.
✓ Branch 1 taken 256 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.
|
256 | else if(type == PLatexType::TABLE){body += platexobj_texStrBasicEnv(outputMode, obj, "table", indentation);} |
521 |
4/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 255 times.
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 1 times.
|
256 | else if(type == PLatexType::TABULAR){body += platexobj_texStrTabular(outputMode, obj, indentation);} |
522 |
4/4✓ Branch 0 taken 10 times.
✓ Branch 1 taken 245 times.
✓ Branch 3 taken 10 times.
✓ Branch 6 taken 10 times.
|
255 | else if(type == PLatexType::TABROW){body += platexobj_texStrTabRow(outputMode, obj, indentation);} |
523 |
4/4✓ Branch 0 taken 50 times.
✓ Branch 1 taken 195 times.
✓ Branch 3 taken 50 times.
✓ Branch 6 taken 50 times.
|
245 | else if(type == PLatexType::TABCELL){body += platexobj_texStrTabCell(outputMode, obj, indentation);} |
524 |
5/5✓ Branch 0 taken 6 times.
✓ Branch 1 taken 189 times.
✓ Branch 3 taken 6 times.
✓ Branch 6 taken 6 times.
✓ Branch 9 taken 6 times.
|
195 | else if(type == PLatexType::FIGURE){body += platexobj_texStrBasicEnv(outputMode, obj, "figure", indentation);} |
525 | |||
526 |
1/8✗ Branch 0 not taken.
✓ Branch 1 taken 189 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.
|
189 | else if(type == PLatexType::DISPLAYMATH){body += platexobj_texStrMathEnv(outputMode, obj, "displaymath");} |
527 |
5/5✓ Branch 0 taken 10 times.
✓ Branch 1 taken 179 times.
✓ Branch 3 taken 10 times.
✓ Branch 6 taken 10 times.
✓ Branch 9 taken 10 times.
|
189 | else if(type == PLatexType::EQNARRAY){body += platexobj_texStrMathEnv(outputMode, obj, "eqnarray*");} |
528 |
4/4✓ Branch 0 taken 30 times.
✓ Branch 1 taken 149 times.
✓ Branch 3 taken 30 times.
✓ Branch 6 taken 30 times.
|
179 | else if(type == PLatexType::INLINEMATH){body += platexobj_texStrInlineMath(outputMode, obj);} |
529 | |||
530 |
4/4✓ Branch 0 taken 14 times.
✓ Branch 1 taken 135 times.
✓ Branch 3 taken 14 times.
✓ Branch 6 taken 14 times.
|
149 | else if(type == PLatexType::ITEMIZE){body += platexobj_texStrItemize(outputMode, obj, indentation);} |
531 |
4/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 131 times.
✓ Branch 3 taken 4 times.
✓ Branch 6 taken 4 times.
|
135 | else if(type == PLatexType::ENUMERATE){body += platexobj_texStrEnumerate(outputMode, obj, indentation);} |
532 |
4/4✓ Branch 0 taken 34 times.
✓ Branch 1 taken 97 times.
✓ Branch 3 taken 34 times.
✓ Branch 6 taken 34 times.
|
131 | else if(type == PLatexType::ITEM){body += platexobj_texStrItem(outputMode, obj, indentation);} |
533 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 95 times.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
|
97 | else if(type == PLatexType::VIDEO){body += platexobj_texStrVideo(obj);} |
534 | |||
535 |
4/4✓ Branch 0 taken 29 times.
✓ Branch 1 taken 66 times.
✓ Branch 3 taken 29 times.
✓ Branch 6 taken 29 times.
|
95 | else if(type == PLatexType::ENVIRONEMENT){body += platexobj_texStrExtraEnvironement(outputMode, obj, indentation);} |
536 |
4/4✓ Branch 0 taken 39 times.
✓ Branch 1 taken 27 times.
✓ Branch 3 taken 39 times.
✓ Branch 6 taken 39 times.
|
66 | else if(type == PLatexType::FUNCTION){body += platexobj_texStrExtraFunction(outputMode, obj, indentation);} |
537 |
4/4✓ Branch 0 taken 15 times.
✓ Branch 1 taken 12 times.
✓ Branch 3 taken 15 times.
✓ Branch 6 taken 15 times.
|
27 | else if(type == PLatexType::PARSER){body += platexobj_texStrExtraParser(obj);} |
538 | |||
539 |
4/4✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 9 times.
✓ Branch 6 taken 9 times.
|
12 | else if(type == PLatexType::FILE){body += platexobj_indexTex(outputMode, obj);} |
540 | else{ | ||
541 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | body += platexobj_texStr(outputMode, obj.getVecContent(), indentation, allowText); |
542 | } | ||
543 | 1047 | return body; | |
544 | } | ||
545 | |||
546 | ///Save a vector of PLatexObj in tex | ||
547 | /** @param[out] outputMode : output mode of the tex backend | ||
548 | * @param vecObj : vector of PLatexObj to be saved in tex | ||
549 | * @param allowText : true if the TEXT PLatexObj are allowed, false if not | ||
550 | * @param indentation : indentation of the text | ||
551 | * @return tex string | ||
552 | */ | ||
553 | 252 | PString platexobj_texStr(POutputTex & outputMode, const PVecLatexObj & vecObj, const PString & indentation, bool allowText){ | |
554 | 252 | PString body(""); | |
555 |
2/2✓ Branch 3 taken 681 times.
✓ Branch 4 taken 252 times.
|
933 | for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
556 |
2/2✓ Branch 2 taken 681 times.
✓ Branch 5 taken 681 times.
|
681 | body += platexobj_texStr(outputMode, *it, indentation, allowText); |
557 | } | ||
558 | 252 | return body; | |
559 | } | ||
560 | |||
561 | ///Save the main PLatexObj | ||
562 | /** @param[out] outputMode : output mode of the tex backend | ||
563 | * @param obj : main PLatexObj to be saved | ||
564 | * @return true on success, false otherwise | ||
565 | */ | ||
566 | 9 | bool platexobj_tex(POutputTex & outputMode, const PLatexObj & obj){ | |
567 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | PString fileContent(platexobj_texStr(outputMode, obj, "")); |
568 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | PPath indexTex(obj.getLink()); |
569 |
2/3✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
|
9 | if(!indexTex.saveFileContent(fileContent)){ |
570 | ✗ | std::cerr << "platexobj_tex : can't save file '"<<indexTex<<"'" << std::endl; | |
571 | ✗ | return false; | |
572 | }else{ | ||
573 |
4/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
|
9 | std::cerr << "platexobj_tex : save file '"<<indexTex<<"'" << std::endl; |
574 | } | ||
575 | 9 | return true; | |
576 | 9 | } | |
577 | |||
578 |