4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
12 #ifndef OUTPUTPARAMS_H
13 #define OUTPUTPARAMS_H
32 enum class Flavor : int {
44 enum class CtObject : int {
75 OutputParams(Encoding const *);
78 /** The file that we export depends occasionally on what is to
81 Flavor flavor = Flavor::LaTeX;
82 /// is it some flavor of LaTeX?
84 /// does this flavour support full unicode?
85 bool isFullUnicode() const;
87 /// Same, but for math output, which only matter is XHTML output.
88 MathFlavor math_flavor = NotApplicable;
90 /** Are we to write a 'nice' LaTeX file or not.
91 This essentially seems to mean whether InsetInclude, InsetGraphics
92 and InsetExternal should add the absolute path to any external
94 Non-nice LaTeX also includes additional safe line breaks in order to
95 increase the precision of forward/reverse search and error reporting.
99 /** Is this a real child (i.e., compiled as a child)?
100 This depends on wherefrom we export the buffer. Even children
101 that have a master can be compiled standalone.
103 mutable bool is_child = false;
105 /** moving_arg == true means that the environment in which the inset
106 is typeset is a moving argument. The inset should take care about
107 fragile commands by preceding the latex with \\protect.
109 bool moving_arg = false;
111 /** no_cprotect == true means that the layout in which this is
112 * does not allow \cprotect'ing.
114 bool no_cprotect = false;
116 /** intitle == true means that the environment in which the
117 inset is typeset is part of a title (before a \\maketitle).
118 Footnotes in such environments have moving arguments.
120 bool intitle = false;
122 /** need_maketitle == true means that the last layout was a title layout
123 * this is to track when \maketitle needs to be output.
125 mutable bool need_maketitle = false;
127 /** have_maketitle == true means that \maketitle already has been output.
129 mutable bool have_maketitle = false;
131 /** inbranch == true means that the environment being typeset
132 is inside an active branch inset.
134 bool inbranch = false;
136 /** inulemcmd > 0 means that the environment in which the
137 inset is typeset is part of a ulem or soul command (e.g., \uline,
138 \uuline, \uwave, \sout or \xout). Insets that output latex commands
139 relying on local assignments (such as \cite) should enclose such
140 commands in \mbox{} in order to avoid breakage.
142 mutable int inulemcmd = 0;
144 /** the font at the point where the inset is
146 * Note from lasgouttes: I have doubts on the semantics of this
147 * variable. Until this is sorted out, here are some notes on the
148 * history of local_font.
150 * A research that excludes test and assignment [*] shows that
151 * this is only used to remember language, which is a different
152 * story (and not changed by this patch). The only exception being
153 * in InsetMathHull::getCtObject and InsetMathNest::latex to
154 * support change tracking in insets, but I am not 100% sure that
155 * this is required. And historically [**] local_font used to be
156 * local_lang; it may be good to return to this simpler variable
159 * [*] git grep local_font src|grep -v 'local_font [!=]*='
161 * [**] before afed118a, which improved support for InsetLine;
162 * however, since 0e7ab29f, InsetLine does not depend on the
163 * current font anymore.
165 Font const * local_font = nullptr;
167 /** Document language lyx name
169 std::string document_language;
171 /// main font encoding of the document
172 std::string main_fontenc;
174 /** The master language. Non-null only for child documents.
175 Note that this is not the language of the top level master, but
176 of the direct parent for nested includes.
178 mutable Language const * master_language = nullptr;
180 /// Active characters
181 std::string active_chars;
183 /** Current stream encoding. Only used for LaTeX.
184 This must be set to the document encoding (via the constructor)
185 before output starts. Afterwards it must be kept up to date for
186 each single character (\sa Paragraph::latex).
187 This does also mean that you need to set it back if you use a
188 copy (e.g. in insets): \code
189 int InsetFoo::latex(..., OutputParams const & runparams_in) const
191 OutputParams runparams(runparams_in);
192 runparams.inComment = true;
194 InsetBla::latex(..., runparams);
196 runparams_in.encoding = runparams.encoding;
200 mutable Encoding const * encoding;
202 /** free_spacing == true means that the inset is in a free-spacing
205 bool free_spacing = false;
207 /** This var is set by the return value from BufferParams::writeLaTeX
209 bool use_babel = false;
211 /** Do we use polyglossia (instead of babel)?
213 bool use_polyglossia = false;
215 /** Do we use hyperref?
217 bool use_hyperref = false;
219 /// Do we use the CJK package?
220 bool use_CJK = false;
222 /** Are we generating multiple indices?
224 bool use_indices = false;
226 /** Are we using japanese (pLaTeX)?
228 bool use_japanese = false;
230 /** Customized bibtex_command
232 std::string bibtex_command;
234 /** Customized index_command
236 std::string index_command;
240 std::string hyperref_driver;
242 /** Line length to use with plaintext or LaTeX export.
244 size_type linelen = 0;
246 /** The depth of the current paragraph, set for plaintext
247 * export and used by InsetTabular
251 /** Export data filled in by the latex(), docbook(), etc. methods.
252 This is a hack: Make it possible to add stuff to constant
253 OutputParams instances.
255 std::shared_ptr<ExportData> exportdata;
257 /** Store labels, index entries, etc. (in \ref post_macro)
258 * and output them later. This is used in particular to get
259 * labels and index entries (and potentially other fragile commands)
260 * outside of moving arguments (bug 2154)
262 bool postpone_fragile_stuff = false;
264 /** Stuff to be postponed and output after the current macro
265 * (if \ref postpone_fragile_stuff is true). Used for labels and index
266 * entries in commands with moving arguments (\\section, \\caption etc.)
268 mutable docstring post_macro;
270 /** Whether we in a command that is not \\long (i.e. cannot have multiple
273 mutable bool isNonLong = false;
275 /** Whether we are entering a display math inset.
276 * Needed to correctly strike out deleted math in change tracking.
278 mutable bool inDisplayMath = false;
280 /** Whether we are leaving a display math inset.
281 * Needed to correctly track nested ulem commands in change tracking.
283 mutable bool wasDisplayMath = false;
285 /** Whether we are inside a comment inset. Insets that are including
286 * external files like InsetGraphics, InsetInclude and InsetExternal
287 * may only write the usual output and must not attempt to do
288 * something with the included files (e.g. copying, converting)
289 * if this flag is true, since they may not exist.
291 bool inComment = false;
293 /** Whether we are inside an include inset.
295 bool inInclude = false;
297 /** Whether we are inside a footnote.
299 mutable bool inFootnote = false;
301 /** Whether a btUnit (for multiple biblographies) is open.
303 mutable bool openbtUnit = false;
305 /** Process only the children's aux files with BibTeX.
306 * This is necessary with chapterbib.
308 bool only_childbibs = false;
310 /** Whether we are in a table cell.
311 * For newline, it matters whether its content is aligned or not.
313 TableCell inTableCell = NO;
315 /** Whether we are inside a float or subfloat.
316 * Needed for subfloat detection on the command line.
318 Float inFloat = NONFLOAT;
320 /** Whether we are inside an index inset.
321 * ERT needs to know this, due to the active chars.
323 bool inIndexEntry = false;
325 /** Whether we are inside an IPA inset.
326 * Needed for proper IPA output.
330 /** Whether we are inside an inset that is logically deleted.
331 * A value > 0 indicates a deleted inset.
333 int inDeletedInset = 0;
335 /** The change information of the outermost logically deleted inset.
336 * changeOfDeletedInset shall only be evaluated if inDeletedInset > 0.
338 Change changeOfDeletedInset {Change::UNCHANGED};
340 /** What kind of change tracking object is this?
341 * Relevant for strikeout method in output
343 mutable CtObject ctObject = CtObject::Normal;
345 /** allow output of only part of the top-level paragraphs
346 * par_begin: beginning paragraph
348 mutable pit_type par_begin = 0;
350 /** allow output of only part of the top-level paragraphs
351 * par_end: par_end-1 is the ending paragraph
352 * if par_begin=par_end, output all paragraphs
354 mutable pit_type par_end = 0;
356 /// Id of the last paragraph before an inset
357 mutable int lastid = -1;
359 /// Last position in the last paragraph before an inset
360 mutable pos_type lastpos = 0;
362 /// is this the last paragraph in the current buffer/inset?
363 bool isLastPar = false;
366 /** whether or not to do actual file copying and image conversion
367 * This mode will be used to preview the source code
371 /// whether to display output errors or not
374 /// Should we output verbatim or escape LaTeX's special chars?
375 bool pass_thru = false;
377 /// Should we output verbatim specific chars?
378 docstring pass_thru_chars;
380 /// Do not output verbatim specific chars even
381 /// if normally requested
382 docstring no_pass_thru_chars;
384 /// A specific newline macro
385 std::string newlinecmd;
387 /// Should we output captions?
388 bool html_disable_captions = false;
390 /// Are we already in a paragraph?
391 bool html_in_par = false;
393 /// Does the present context even permit paragraphs?
394 bool html_make_pars = true;
396 /// Are we already in a paragraph?
397 bool docbook_in_par = false;
399 /// Is this element's allowMultiPar useable or not?
400 bool docbook_consider_allow_multi_par = true;
402 /// Does the present context even permit paragraphs?
403 bool docbook_make_pars = true;
405 /// Are paragraphs mandatory in this context?
406 bool docbook_force_pars = false;
408 /// Anchors that should not be output (LyX-side identifier, not DocBook-side).
409 std::set<docstring> docbook_anchors_to_ignore;
411 /// Is the current context a float (such as a table or a figure)?
412 bool docbook_in_float = false;
414 /// Is the current context a listing?
415 bool docbook_in_listing = false;
417 /// Is the current context a table?
418 bool docbook_in_table = false;
420 /// Should the layouts that should/must go into <info> be generated?
421 bool docbook_generate_info = true;
423 /// Should wrappers be ignored? Mostly useful to avoid generation of <abstract>.
424 bool docbook_ignore_wrapper = false;
426 /// Some parameters are output before the rest of the paragraph, they should not be generated a second time.
427 std::set<InsetArgument const *> docbook_prepended_arguments = {};
429 /// Some parameters are output after the rest of the paragraph, they should not be generated a second time.
430 std::set<InsetArgument const *> docbook_appended_arguments = {};
432 /// Are we generating this material for inclusion in a TOC-like entity?
433 bool for_toc = false;
435 /// Are we generating this material for inclusion in a tooltip?
436 bool for_tooltip = false;
438 /// Are we generating this material for use by advanced search?
441 SearchWithDeleted = 1,
442 SearchWithoutDeleted = 2,
447 inline bool find_effective(void) const { return (for_search != OutputParams::NoSearch); }
448 inline bool find_with_non_output() const { return ((for_search & OutputParams::SearchNonOutput) != 0); }
449 inline bool find_with_deleted() const { return ((for_search & OutputParams::SearchWithDeleted) != 0); }
450 inline void find_set_feature(enum Search set_) { for_search = set_; }
451 inline void find_add_feature(enum Search add_) { for_search |= add_; }
452 inline void find_clean_features(void) { for_search = OutputParams::NoSearch; }
454 /// Are we generating this material for instant preview?
455 bool for_preview = false;
457 /// Include all children notwithstanding the use of \includeonly
458 bool includeall = false;
460 /// Explicit output folder, if any is desired
461 std::string export_folder;
463 /// A postponed \\noindent (after VSpace)
464 mutable bool need_noindent = false;
466 int for_search = NoSearch;
472 #endif // NOT OUTPUTPARAMS_H