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
(cherry picked from commit 33bfbf89c4)
This commit is contained in:
Juergen Spitzmueller 2018-04-08 19:02:01 +02:00
parent 9df09d8cba
commit 1eceb1c574
10 changed files with 122 additions and 14 deletions

View File

@ -768,10 +768,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()
@ -923,7 +923,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 "%%" ""' ])
@ -973,13 +973,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 "%%" ""'])

View File

@ -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
@ -2515,6 +2516,35 @@ value
format:
\end_layout
\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
@ -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

View File

@ -1989,6 +1989,25 @@ key=value
\begin_layout Labeling
\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
@ -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

View File

@ -4319,6 +4319,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);
Graph::EdgePath::const_iterator it = path.begin();
Graph::EdgePath::const_iterator en = path.end();
for (; it != en; ++it)

View File

@ -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"))

View File

@ -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)
{

View File

@ -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

View File

@ -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;

View File

@ -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,";

View File

@ -107,6 +107,8 @@ What's new
- Set correct path to (biblatex) bibliography databases that are entered
relative to child documents (bug 11105).
- Load hyperref with a suitable driver (bug 6418).
* LYX2LYX