mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Load color before polyglossia also in preview snippets
This fixes an error in the preview generation with polyglossia and bidi that prevents snippet generation (and consequently also "math as image" xhtml output). Fixes: #10716.
This commit is contained in:
parent
0237292eb1
commit
476705ba76
@ -202,6 +202,7 @@ def extract_resolution(log_file, dpi):
|
|||||||
|
|
||||||
def legacy_latex_file(latex_file, fg_color, bg_color):
|
def legacy_latex_file(latex_file, fg_color, bg_color):
|
||||||
use_preview_re = re.compile(r"\s*\\usepackage\[([^]]+)\]{preview}")
|
use_preview_re = re.compile(r"\s*\\usepackage\[([^]]+)\]{preview}")
|
||||||
|
use_polyglossia_re = re.compile(r"\s*\\usepackage{polyglossia}")
|
||||||
fg_color_gr = make_texcolor(fg_color, True)
|
fg_color_gr = make_texcolor(fg_color, True)
|
||||||
bg_color_gr = make_texcolor(bg_color, True)
|
bg_color_gr = make_texcolor(bg_color, True)
|
||||||
|
|
||||||
@ -216,18 +217,36 @@ def legacy_latex_file(latex_file, fg_color, bg_color):
|
|||||||
warning('Warning in legacy_latex_file! Unable to open "%s"' % latex_file)
|
warning('Warning in legacy_latex_file! Unable to open "%s"' % latex_file)
|
||||||
warning(`sys.exc_type` + ',' + `sys.exc_value`)
|
warning(`sys.exc_type` + ',' + `sys.exc_value`)
|
||||||
|
|
||||||
|
polyglossia = False
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if success:
|
if success:
|
||||||
tmp.write(line)
|
tmp.write(line)
|
||||||
continue
|
continue
|
||||||
match = use_preview_re.match(line)
|
match = use_preview_re.match(line)
|
||||||
|
polymatch = use_polyglossia_re.match(line)
|
||||||
|
# Package order:
|
||||||
|
# * if polyglossia is used, we need to load color before that
|
||||||
|
# (also, we do not have to load lmodern)
|
||||||
|
# * else, color should be loaded before preview
|
||||||
if match == None:
|
if match == None:
|
||||||
tmp.write(line)
|
if polymatch == None:
|
||||||
continue
|
tmp.write(line)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
tmp.write(b"""
|
||||||
|
\\usepackage{color}
|
||||||
|
\\definecolor{fg}{rgb}{%s}
|
||||||
|
\\definecolor{bg}{rgb}{%s}
|
||||||
|
\\pagecolor{bg}
|
||||||
|
\\usepackage{polyglossia}
|
||||||
|
""" % (fg_color_gr, bg_color_gr))
|
||||||
|
polyglossia = True
|
||||||
|
continue
|
||||||
success = 1
|
success = 1
|
||||||
# Package order: color should be loaded before preview
|
|
||||||
# Preview options: add the options lyx and tightpage
|
# Preview options: add the options lyx and tightpage
|
||||||
tmp.write(r"""
|
previewopts = match.group(1)
|
||||||
|
if not polyglossia:
|
||||||
|
tmp.write(r"""
|
||||||
\usepackage{color}
|
\usepackage{color}
|
||||||
\definecolor{fg}{rgb}{%s}
|
\definecolor{fg}{rgb}{%s}
|
||||||
\definecolor{bg}{rgb}{%s}
|
\definecolor{bg}{rgb}{%s}
|
||||||
@ -241,8 +260,15 @@ def legacy_latex_file(latex_file, fg_color, bg_color):
|
|||||||
\g@addto@macro\preview{\begingroup\color{bg}\special{ps::clippath fill}\color{fg}}
|
\g@addto@macro\preview{\begingroup\color{bg}\special{ps::clippath fill}\color{fg}}
|
||||||
\g@addto@macro\endpreview{\endgroup}
|
\g@addto@macro\endpreview{\endgroup}
|
||||||
\makeatother
|
\makeatother
|
||||||
""" % (fg_color_gr, bg_color_gr, match.group(1)))
|
""" % (fg_color_gr, bg_color_gr, previewopts))
|
||||||
|
else:
|
||||||
|
tmp.write(r"""
|
||||||
|
\usepackage[%s,tightpage]{preview}
|
||||||
|
\makeatletter
|
||||||
|
\g@addto@macro\preview{\begingroup\color{bg}\special{ps::clippath fill}\color{fg}}
|
||||||
|
\g@addto@macro\endpreview{\endgroup}
|
||||||
|
\makeatother
|
||||||
|
""" % previewopts)
|
||||||
if success:
|
if success:
|
||||||
copyfileobj(tmp, open(latex_file,"wb"), 1)
|
copyfileobj(tmp, open(latex_file,"wb"), 1)
|
||||||
|
|
||||||
|
@ -57,6 +57,9 @@ What's new
|
|||||||
- Do not let the natbibapa module overwrite what the class or other packages
|
- Do not let the natbibapa module overwrite what the class or other packages
|
||||||
add to the preamble.
|
add to the preamble.
|
||||||
|
|
||||||
|
- Assure the color package is loaded before polyglossia in preview snippets
|
||||||
|
This fixes preview image generation with polyglossia and bidi (bug 10716).
|
||||||
|
|
||||||
|
|
||||||
* LYX2LYX
|
* LYX2LYX
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user