commit 33bfbf89c4267ed8e37fad1681adce4cd5dfddf4
Author: Juergen Spitzmueller <[email protected]>
Date: Sun Apr 8 19:02:01 2018 +0200
Load hyperref with a suitable driver
This is mandatory for some features (such as bookmarks,pdfusetitle)
to work, and only a handful of drivers can be auto-detected by hyperref.
Fixes: #6418
---
lib/configure.py | 12 ++++----
lib/doc/Customization.lyx | 62 +++++++++++++++++++++++++++++++++++++++--
lib/doc/de/Customization.lyx | 27 ++++++++++++++++--
src/Buffer.cpp | 1 +
src/BufferParams.cpp | 4 +-
src/Converter.cpp | 14 +++++++++
src/Converter.h | 6 ++++
src/OutputParams.h | 4 +++
src/PDFOptions.cpp | 4 +++
9 files changed, 120 insertions(+), 14 deletions(-)
diff --git a/lib/configure.py b/lib/configure.py
index df07e46..34916d8 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -772,10 +772,10 @@ def checkFormatEntries(dtl_tools):
def checkConverterEntries():
''' Check all converters (\converter entries) '''
checkProg('the pdflatex program', ['pdflatex $$i'],
- rc_entry = [ r'\converter pdflatex pdf2 "%%"
"latex=pdflatex"' ])
+ rc_entry = [ r'\converter pdflatex pdf2 "%%"
"latex=pdflatex,hyperref-driver=pdftex"' ])
checkProg('XeTeX', ['xelatex $$i'],
- rc_entry = [ r'\converter xetex pdf4 "%%"
"latex=xelatex"' ])
+ rc_entry = [ r'\converter xetex pdf4 "%%"
"latex=xelatex,hyperref-driver=xetex"' ])
checkLuatex()
@@ -927,7 +927,7 @@ def checkConverterEntries():
rc_entry = [ r'\converter rtf html "%%" ""' ])
# Do not define a converter to pdf6, ps is a pure export format
checkProg('a PS to PDF converter', ['ps2pdf $$i $$o'],
- rc_entry = [ r'\converter ps pdf "%%" ""' ])
+ rc_entry = [ r'\converter ps pdf "%%"
"hyperref-driver=dvips"' ])
#
checkProg('a PS to TXT converter', ['pstotext $$i > $$o'],
rc_entry = [ r'\converter ps text2 "%%" ""' ])
@@ -977,13 +977,13 @@ def checkConverterEntries():
rc_entry = [ r'\converter dvi text4 "%%" ""' ])
#
checkProg('a DVI to PS converter', ['dvips -o $$o $$i'],
- rc_entry = [ r'\converter dvi ps "%%" ""' ])
+ rc_entry = [ r'\converter dvi ps "%%"
"hyperref-driver=dvips"' ])
#
checkProg('a DVI to cropped EPS converter', ['dvips -E -o $$o $$i'],
rc_entry = [ r'\converter dvi eps3 "%%" ""' ])
#
- checkProg('a DVI to PDF converter', ['dvipdfmx -o $$o $$i', 'dvipdfm -o
$$o $$i'],
- rc_entry = [ r'\converter dvi pdf3 "%%" ""' ])
+ checkProg('a DVI to PDF converter', ['dvipdfmx', 'dvipdfm'],
+ rc_entry = [ r'\converter dvi pdf3 "%% -o $$o $$i"
"hyperref-driver=%%"' ])
#
checkProg('a fax program', ['kdeprintfax $$i', 'ksendfax $$i', 'hylapex
$$i'],
rc_entry = [ r'\converter ps fax "%%" ""'])
diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index 40b32b4..7b81ff8 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -124,11 +124,12 @@ logicalmkup
\papercolumns 1
\papersides 2
\paperpagestyle headings
-\tracking_changes false
+\tracking_changes true
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict true
+\author -712698321 "Jürgen Spitzmüller"
\end_header
\begin_body
@@ -2517,6 +2518,35 @@ value
\begin_layout Labeling
\labelwidthstring 00.00.0000
+
+\change_inserted -712698321 1523206314
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1523206193
+hyperref-driver
+\end_layout
+
+\end_inset
+
+ The name of the driver that needs to be loaded with the
+\family sans
+hyperref
+\family default
+ package for this converter.
+ The loading of the correct driver is necessary to get some PDF-specific
+ features.
+ See the
+\family sans
+hyperref
+\family default
+ manual for details.
+\end_layout
+
+\begin_layout Labeling
+\labelwidthstring 00.00.0000
\begin_inset Flex Code
status collapsed
@@ -2622,8 +2652,34 @@ $$b
\end_layout
\begin_layout Standard
-None of these last three are presently used in any of the converters that
- are installed with \SpecialChar LyX
+
+\change_inserted -712698321 1523206384
+A suitable hyperref-driver is set for some converters that are installed
+ with \SpecialChar LyX
+.
+
+\change_deleted -712698321 1523206388
+None of these
+\change_inserted -712698321 1523206389
+The
+\change_unchanged
+ last three
+\change_inserted -712698321 1523206400
+ flags, however,
+\change_unchanged
+ are presently
+\change_inserted -712698321 1523206407
+not
+\change_unchanged
+used in any of the
+\change_inserted -712698321 1523206437
+pre-installed
+\change_unchanged
+converters
+\change_deleted -712698321 1523206442
+ that are installed with \SpecialChar LyX
+
+\change_unchanged
.
\end_layout
diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx
index 270e385..0420dad 100644
--- a/lib/doc/de/Customization.lyx
+++ b/lib/doc/de/Customization.lyx
@@ -1990,6 +1990,25 @@ key=value
\labelwidthstring 00.00.0000
\family typewriter
+hyperref-driver
+\family default
+Der Name der Treiberdatei, die für diesen Konverter mit dem
+\family sans
+Hyperref
+\family default
+-Paket geladen werden soll.
+ Dies ist nötig, um bestimmte PDF-Features verwenden zu können.
+ Konsultieren Sie das
+\family sans
+Hyperref
+\family default
+-Handbuch für Einzelheiten.
+\end_layout
+
+\begin_layout Labeling
+\labelwidthstring 00.00.0000
+
+\family typewriter
parselog
\family default
Wenn das gesetzt ist, werden der Standardfehler des Konverters in die Datei
@@ -2082,9 +2101,11 @@ index
\end_layout
\begin_layout Standard
-Keines dieser Flags wird zur Zeit in einem Konverter benutzt, der zusammen
- mit \SpecialChar LyX
- installiert wird.
+Ein passender Hyperref-Treiber wird für einige mit \SpecialChar LyX
+ installierten Konverter
+ definiert.
+ Die zuletzt aufgeführten drei Flags hingegen werden zurzeit von keinem
+ der vorinstallierten Konverter verwendet.
\end_layout
\begin_layout Standard
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 09dfff9..867c4c5 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -4267,6 +4267,7 @@ Buffer::ExportStatus Buffer::doExport(string const &
target, bool put_in_tempdir
return ExportNoPathToFormat;
}
runparams.flavor = converters.getFlavor(path, this);
+ runparams.hyperref_driver = converters.getHyperrefDriver(path);
for (auto const & edge : path)
if (theConverters().get(edge).nice()) {
need_nice_file = true;
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index a28f34a..f0be844 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -2094,8 +2094,8 @@ bool BufferParams::writeLaTeX(otexstream & os,
LaTeXFeatures & features,
OutputParams tmp_params = features.runparams();
pdfoptions().writeLaTeX(tmp_params, os,
features.isProvided("hyperref"));
- // correctly break URLs with hyperref and dvi output
- if (features.runparams().flavor == OutputParams::LATEX
+ // correctly break URLs with hyperref and dvi/ps output
+ if (features.runparams().hyperref_driver == "dvips"
&& features.isAvailable("breakurl"))
os << "\\usepackage{breakurl}\n";
} else if (features.isRequired("nameref"))
diff --git a/src/Converter.cpp b/src/Converter.cpp
index d433f83..37977b4 100644
--- a/src/Converter.cpp
+++ b/src/Converter.cpp
@@ -136,6 +136,8 @@ void Converter::readFlags()
nice_ = true;
else if (flag_name == "needauth")
need_auth_ = true;
+ else if (flag_name == "hyperref-driver")
+ href_driver_ = flag_value;
}
if (!result_dir_.empty() && result_file_.empty())
result_file_ = "index." + theFormats().extension(to_);
@@ -283,6 +285,18 @@ OutputParams::FLAVOR Converters::getFlavor(Graph::EdgePath
const & path,
}
+string Converters::getHyperrefDriver(Graph::EdgePath const & path)
+{
+ for (Graph::EdgePath::const_iterator cit = path.begin();
+ cit != path.end(); ++cit) {
+ Converter const & conv = converterlist_[*cit];
+ if (!conv.hyperref_driver().empty())
+ return conv.hyperref_driver();
+ }
+ return string();
+}
+
+
bool Converters::checkAuth(Converter const & conv, string const & doc_fname,
bool use_shell_escape)
{
diff --git a/src/Converter.h b/src/Converter.h
index 8f63aba..e144ca2 100644
--- a/src/Converter.h
+++ b/src/Converter.h
@@ -79,6 +79,8 @@ public:
std::string const result_file() const { return result_file_; }
///
std::string const parselog() const { return parselog_; }
+ ///
+ std::string const hyperref_driver() const { return href_driver_; }
private:
///
@@ -114,6 +116,8 @@ private:
trivstring result_file_;
/// Command to convert the program output to a LaTeX log file format
trivstring parselog_;
+ /// The hyperref driver
+ trivstring href_driver_;
};
@@ -159,6 +163,8 @@ public:
///
OutputParams::FLAVOR getFlavor(Graph::EdgePath const & path,
Buffer const * buffer = 0);
+ ///
+ std::string getHyperrefDriver(Graph::EdgePath const & path);
/// Flags for converting files
enum ConversionFlags {
/// No special flags
diff --git a/src/OutputParams.h b/src/OutputParams.h
index 1631dac..ff94912 100644
--- a/src/OutputParams.h
+++ b/src/OutputParams.h
@@ -172,6 +172,10 @@ public:
*/
std::string index_command;
+ /** Hyperref driver
+ */
+ std::string hyperref_driver;
+
/** Line length to use with plaintext or LaTeX export.
*/
size_type linelen;
diff --git a/src/PDFOptions.cpp b/src/PDFOptions.cpp
index a4d23ee..b030baa 100644
--- a/src/PDFOptions.cpp
+++ b/src/PDFOptions.cpp
@@ -97,6 +97,10 @@ void PDFOptions::writeLaTeX(OutputParams & runparams,
otexstream & os,
string opt;
string hyperset;
+ // Driver needed by specific converters
+ if (!runparams.hyperref_driver.empty())
+ opt += runparams.hyperref_driver + ",";
+
// since LyX uses unicode, also set the PDF strings to unicode strings
with the
// hyperref option "unicode"
opt += "unicode=true,";