summaryrefslogtreecommitdiff
blob: d546851612fe170d1353fd23cddace32656aff26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff --git a/lib/scripts/legacy_lyxpreview2ppm.py b/lib/scripts/legacy_lyxpreview2ppm.py
index be242cc..3125006 100644
--- a/lib/scripts/legacy_lyxpreview2ppm.py
+++ b/lib/scripts/legacy_lyxpreview2ppm.py
@@ -172,11 +172,18 @@ def legacy_latex_file(latex_file, fg_color, bg_color, bg_color_gr):
     use_preview_dvi_re = re.compile("(\s*\\\\usepackage\[[^]]+)(dvips\]{preview})")
     use_preview_pdf_re = re.compile("(\s*\\\\usepackage\[[^]]+)(pdftex\]{preview})")
 
+    do_not_color_pictures_re = re.compile("(\\includegraphics)")
+
     tmp = mkstemp()
 
     success = 0
     try:
         for line in open(latex_file, 'r').readlines():
+            match = do_not_color_pictures_re.search(line)
+            if match != None:
+               tmp.write("\colorbox{white}{" + line + "}\n")
+               continue
+
             match = use_preview_dvi_re.match(line)
             if match == None:
                 match = use_preview_pdf_re.match(line)
@@ -192,7 +199,7 @@ def legacy_latex_file(latex_file, fg_color, bg_color, bg_color_gr):
 
             success = 1
             tmp.write("%stightpage,%s\n" \
-                      "  \\AtBeginDocument{\\AtBeginDvi{%%\n" \
+                      "  \\usepackage{color}\n\\AtBeginDocument{\\AtBeginDvi{%%\n" \
                       "  \\special{!userdict begin/bop-hook{//bop-hook exec\n" \
                       "  <%s%s>{255 div}forall setrgbcolor\n" \
                       "  clippath fill setrgbcolor}bind def end}}}\n" \