Commit Graph

49 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
a20477993b Preview: do not overwrite fg/bg color names that beamer uses
Rename them to lyxfg/lyxbg

Fixes bug #12563.
2022-10-08 16:42:55 +02:00
Pavel Sanda
79f321d0f5 pyupgrade related fixes to python scripts #2.
Patch from Jose.
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg217790.html
2022-07-31 20:08:44 +02:00
Enrico Forestieri
92c4bb4682 Amend bd6d09fc
Was forgetting this.
2020-03-22 22:03:49 +01:00
Enrico Forestieri
bd6d09fc98 Fix Python 3 issues when generating preview snippets
The log file generated by latex can contain strings encoded in
whatever supported encoding. Instead of guessing the encoding,
it is better to open it in binary mode and then performing the
necessary comparisons as "bytes". In order to do this, the
strings are encoded in utf8, so that, for example, b"pythön" is
encoded as "pyth\xc3\xb6n" (7 bytes). Of course, this means that
we can only successfully perform comparisons with ascii strings.
However, this is what we actually do, as we only search for
ascii strings in the log file.
2020-03-14 17:19:08 +01:00
Juergen Spitzmueller
7945ba0cb0 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.
2017-07-11 10:03:03 +02:00
Enrico Forestieri
7c14ff94e3 Fix bug #10718
Due to the peculiarities of Windows, it may happen that
pdftocairo is built without png support when compiled on this
platform. Unless explicitly requested (maybe for some peculiar
application and certainly not for usual distros), this is
highly improbable to occur on other platforms.
2017-07-09 22:27:06 +02:00
José Matos
376cb6763f python3: fix the preview framework to work with both python 2 and 3 (part 4)
Remove support for python 1.x (really)

This code has not been used for a long time, probably never, since some code
above requires at least python 2.4 to work.

I got to this code by running futurize from python-future. There are no
significant warnings, mostly are related with the division but since
we are dividing floats there is no change between python 2 and 3.
2017-05-12 10:01:48 +01:00
José Matos
c546977c6e python3: fix the preview framework to work with both python 2 and 3 (part 2) 2017-05-11 15:50:08 +01:00
José Matos
11f2a59ce9 python3: fix the preview framework to work with both python 2 and 3 2017-05-09 11:20:34 +01:00
Georg Baum
d0aa7d24ab Make scripts python3 compatible
Again using 2to3 and manual checking
2016-06-08 20:02:33 +02:00
Enrico Forestieri
3c3cb777d6 Missing bits from 07169c7b
Sorry, was forgetting this.
2015-06-03 18:43:27 +02:00
Enrico Forestieri
07169c7be2 Report how many preview snippets fail.
Instead of warning about latex problems that, most probably, are worked
around by the script, report how many preview snippets were not produced.
2015-06-03 17:57:09 +02:00
Enrico Forestieri
3924030e82 Fix some preview issues reported on the devel list.
* Provide for vector fonts only if needed.
* Make sure microtype doesn't throw a trantum in dvi mode.
* Use correct macro definition in preview insets.
2015-06-03 00:24:54 +02:00
Enrico Forestieri
d3eae5b9c7 Do not show previews of snippets that produce latex errors 2015-04-30 00:37:05 +02:00
Enrico Forestieri
ca921fd650 Correctly indicate the failing converter
If epstopdf fails, pdftocairo is not called but the warning points
the finger to it. Also correctly indicate the failing file.
2015-04-29 16:20:27 +02:00
Enrico Forestieri
d44b0a19cb Amend 75f7eafd
Was forgetting this last bit from 64e0c558. Also give a message such
that the user is informed that not everything is lost if latex fails.
With this, the previews are generated also when the document directly
specifies a specific pdf output format.
2015-04-29 13:59:28 +02:00
Enrico Forestieri
75f7eafd65 Try even harder to obtain an instant preview
This is a followup commit to 691fdea3 and restores the behavior of the
script as it was intended before 64e0c558, other than taking into account
possible inclusion of files that only pdflatex can process and the
possibility of multiple defined math macros.
The instant previews in the math manual now work again.
2015-04-29 12:32:54 +02:00
Enrico Forestieri
c9b553fd2f Use pdftocairo (if available) for instant preview.
If pdftocairo is detected, it is used for generating bitmaps in the
legacy method route in preference to ghostscript. This is justified
by the fact that the conversion is 4 to 5 times faster and the
quality of the generated images is superior.
2015-04-27 21:37:26 +02:00
Enrico Forestieri
890b9a53cb Fix bug #7850 (Preview of inline math misaligned) 2015-04-26 19:08:16 +02:00
Richard Heck
64e0c5589c Return an error if LaTeX is unable to compile the file. 2014-04-21 11:51:57 -04:00
Richard Heck
f9de88c53c Remove the shebang line from our python scripts, per Jose's suggestion.
Fedora ships these chmod 644 and has never seen a problem. The advantage
to doing this is that it better controls what version of python we are
using to launch the script, and it will reveal if we're somehow somewhere
not controlling that properly.
2014-01-28 12:52:16 -05:00
Julien Rioux
ec1e52ca91 Add gswin64c as possible executable in legacy_lyxpreview2ppm.py (#7938).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40595 a592a061-630c-0410-9148-cb99ea01b6c8
2012-01-10 13:50:11 +00:00
Julien Rioux
35b580fb30 lyxpreview: Simplify the color handling.
Let's have this in trunk for testing. The real difference maker
when it comes to color is whether we use dvipng or ghostscript.

For dvipng:

  - The color info is passed as command-line arguments.

  - The tightpage option is not necessary, and since it adds
    ps specials to the output, we shouldn't use it.

For ghostscript:

  - The color info needs to be in the latex file.

  - The foreground color is set for each preview inset.

  - The background color is set by \pagecolor in the preamble,
    which is understood by pdflatex, but ignored in dvips mode.
    Thus dvips is handled with a ps special.

  - The tightpage option is necessary to crop the images.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39797 a592a061-630c-0410-9148-cb99ea01b6c8
2011-10-03 16:43:33 +00:00
Julien Rioux
13b1277cd2 lyxpreview: Handle bibtex-generated references and bibliography.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39795 a592a061-630c-0410-9148-cb99ea01b6c8
2011-10-03 16:35:27 +00:00
Enrico Forestieri
e75302bbce Fix another thinko from r38243.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39773 a592a061-630c-0410-9148-cb99ea01b6c8
2011-09-27 07:28:12 +00:00
Julien Rioux
45280f6bb5 Refine the lyxpreview legacy conversion (the ghostscript one).
- Break up steps 1, 2 and 3 from the legacy preview mechanism.
    These are really separate steps.

      1) Add color info, run latex
      2) Run dvips
      3) Run ghostscript

  - In the case of pdf output, skip step 2 and go directly to step 3.
  - Make sure that we fall back to the legacy conversion whenever we can.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39661 a592a061-630c-0410-9148-cb99ea01b6c8
