From 9e8901f997f0b278be40b78ce85cdd7ef04d1038 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Sun, 6 Aug 2023 16:50:07 +0200 Subject: [PATCH] Adding hebrew quotation marks (bug #12849). Patch from Udi Fogiel. --- development/FORMAT | 5 +++ lib/doc/UserGuide.lyx | 63 +++++++++++++++++++++++++++++++++++++- lib/languages | 5 +-- lib/lyx2lyx/lyx_2_4.py | 27 ++++++++++++++-- src/BufferParams.cpp | 3 +- src/LyXAction.cpp | 1 + src/insets/InsetQuotes.cpp | 12 +++++++- src/insets/InsetQuotes.h | 2 ++ src/tex2lyx/Preamble.cpp | 9 +++++- src/tex2lyx/text.cpp | 8 +++++ src/version.h | 4 +-- 11 files changed, 129 insertions(+), 10 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 8adbb250a1..2687c18a79 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,6 +7,11 @@ changes happened in particular if possible. A good example would be ----------------------- +2023-08-01 Udi Fogiel + * Format incremented to 618: Hebrew quote style + New buffer param \quotes_style hebrew + \begin_inset Quotes d{l,r}{d,s} + 2023-07-20 Jürgen Spitzmüller * Format incremented to 617: Update covington support in linguistics module: - Support enviroment option of example and examples diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx index e112cddecb..222394f3bc 100644 --- a/lib/doc/UserGuide.lyx +++ b/lib/doc/UserGuide.lyx @@ -1,5 +1,5 @@ #LyX 2.4 created this file. For more info see https://www.lyx.org/ -\lyxformat 616 +\lyxformat 618 \begin_document \begin_header \save_transient_properties true @@ -168,6 +168,7 @@ logicalmkup \author 244031559 "Yuriy" \author 274215730 "scott" \author 630872221 "Jean-Pierre Chrétien" jeanpierre.chretien@free.fr +\author 1064312605 "Udi Fogiel" \author 1549938239 "Kornel Benko" \author 1675569489 "Stephan Witt" \end_header @@ -23349,6 +23350,66 @@ Note that these characters are just emulated with similar-looking math symbols i \end_inset +\change_inserted 1064312605 1690963146 + +\end_layout + +\begin_layout Labeling +\labelwidthstring <> and <>: + +\change_inserted 1064312605 1690963188 + +\family sans +\begin_inset Quotes dld +\end_inset + +Outer +\begin_inset Quotes drd +\end_inset + + +\begin_inset space ~ +\end_inset + +and +\begin_inset space ~ +\end_inset + + +\begin_inset Quotes dls +\end_inset + +inner +\begin_inset Quotes drs +\end_inset + + +\family default + Produces +\begin_inset Quotes dld +\end_inset + +these outer +\family sans + +\begin_inset Quotes drd +\end_inset + + +\family default + and +\begin_inset Quotes dls +\end_inset + +these inner +\family sans + +\begin_inset Quotes drs +\end_inset + + +\family default + quotation marks (as common in Hungary) \change_unchanged \end_layout diff --git a/lib/languages b/lib/languages index 76652f9654..7f5d4655c0 100644 --- a/lib/languages +++ b/lib/languages @@ -57,6 +57,7 @@ # - french: <> ``text'' (outward guillemets -- 66_99) # - frenchin: <> <> (French Imprimerie Nationale style) # - german: ,,text`` ,text` (99/66 -- 9/6) +# - hebrew: ''text,, 'text, (99/99 -- 9/9) # - hungarian: ,,text'' >>text<< (99/99 -- double inward guillemets) # - polish: ,,text'' ,text' (99/99 -- 9/9) # - russian: <> ,,text`` (outward guillemets -- 99/66) @@ -850,12 +851,12 @@ Language hebrew PolyglossiaName hebrew XindyName hebrew Encoding cp1255 - QuoteStyle english + QuoteStyle hebrew InternalEncoding true # babel-hebrew expects the encoding for *other* languages last: FontEncoding HE8,T1|LHE,T1 ## Use font encoding HE8 if the Culmus fonts are installed and - # work around too simple test for article-like classes in rlbabel.def. + # work around to simple test for article-like classes in rlbabel.def. PreBabelPreamble \IfFileExists{he8david.fd}{% \providecommand{\HeblatexEncoding}{HE8} diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 6e4bdbb362..ede6e4fae6 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -5525,6 +5525,27 @@ def revert_expreambles(document): revert_flex_inset(document.body, "Subexample Preamble", "\\subexpreamble") revert_flex_inset(document.body, "Example Postamble", "\\expostamble") revert_flex_inset(document.body, "Subexample Postamble", "\\subexpostamble") + +def revert_hequotes(document): + " Revert Hebrew Quotation marks " + + i = find_token(document.header, "\\quotes_style hebrew", 0) + if i != -1: + document.header[i] = "\\quotes_style english" + + i = 0 + while True: + i = find_token(document.body, "\\begin_inset Quotes d") + if i == -1: + return + if document.body[i] == "\\begin_inset Quotes dld": + document.body[i] = "\\begin_inset Quotes prd" + elif document.body[i] == "\\begin_inset Quotes drd": + document.body[i] = "\\begin_inset Quotes pld" + elif document.body[i] == "\\begin_inset Quotes dls": + document.body[i] = "\\begin_inset Quotes prd" + elif document.body[i] == "\\begin_inset Quotes drs": + document.body[i] = "\\begin_inset Quotes pld" ## @@ -5605,10 +5626,12 @@ convert = [ [614, [convert_hyper_other]], [615, [convert_acknowledgment,convert_ack_theorems]], [616, [convert_empty_macro]], - [617, [convert_cov_options]] + [617, [convert_cov_options]], + [618, []] ] -revert = [[616, [revert_expreambles,revert_exarg2,revert_linggloss2,revert_cov_options]], +revert = [[617, [revert_hequotes]], + [616, [revert_expreambles,revert_exarg2,revert_linggloss2,revert_cov_options]], [615, [revert_empty_macro]], [614, [revert_ack_theorems,revert_acknowledgment]], [613, [revert_hyper_other]], diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index a6ccd4ed54..ec4d290609 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -74,7 +74,7 @@ static char const * const string_paragraph_separation[] = { static char const * const string_quotes_style[] = { "english", "swedish", "german", "polish", "swiss", "danish", "plain", "british", "swedishg", "french", "frenchin", "russian", "cjk", "cjkangle", - "hungarian", "" + "hungarian", "hebrew", "" }; @@ -158,6 +158,7 @@ QuotesStyleTranslator const init_quotesstyletranslator() translator.addPair(string_quotes_style[12], QuoteStyle::CJK); translator.addPair(string_quotes_style[13], QuoteStyle::CJKAngle); translator.addPair(string_quotes_style[14], QuoteStyle::Hungarian); + translator.addPair(string_quotes_style[15], QuoteStyle::Hebrew); return translator; } diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 3391e228d2..19f12038a8 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -3479,6 +3479,7 @@ void LyXAction::init() * 'french' for <> quote style (with ``inner quotation'')\n * 'frenchin' for <> quote style (with <>) ["in" = Imprimerie Nationale]\n * 'german' for ,,German`` quote style (with ,inner quotation`)\n + * 'hebrew' for ''hebrew,, quote style (with 'inner quotation,)\n * 'plain' for "Plain" quote style (with 'inner quotation')\n * 'polish' for ,,Polish'' quote style (with ,inner quotation')\n * 'swedish' for ''Swedish'' quote style (with 'inner quotation')\n diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp index f582360554..53709daba4 100644 --- a/src/insets/InsetQuotes.cpp +++ b/src/insets/InsetQuotes.cpp @@ -68,10 +68,11 @@ namespace { * j [U+300C]cjk[U+300D] ([U+300E]inner quotation[U+300F]) [CORNER BRACKETS] * k [U+300A]cjkangle[U+300B] ([U+3008]inner quotation[U+3009]) [ANGLE BRACKETS] * h ,,hungarian'' (>>inner quotation<<) + * d ''hebrew,, ('inner quotation,) * x dynamic style (inherits document settings) */ -char const * const style_char = "esgpcaqbwfirjkhx"; +char const * const style_char = "esgpcaqbwfirjkhdx"; char const * const side_char = "lr" ; char const * const level_char = "sd"; @@ -313,6 +314,13 @@ char_type InsetQuotesParams::getQuoteChar(QuoteStyle const & style, QuoteLevel c right_secondary = 0x00ab; // << break; } + case QuoteStyle::Hebrew: { + left_primary = 0x201d; // '' + right_primary = 0x201e; // ,, + left_secondary = 0x2019; // ' + right_secondary = 0x201a; // , + break; + } case QuoteStyle::Dynamic: default: // should not happen @@ -641,6 +649,8 @@ QuoteStyle InsetQuotes::getStyle(string const & s) qs = QuoteStyle::CJKAngle; else if (s == "hungarian") qs = QuoteStyle::Hungarian; + else if (s == "hebrew") + qs = QuoteStyle::Hebrew; else if (s == "dynamic") qs = QuoteStyle::Dynamic; diff --git a/src/insets/InsetQuotes.h b/src/insets/InsetQuotes.h index 41bad175b8..5e6cb3c4aa 100644 --- a/src/insets/InsetQuotes.h +++ b/src/insets/InsetQuotes.h @@ -53,6 +53,8 @@ enum class QuoteStyle : int { /// Hungarian, /// + Hebrew, + /// Dynamic }; diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index c7e3f73f37..3226b0f0a5 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -137,6 +137,9 @@ const char * const known_swiss_quotes_languages[] = {"albanian", "armenian", "basque", "churchslavonic", "german-ch", "german-ch-old", "norsk", "nynorsk", "turkmen", "ukrainian", "vietnamese", 0}; +/// languages with hebrew quotes (.lyx names) +const char * const known_hebrew_quotes_languages[] = {"hebrew", 0}; + /// known language packages from the times before babel const char * const known_old_language_packages[] = {"french", "frenchle", "frenchpro", "german", "ngerman", "pmfrench", 0}; @@ -3173,7 +3176,7 @@ void Preamble::parse(Parser & p, string const & forceclass, // Finally, set the quote style. // LyX knows the following quotes styles: // british, cjk, cjkangle, danish, english, french, german, - // polish, russian, swedish and swiss + // polish, russian, swedish, swiss, and hebrew // conversion list taken from // https://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage // (quotes for kazakh are unknown) @@ -3210,6 +3213,10 @@ void Preamble::parse(Parser & p, string const & forceclass, // swiss else if (is_known(h_language, known_swiss_quotes_languages)) h_quotes_style = "swiss"; + // hebrew + else if (is_known(h_language, known_hebrew_quotes_languages)) + h_quotes_style = "hebrew"; + // english else if (is_known(h_language, known_english_quotes_languages)) h_quotes_style = "english"; diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index ed80968f5d..4dd5f11f38 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -504,6 +504,8 @@ string guessQuoteStyle(string const & in, bool const opening) res = "hrd"; else if (preamble.quotesStyle() == "swedish") res = opening ? "sld" : "srd"; + else if (preamble.quotesStyle() == "hebrew") + res = "dld"; } else if (in == "els") {// ` if (preamble.quotesStyle() == "german") res = "grs"; @@ -516,6 +518,8 @@ string guessQuoteStyle(string const & in, bool const opening) res = "brd"; else if (preamble.quotesStyle() == "swedish") res = opening ? "sls" : "srs"; + else if (preamble.quotesStyle() == "hebrew") + res = "dls"; } else if (in == "ard") {// >> if (preamble.quotesStyle() == "swiss") res = "cld"; @@ -547,9 +551,13 @@ string guessQuoteStyle(string const & in, bool const opening) res = "hld"; else if (preamble.quotesStyle() == "russian") res = "rls"; + else if (preamble.quotesStyle() == "hebrew") + res = "drd"; } else if (in == "gls") {// , if (preamble.quotesStyle() == "polish") res = "pls"; + else if (preamble.quotesStyle() == "hebrew") + res = "drs"; } return res; } diff --git a/src/version.h b/src/version.h index df53604d51..ab05f89504 100644 --- a/src/version.h +++ b/src/version.h @@ -32,8 +32,8 @@ extern char const * const lyx_version_info; // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -#define LYX_FORMAT_LYX 617 // spitz: linguistics module enhancements -#define LYX_FORMAT_TEX2LYX 617 +#define LYX_FORMAT_LYX 618 // Udi_Fogiel: hebrew quote style +#define LYX_FORMAT_TEX2LYX 618 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER