mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Do not convert dashes/hyphens in Code insets (logical markup).
Code is by default rendered as typewriter and should be treated similar: In text marked up as code, -- or --- is typically part of a command (e.g. "lyx --help" or "x--") and not a transliteration for en dash, see #10961. This is already handled so for text in typewriter font (see Text.cpp:500).
This commit is contained in:
parent
a3dcb6e4e5
commit
cb1fda9988
@ -618,12 +618,15 @@ def convert_dashes(document):
|
|||||||
i = 0
|
i = 0
|
||||||
while i < len(document.body):
|
while i < len(document.body):
|
||||||
words = document.body[i].split()
|
words = document.body[i].split()
|
||||||
if len(words) > 1 and words[0] == "\\begin_inset" and \
|
if (len(words) > 1 and words[0] == "\\begin_inset"
|
||||||
words[1] in ["CommandInset", "ERT", "External", "Formula", "FormulaMacro", "Graphics", "IPA", "listings"]:
|
and (words[1] in ["CommandInset", "ERT", "External", "Formula",
|
||||||
|
"FormulaMacro", "Graphics", "IPA", "listings"]
|
||||||
|
or ' '.join(words[1:]) == "Flex Code")):
|
||||||
# must not replace anything in insets that store LaTeX contents in .lyx files
|
# must not replace anything in insets that store LaTeX contents in .lyx files
|
||||||
# (math and command insets withut overridden read() and write() methods
|
# (math and command insets without overridden read() and write() methods
|
||||||
# filtering out IPA makes Text::readParToken() more simple
|
# filtering out IPA makes Text::readParToken() more simple
|
||||||
# skip ERT as well since it is not needed there
|
# skip ERT as well since it is not needed there
|
||||||
|
# Flex Code is logical markup, typically rendered as typewriter
|
||||||
j = find_end_of_inset(document.body, i)
|
j = find_end_of_inset(document.body, i)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
document.warning("Malformed LyX document: Can't find end of " + words[1] + " inset at line " + str(i))
|
document.warning("Malformed LyX document: Can't find end of " + words[1] + " inset at line " + str(i))
|
||||||
|
@ -1862,9 +1862,10 @@ def convert_dashligatures(document):
|
|||||||
if (i < j) or line.startswith("\\labelwidthstring"):
|
if (i < j) or line.startswith("\\labelwidthstring"):
|
||||||
continue
|
continue
|
||||||
words = line.split()
|
words = line.split()
|
||||||
if len(words) > 1 and words[0] == "\\begin_inset" and \
|
if (len(words) > 1 and words[0] == "\\begin_inset"
|
||||||
words[1] in ["CommandInset", "ERT", "External", "Formula",
|
and (words[1] in ["CommandInset", "ERT", "External", "Formula",
|
||||||
"FormulaMacro", "Graphics", "IPA", "listings"]:
|
"FormulaMacro", "Graphics", "IPA", "listings"]
|
||||||
|
or ' '.join(words[1:]) == "Flex Code")):
|
||||||
j = find_end_of_inset(document.body, i)
|
j = find_end_of_inset(document.body, i)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
document.warning("Malformed LyX document: "
|
document.warning("Malformed LyX document: "
|
||||||
@ -1903,10 +1904,6 @@ def revert_dashligatures(document):
|
|||||||
return
|
return
|
||||||
use_dash_ligatures = get_bool_value(document.header, "\\use_dash_ligatures", i)
|
use_dash_ligatures = get_bool_value(document.header, "\\use_dash_ligatures", i)
|
||||||
del document.header[i]
|
del document.header[i]
|
||||||
use_non_tex_fonts = False
|
|
||||||
i = find_token(document.header, "\\use_non_tex_fonts", 0)
|
|
||||||
if i != -1:
|
|
||||||
use_non_tex_fonts = get_bool_value(document.header, "\\use_non_tex_fonts", i)
|
|
||||||
if not use_dash_ligatures or document.backend != "latex":
|
if not use_dash_ligatures or document.backend != "latex":
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1918,9 +1915,10 @@ def revert_dashligatures(document):
|
|||||||
new_body.append(line)
|
new_body.append(line)
|
||||||
continue
|
continue
|
||||||
words = line.split()
|
words = line.split()
|
||||||
if len(words) > 1 and words[0] == "\\begin_inset" and \
|
if (len(words) > 1 and words[0] == "\\begin_inset"
|
||||||
words[1] in ["CommandInset", "ERT", "External", "Formula",
|
and (words[1] in ["CommandInset", "ERT", "External", "Formula",
|
||||||
"FormulaMacro", "Graphics", "IPA", "listings"]:
|
"FormulaMacro", "Graphics", "IPA", "listings"]
|
||||||
|
or ' '.join(words[1:]) == "Flex Code")):
|
||||||
j = find_end_of_inset(document.body, i)
|
j = find_end_of_inset(document.body, i)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
document.warning("Malformed LyX document: Can't find end of "
|
document.warning("Malformed LyX document: Can't find end of "
|
||||||
|
Loading…
Reference in New Issue
Block a user