2015-04-20 15:51 GMT+02:00 Jean-Marc Lasgouttes: > If these are plain characters, why shall the list be comma separated > instead of being a plain string? >
It did not occur to me to simply use a string, but you are right, it is much easier that way. See attached. Jürgen > > JMarc > >
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 1957633..95412ca 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -180,6 +180,9 @@ import os, re, string, sys # Incremented to format 54, 11 Jan 2014 by gb # New InsetLayout tag "FixedWidthPreambleEncoding" +# Incremented to format 55, 20 April 2015 by spitz +# New InsetLayout and Layout tags "PassThruChars" + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). @@ -187,7 +190,7 @@ import os, re, string, sys # development/tools/updatelayouts.py script to update all # layout files to the new format. -currentFormat = 54 +currentFormat = 55 def usage(prog_name): @@ -411,7 +414,7 @@ def convert(lines): i += 1 continue - if format >= 50 and format <= 53: + if format >= 50 and format <= 54: # nothing to do. i += 1 continue diff --git a/src/Layout.cpp b/src/Layout.cpp index bb31287..be51756 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -51,6 +51,7 @@ enum LayoutTags { LT_FONT, LT_FREE_SPACING, LT_PASS_THRU, + LT_PASS_THRU_CHARS, LT_PARBREAK_IS_NEWLINE, LT_ITEMCOMMAND, LT_ITEMSEP, @@ -235,6 +236,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) { "parsep", LT_PARSEP }, { "parskip", LT_PARSKIP }, { "passthru", LT_PASS_THRU }, + { "passthruchars", LT_PASS_THRU_CHARS }, { "preamble", LT_PREAMBLE }, { "refprefix", LT_REFPREFIX }, { "requires", LT_REQUIRES }, @@ -548,6 +550,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> pass_thru; break; + case LT_PASS_THRU_CHARS: + lex >> pass_thru_chars; + break; + case LT_PARBREAK_IS_NEWLINE: lex >> parbreak_is_newline; break; @@ -1280,6 +1286,7 @@ void Layout::write(ostream & os) const os << "\tLabelCounter \"" << to_utf8(counter) << "\"\n"; os << "\tFreeSpacing " << free_spacing << '\n'; os << "\tPassThru " << pass_thru << '\n'; + os << "\tPassThruChars " << to_utf8(pass_thru_chars) << '\n'; os << "\tParbreakIsNewline " << parbreak_is_newline << '\n'; switch (spacing.getSpace()) { case Spacing::Double: diff --git a/src/Layout.h b/src/Layout.h index 2da831e..9f98f0a 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -285,6 +285,8 @@ public: bool free_spacing; /// bool pass_thru; + /// Individual chars to be passed verbatim + docstring pass_thru_chars; /// bool parbreak_is_newline; /// show this in toc diff --git a/src/OutputParams.h b/src/OutputParams.h index 8663c17..e5e9ad0 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -254,6 +254,9 @@ public: /// Should we output verbatim or escape LaTeX's special chars? bool pass_thru; + /// Should we output verbatim specific chars? + docstring pass_thru_chars; + /// Should we output captions? bool html_disable_captions; diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 906a069..da4dccf 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1139,7 +1139,9 @@ void Paragraph::Private::latexSpecialChar(otexstream & os, char_type const c = (runparams.use_polyglossia) ? owner_->getUChar(bparams, i) : text_[i]; - if (style.pass_thru || runparams.pass_thru) { + if (style.pass_thru || runparams.pass_thru + || contains(style.pass_thru_chars, c) + || contains(runparams.pass_thru_chars, c)) { if (c != '\0') { Encoding const * const enc = runparams.encoding; if (enc && !enc->encodable(c)) diff --git a/src/TextClass.cpp b/src/TextClass.cpp index a07b674..02fc86e 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -61,7 +61,7 @@ namespace lyx { // You should also run the development/tools/updatelayouts.py script, // to update the format of all of our layout files. // -int const LAYOUT_FORMAT = 54; //gb: add FixedWidthPreambleEncoding tag for InsetLayouts +int const LAYOUT_FORMAT = 55; //spitz: InsetLayout and Layout tags PassThruChars namespace { diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index 6b30f5a..6e081d9 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -117,6 +117,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) IL_MULTIPAR, IL_NEEDPROTECT, IL_PASSTHRU, + IL_PASSTHRU_CHARS, IL_PARBREAKISNEWLINE, IL_PREAMBLE, IL_REQUIRES, @@ -171,6 +172,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) { "obsoletedby", IL_OBSOLETEDBY }, { "parbreakisnewline", IL_PARBREAKISNEWLINE }, { "passthru", IL_PASSTHRU }, + { "passthruchars", IL_PASSTHRU_CHARS }, { "preamble", IL_PREAMBLE }, { "refprefix", IL_REFPREFIX }, { "requires", IL_REQUIRES }, @@ -296,6 +298,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) case IL_PASSTHRU: lex >> passthru_; break; + case IL_PASSTHRU_CHARS: + lex >> passthru_chars_; + break; case IL_PARBREAKISNEWLINE: lex >> parbreakisnewline_; break; diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index d2e6458..9589fad 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -156,6 +156,8 @@ public: /// bool isPassThru() const { return passthru_; } /// + docstring passThruChars() const { return passthru_chars_; } + /// bool parbreakIsNewline() const { return parbreakisnewline_; } /// bool isNeedProtect() const { return needprotect_; } @@ -262,6 +264,8 @@ private: /// bool passthru_; /// + docstring passthru_chars_; + /// bool parbreakisnewline_; /// bool freespacing_; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 7a67123..0073642 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -478,6 +478,8 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const rp.pass_thru = true; if (il.isNeedProtect()) rp.moving_arg = true; + if (!il.passThruChars().empty()) + rp.pass_thru_chars += il.passThruChars(); rp.par_begin = 0; rp.par_end = paragraphs().size();