On 2017-01-17, Guenter Milde wrote: > On 2017-01-17, Enrico Forestieri wrote: >> On Tue, Jan 17, 2017 at 06:05:57PM +0100, Enrico Forestieri wrote: >>> On Tue, Jan 17, 2017 at 09:41:03AM -0500, Richard Heck wrote: >>> > On 01/17/2017 02:55 AM, Jürgen Spitzmüller wrote: >>> > > Am Montag, den 16.01.2017, 22:17 +0000 schrieb Guenter Milde: >>> > >> Now we have 3 specs: >>> > >> >>> > >> 1. Unicode: Break Opportunity Before and After >>> > >> >>> > >> 2. --- ligature: Break opportunity after, no hyphenation of word >>> > >> before >>> > >> (also with literal EM DASH and \textemdash macro with non-TeX >>> > >> fonts). >>> > >> >>> > >> 3. \textemdash macro (and literal EM DASH with inputenc-utf8) and TeX >>> > >> fonts: >>> > >> no break opportunity. Hyphenation of word before allowed. >>> > >> >>> > >> What should be the LyX behaviour? >>> > > 2. >>> > >>> > I agree with Jürgen, mostly because this is the old and expected >>> > behavior. >>> That's also my opinion. >> Meaning that we should output "---".
Below is an incomplete patch (see FIXME). Could someone with more C++ knowledge complete and test, please? Günter Exec: git 'diff' 'LaTeXFeatures.cpp' 2>&1 Dir: /usr/local/src/lyx/src/ diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 08e1470561..332a49556e 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -374,7 +374,21 @@ static docstring const lyxref_def = from_ascii( " {\\def\\RSlemtxt{lemma~}\\newref{lem}{name = \\RSlemtxt}}\n" " {}\n"); -// Make sure the columns are also outputed as rtl +// Allow line wrapping after em- and en-dash +static docstring const textdashes_utf8_def = from_ascii( + "\\DeclareUnicodeCharacter{2013}{--}\n" + "\\DeclareUnicodeCharacter{2014}{---}n"); +static docstring const textdashes_cp_def = from_ascii( + "\\DeclareInputText{150}{--}\n" + "\\DeclareInputText{151}{---}\n"); +static docstring const textdashes_next_def = from_ascii( + "\\DeclareInputText{177}{--}\n" + "\\DeclareInputText{208}{---}\n"); +static docstring const textdashes_mac_def = from_ascii( + "\\DeclareInputText{208}{--}\n" + "\\DeclareInputText{209}{---}\n"); + +// Make sure the columns are also put out as rtl static docstring const rtloutputdblcol_def = from_ascii( "\\def\\@outputdblcol{%\n" " \\if@firstcolumn\n" @@ -1346,6 +1360,28 @@ TexString LaTeXFeatures::getMacros() const if (mustProvide("textbaltic")) macros << textbaltic_def << '\n'; + // em- and en-dash + // * \textemdash/\textendash prevents wraps before and after the dash + // inptenc uses textemdash/textendash. + // * The Unicode standard allows wraps before and after the dash. + // * LaTeX ligatures "---" and "--" allow wraps after the dash. + // lib/unicodesymbols inserts ligatures, for utf8 and utf8x we + // override the inputenc definitions for consistency. Power users + // may override this in the LaTeX preamble. + // FIXME: + // replace "encoding" by a variable containing the document input encoding + if (mustProvide("textdashes")) { + if (encoding == "utf8" || encoding == "utf8x") + macros << textdashes_utf8_def << '\n'; + else if (encoding == "ansinew" || encoding == "cp1250" || + encoding == "cp1252" || encoding == "cp1257") + macros << textdashes_cp_def << '\n'; + else if (encoding == "next") + macros << textdashes_next_def << '\n'; + else if (encoding == "applemac" || encoding == "macce") + macros << textdashes_mac_def << '\n'; + } + // split-level fractions if (mustProvide("xfrac") || mustProvide("smallLetterFrac")) macros << xfrac_def << '\n'; Exec: git 'diff' 'unicodesymbols' 2>&1 Dir: /usr/local/src/lyx/lib/ diff --git a/lib/unicodesymbols b/lib/unicodesymbols index d894a8e720..3bc28af7dd 100644 --- a/lib/unicodesymbols +++ b/lib/unicodesymbols @@ -1737,8 +1737,8 @@ 0x2010 "-" "" "force=utf8x,notermination=text" "" "" # HYPHEN # identic in LaTeX to FIGURE DASH 0x2011 "\\nobreakdash-" "amsmath" "notermination=text" "" "" # NON-BREAKING HYPHEN 0x2012 "-" "" "force=utf8x,notermination=text" "" "" # FIGURE DASH -0x2013 "\\textendash" "" "" # EN DASH -0x2014 "\\textemdash" "" "force=armscii8" # EM DASH +0x2013 "--" "textdashes" "notermination=text" # EN DASH +0x2014 "---" "textdashes" "force=armscii8,notermination=text" # EM DASH # use the following macro for the character HORIZONTAL BAR 0x2015 "\\LyXbar" "\\newcommand*\\LyXbar{\\rule[0.585ex]{1.2em}{0.25pt}}" "force" 0x2016 "\\textbardbl" "textcomp" "force=utf8x,notermination=math,tipashortcut=\\textdoublevertline{}" "\\|" "" # DOUBLE VERTICAL LINE