New (Inset)Layout tag PassThruChars

This commit is contained in:
Juergen Spitzmueller 2015-04-20 18:13:49 +02:00
parent bf93b9756e
commit 897b2e73a1
10 changed files with 1061 additions and 577 deletions

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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;

View File

@ -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))

View File

@ -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 {

View File

@ -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;

View File

@ -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_;

View File

@ -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();