2011-09-11 18:23:41 +00:00
Julien Rioux
bb55234cac Better error and progress messages for lyxpreview.
Introduce --debug and --verbose flags to control output. Also, use the
python subprocess module to capture stderr from external commands, thus
bumping the python requirement to version 2.4 or later.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39660 a592a061-630c-0410-9148-cb99ea01b6c8
2011-09-11 18:23:29 +00:00
Julien Rioux
675f233f34 Some clean up of the lyxpreview code.
Move some common variables to lyxpreview_tools. Otherwise,
add a few variable names, making it easier to track things.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39656 a592a061-630c-0410-9148-cb99ea01b6c8
2011-09-11 18:22:29 +00:00
Julien Rioux
2dfa11904f Stylictic-only changes to lyxpreview.
Whitespace and line endings only, in preparation for some serious work.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39655 a592a061-630c-0410-9148-cb99ea01b6c8
2011-09-11 18:22:12 +00:00
Pavel Sanda
f9f7c4a4bd Mostly documentation for the pythonic part of instant preview.
Patch from Ale.
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg167220.html


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38256 a592a061-630c-0410-9148-cb99ea01b6c8
2011-04-05 14:54:38 +00:00
Julien Rioux
adf6faf4d4 revert r37696 and apply a fallback mechanism to pdflatex
when latex fails with a preview. Fixes bug #7303 (IP fails with hyperref).
Patch by Ale with suggestions from Enrico

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38243 a592a061-630c-0410-9148-cb99ea01b6c8
2011-04-04 14:33:45 +00:00
Enrico Forestieri
46cb01a5e0 Fix bug #6720 (Better error handling of instant preview)
Patch from Ale revised by me.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37274 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-20 23:39:08 +00:00
Jürgen Spitzmüller
a2906cb877 ** proper implementation of pLaTeX by Tetsuya Makimura and me, fixes many remaining problems and bugs with language "japanese" (bugs 4863, 4290, 4700 and partially 4697) **
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26200 a592a061-630c-0410-9148-cb99ea01b6c8
2008-08-18 17:26:09 +00:00
Jürgen Spitzmüller
01c71419d9 *** Extend preview scripts to also handle PDF output (bug 2165) ***
* src/PreviewLoader.cpp:
	- add conditions for preview with pdf output

