Re: [patch] PassThruChars
2015-04-21 0:15 GMT+02:00 aparsloe: As I understand it, you are implementing an enhancement request I made 3 years ago: #8347. I am delighted. Nice. Didn't see that. Jürgen Andrew
Re: [patch] PassThruChars
2015-04-21 0:15 GMT+02:00 aparsloe: > As I understand it, you are implementing an enhancement request I made 3 > years ago: #8347. I am delighted. > Nice. Didn't see that. Jürgen > > Andrew >
Re: [patch] PassThruChars
On 04/20/2015 06:15 PM, aparsloe wrote: On 21/04/2015 12:43 a.m., Jürgen Spitzmüller wrote: In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. snip I think this might also be useful in other cases. Comments? Jürgen Hullo Jürgen. As I understand it, you are implementing an enhancement request I made 3 years ago: #8347. I am delighted. Indeed. I've updated the bug. Richard
Re: [patch] PassThruChars
On 21/04/2015 12:43 a.m., Jürgen Spitzmüller wrote: In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. snip I think this might also be useful in other cases. Comments? Jürgen Hullo Jürgen. As I understand it, you are implementing an enhancement request I made 3 years ago: #8347. I am delighted. Andrew
Re: [patch] PassThruChars
2015-04-20 14:59 GMT+02:00 Richard Heck: Yes, this sounds generally useful. My only thought would be: Wouldn't it be slightly easier to store the pass_thru_chars as a vector rather than call getVectorFromString every time we need it? I pondered about this as well. I just think we only need it in this one place most likely, and a string is easier to handle. Jürgen Richard
Re: [patch] PassThruChars
On 04/20/2015 08:43 AM, Jürgen Spitzmüller wrote: In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. Thus, I propose the following patch, which adds PassThruChars tags to InsetLayout and Layout, where a comma.separated list of characters that should be treated verbatim can be specified. I think this might also be useful in other cases. Yes, this sounds generally useful. My only thought would be: Wouldn't it be slightly easier to store the pass_thru_chars as a vector rather than call getVectorFromString every time we need it? Richard
[patch] PassThruChars
In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. Thus, I propose the following patch, which adds PassThruChars tags to InsetLayout and Layout, where a comma.separated list of characters that should be treated verbatim can be specified. I think this might also be useful in other cases. Comments? Jürgen 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..35e86a1 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1139,7 +1139,13 @@ 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) { + // Characters that are requested ny layout/insetlayout to be handled verbatim + vectordocstring pass_thru_chars = getVectorFromString(style.pass_thru_chars); + vectordocstring il_pass_thru_chars = getVectorFromString(runparams.pass_thru_chars); + pass_thru_chars.insert(pass_thru_chars.end(), il_pass_thru_chars.begin(), il_pass_thru_chars.end()); + + if (style.pass_thru || runparams.pass_thru + || (std::find(pass_thru_chars.begin(), pass_thru_chars.end(), docstring(1, c)) != pass_thru_chars.end())) { if (c != '\0') { Encoding const * const enc =
Re: [patch] PassThruChars
Le 20/04/2015 14:43, Jürgen Spitzmüller a écrit : In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. Thus, I propose the following patch, which adds PassThruChars tags to InsetLayout and Layout, where a comma.separated list of characters that should be treated verbatim can be specified. If these are plain characters, why shall the list be comma separated instead of being a plain string? JMarc
Re: [patch] PassThruChars
Le 20/04/2015 16:16, Jürgen Spitzmüller a écrit : 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. I suspect that lex does not allow you to specify quoted strings. Does this means that one cannot enter strings containing spaces? Are spaces supported by the functionality, actually? A solution would be to use lex.next(true) and lex.getString(), so that strings can be quoted. This could be the default for , but I am sure this would break something somewhere. JMarc
Re: [patch] PassThruChars
On 04/20/2015 10:16 AM, Jürgen Spitzmüller wrote: 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. Looks good. rh
Re: [patch] PassThruChars
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
Re: [patch] PassThruChars
2015-04-20 16:57 GMT+02:00 Jean-Marc Lasgouttes: I suspect that lex does not allow you to specify quoted strings. Does this means that one cannot enter strings containing spaces? Are spaces supported by the functionality, actually? It works for me (quoted strings, that is). On the other hand, I cannot think of a use for spaces. Jürgen A solution would be to use lex.next(true) and lex.getString(), so that strings can be quoted. This could be the default for , but I am sure this would break something somewhere. JMarc
Re: [patch] PassThruChars
Le 20/04/2015 17:15, Jürgen Spitzmüller a écrit : 2015-04-20 16:57 GMT+02:00 Jean-Marc Lasgouttes: I suspect that lex does not allow you to specify quoted strings. Does this means that one cannot enter strings containing spaces? Are spaces supported by the functionality, actually? It works for me (quoted strings, that is). On the other hand, I cannot think of a use for spaces. We'll have to do something about FreeSpacing that implies that spaces are output as ~. This prevent us from implementing alltt as a better version of the horrible LyX-Code. JMarc
Re: [patch] PassThruChars
2015-04-20 17:21 GMT+02:00 Jean-Marc Lasgouttes: We'll have to do something about FreeSpacing that implies that spaces are output as ~. This prevent us from implementing alltt as a better version of the horrible LyX-Code. I just tested, and the following seems to work (consecutive spaces are output as I would expect it): FreeSpacing true PassThruChars [] Jürgen JMarc
Re: [patch] PassThruChars
2015-04-20 17:26 GMT+02:00 Jürgen Spitzmüller: 2015-04-20 17:21 GMT+02:00 Jean-Marc Lasgouttes: We'll have to do something about FreeSpacing that implies that spaces are output as ~. This prevent us from implementing alltt as a better version of the horrible LyX-Code. I just tested, and the following seems to work (consecutive spaces are output as I would expect it): FreeSpacing true PassThruChars [] Jürgen Actually, I also need the attached. Is this what you have in mind? Jürgen diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index da4dccf..444ae7c 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -898,7 +898,8 @@ bool Paragraph::Private::simpleTeXBlanks(OutputParams const runparams, os '\n'; os.texrow().start(owner_-id(), i + 1); column = 0; - } else if (style.free_spacing) { + } else if (style.free_spacing !contains(style.pass_thru_chars, ' ') + !contains(runparams.pass_thru_chars, ' ')) { os '~'; } else { os ' ';
[patch] PassThruChars
In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. Thus, I propose the following patch, which adds PassThruChars tags to InsetLayout and Layout, where a comma.separated list of characters that should be treated verbatim can be specified. I think this might also be useful in other cases. Comments? Jürgen 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..35e86a1 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1139,7 +1139,13 @@ 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) { + // Characters that are requested ny layout/insetlayout to be handled verbatim + vector pass_thru_chars = getVectorFromString(style.pass_thru_chars); + vector il_pass_thru_chars = getVectorFromString(runparams.pass_thru_chars); + pass_thru_chars.insert(pass_thru_chars.end(), il_pass_thru_chars.begin(), il_pass_thru_chars.end()); + + if (style.pass_thru || runparams.pass_thru + || (std::find(pass_thru_chars.begin(), pass_thru_chars.end(), docstring(1, c)) != pass_thru_chars.end())) { if (c !=
Re: [patch] PassThruChars
On 04/20/2015 08:43 AM, Jürgen Spitzmüller wrote: In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. Thus, I propose the following patch, which adds PassThruChars tags to InsetLayout and Layout, where a comma.separated list of characters that should be treated verbatim can be specified. I think this might also be useful in other cases. Yes, this sounds generally useful. My only thought would be: Wouldn't it be slightly easier to store the pass_thru_chars as a vector rather than call getVectorFromString every time we need it? Richard
Re: [patch] PassThruChars
2015-04-20 14:59 GMT+02:00 Richard Heck: > Yes, this sounds generally useful. > > My only thought would be: Wouldn't it be slightly easier to store the > pass_thru_chars as a vector rather than call getVectorFromString every time > we need it? > I pondered about this as well. I just think we only need it in this one place most likely, and a string is easier to handle. Jürgen > > Richard > >
Re: [patch] PassThruChars
Le 20/04/2015 14:43, Jürgen Spitzmüller a écrit : In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. Thus, I propose the following patch, which adds PassThruChars tags to InsetLayout and Layout, where a comma.separated list of characters that should be treated verbatim can be specified. If these are plain characters, why shall the list be comma separated instead of being a plain string? JMarc
Re: [patch] PassThruChars
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
Re: [patch] PassThruChars
On 04/20/2015 10:16 AM, Jürgen Spitzmüller wrote: 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. Looks good. rh
Re: [patch] PassThruChars
Le 20/04/2015 16:16, Jürgen Spitzmüller a écrit : 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. I suspect that lex>> does not allow you to specify quoted strings. Does this means that one cannot enter strings containing spaces? Are spaces supported by the functionality, actually? A solution would be to use lex.next(true) and lex.getString(), so that strings can be quoted. This could be the default for >>, but I am sure this would break something somewhere. JMarc
Re: [patch] PassThruChars
2015-04-20 16:57 GMT+02:00 Jean-Marc Lasgouttes: > I suspect that lex>> does not allow you to specify quoted strings. Does > this means that one cannot enter strings containing spaces? Are spaces > supported by the functionality, actually? > It works for me (quoted strings, that is). On the other hand, I cannot think of a use for spaces. Jürgen > > A solution would be to use lex.next(true) and lex.getString(), so that > strings can be quoted. This could be the default for >>, but I am sure this > would break something somewhere. > > JMarc > >
Re: [patch] PassThruChars
Le 20/04/2015 17:15, Jürgen Spitzmüller a écrit : 2015-04-20 16:57 GMT+02:00 Jean-Marc Lasgouttes: I suspect that lex>> does not allow you to specify quoted strings. Does this means that one cannot enter strings containing spaces? Are spaces supported by the functionality, actually? It works for me (quoted strings, that is). On the other hand, I cannot think of a use for spaces. We'll have to do something about FreeSpacing that implies that spaces are output as ~. This prevent us from implementing alltt as a better version of the horrible LyX-Code. JMarc
Re: [patch] PassThruChars
2015-04-20 17:21 GMT+02:00 Jean-Marc Lasgouttes: > We'll have to do something about FreeSpacing that implies that spaces are > output as ~. This prevent us from implementing alltt as a better version of > the horrible LyX-Code. > I just tested, and the following seems to work (consecutive spaces are output as I would expect it): FreeSpacing true PassThruChars "[] " Jürgen > > JMarc > >
Re: [patch] PassThruChars
2015-04-20 17:26 GMT+02:00 Jürgen Spitzmüller: > 2015-04-20 17:21 GMT+02:00 Jean-Marc Lasgouttes: > >> We'll have to do something about FreeSpacing that implies that spaces are >> output as ~. This prevent us from implementing alltt as a better version of >> the horrible LyX-Code. >> > > I just tested, and the following seems to work (consecutive spaces are > output as I would expect it): > > FreeSpacing true > PassThruChars "[] " > > Jürgen > > Actually, I also need the attached. Is this what you have in mind? Jürgen diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index da4dccf..444ae7c 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -898,7 +898,8 @@ bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams, os << '\n'; os.texrow().start(owner_->id(), i + 1); column = 0; - } else if (style.free_spacing) { + } else if (style.free_spacing && !contains(style.pass_thru_chars, ' ') + && !contains(runparams.pass_thru_chars, ' ')) { os << '~'; } else { os << ' ';
Re: [patch] PassThruChars
On 21/04/2015 12:43 a.m., Jürgen Spitzmüller wrote: In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. I think this might also be useful in other cases. Comments? Jürgen Hullo Jürgen. As I understand it, you are implementing an enhancement request I made 3 years ago: #8347. I am delighted. Andrew
Re: [patch] PassThruChars
On 04/20/2015 06:15 PM, aparsloe wrote: On 21/04/2015 12:43 a.m., Jürgen Spitzmüller wrote: In order to implement a linguistic feature properly (support for the forest package to generate structure trees), I need a way to pass only selected chars verbatim (here, [ and ], since these are active characters in the package and thus must not be escaped by braces). Making the whole inset PassThru is not a good option, neither the need to use ERT for the brackets. I think this might also be useful in other cases. Comments? Jürgen Hullo Jürgen. As I understand it, you are implementing an enhancement request I made 3 years ago: #8347. I am delighted. Indeed. I've updated the bug. Richard