* lib/scripts/legacy_lyxpreview2ppm.py:
	- if no dvi preview file is available, check for a PDF file
	  and process that, if found
	- also produce png output, if requested.

* lib/scripts/lyxpreview2bitmap.py:
	- if no dvi preview file is available, check for a PDF file
	  and process that, if found

*  lib/scripts/lyxpreview_tools.py:
	- move some common functions here

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25419 a592a061-630c-0410-9148-cb99ea01b6c8
2008-07-02 14:42:04 +00:00
Uwe Stöhr
1c55d1fc77 configure.py, legacy_lyxpreview2ppm.py, lyxpreview2bitmap.py: check also for "platex" (Japanese variant of "latex"); patch by Koji
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21136 a592a061-630c-0410-9148-cb99ea01b6c8
2007-10-22 23:55:13 +00:00
José Matox
37dc5aeabe Convert python scripts to utf-8.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14565 a592a061-630c-0410-9148-cb99ea01b6c8
2006-08-08 10:42:59 +00:00
Bo Peng
2ae2c0db71 Remove hardcoded option -tt from python scripts
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14478 a592a061-630c-0410-9148-cb99ea01b6c8
2006-07-17 19:41:32 +00:00
Georg Baum
4ae87a3bb8 Call python with the -tt switch to make mixed tab/space indentation an error
* src/support/os.[Ch]
	(python): new function, return the python command

	* lib/lyx2lyx/lyx_1_5.py
	(revert_font_settings): replace tabs with spaces

The rest is simply s/python/python -tt/ and
s/"python"/lyx::support::os::python()/ where appropriate.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14270 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-30 13:54:01 +00:00
Jean-Marc Lasgouttes
5bad987680 bug 2167: previews badly placed when ascent or descent is 0
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13273 a592a061-630c-0410-9148-cb99ea01b6c8
2006-02-24 14:24:17 +00:00
Angus Leeming
c302740b9b J�rgen S's fix to bug 1817.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10468 a592a061-630c-0410-9148-cb99ea01b6c8
2005-09-21 09:22:18 +00:00
Angus Leeming
f8be560c1f Use gswin32c rather than gswin32 on Windows.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10072 a592a061-630c-0410-9148-cb99ea01b6c8
2005-06-16 13:15:09 +00:00
Angus Leeming
0a1fc13eff Do not quote the name of the executable when spawning an external process.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9921 a592a061-630c-0410-9148-cb99ea01b6c8
2005-05-08 14:11:55 +00:00
José Matox
6b440f84ca Replace os.getenv(x) by os.environ[x] for compatibility with old python versions.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9063 a592a061-630c-0410-9148-cb99ea01b6c8
2004-10-08 09:19:54 +00:00
Angus Leeming
f907db6a82 Move common code into a 'tools' file.
Implementation is as similar as possible to the well-tested code in the
1.3.x tree.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8878 a592a061-630c-0410-9148-cb99ea01b6c8
2004-08-09 11:31:18 +00:00
Angus Leeming
3e34d6f23c Append ".exe" to the name of the searched-for program on Win32.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8765 a592a061-630c-0410-9148-cb99ea01b6c8
2004-05-19 14:56:33 +00:00
Angus Leeming
2e66a01e8f Search for "gswin32" also when looking for ghostscript.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8760 a592a061-630c-0410-9148-cb99ea01b6c8
2004-05-18 07:40:18 +00:00
José Matox
fc09056ccc fix wrong point for writing in temporary file
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8733 a592a061-630c-0410-9148-cb99ea01b6c8
2004-05-04 09:42:24 +00:00
José Matox
19c9cb3799 fix bug with python 2.3 and
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8726 a592a061-630c-0410-9148-cb99ea01b6c8
2004-05-03 13:45:59 +00:00
Angus Leeming
a2e688065a Re-enable preview generation using dvips, gs and pnmcrop.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8675 a592a061-630c-0410-9148-cb99ea01b6c8
2004-04-19 18:12:23 +00:00