mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Allow quotes in PDF text properties
PDF properties (Author, Title...) need to be quoted properly when writing (normal operation and tex2lyx). Also, reading them requires to use Lexer::getString() directly, because >> uses next(), which does not handle escapes. Fixes bug #9830.
This commit is contained in:
parent
9594f6fc2d
commit
a5822a2976
@ -61,13 +61,13 @@ void PDFOptions::writeFile(ostream & os) const
|
||||
return;
|
||||
|
||||
if (!title.empty() )
|
||||
os << "\\pdf_title \"" << title << "\"\n";
|
||||
os << "\\pdf_title " << Lexer::quoteString(title) << '\n';
|
||||
if (!author.empty())
|
||||
os << "\\pdf_author \"" << author << "\"\n";
|
||||
os << "\\pdf_author " << Lexer::quoteString(author) << '\n';
|
||||
if (!subject.empty())
|
||||
os << "\\pdf_subject \"" << subject << "\"\n";
|
||||
os << "\\pdf_subject " << Lexer::quoteString(subject) << '\n';
|
||||
if (!keywords.empty())
|
||||
os << "\\pdf_keywords \"" << keywords << "\"\n";
|
||||
os << "\\pdf_keywords " << Lexer::quoteString(keywords) << '\n';
|
||||
|
||||
|
||||
os << "\\pdf_bookmarks " << convert<string>(bookmarks) << '\n';
|
||||
@ -85,7 +85,7 @@ void PDFOptions::writeFile(ostream & os) const
|
||||
os << "\\pdf_pagemode " << pagemode << '\n';
|
||||
|
||||
if (!quoted_options.empty())
|
||||
os << "\\pdf_quoted_options \"" << quoted_options << "\"\n";
|
||||
os << "\\pdf_quoted_options " << Lexer::quoteString(quoted_options) << '\n';
|
||||
}
|
||||
|
||||
|
||||
@ -211,13 +211,25 @@ string PDFOptions::readToken(Lexer &lex, string const & token)
|
||||
if (token == "\\use_hyperref") {
|
||||
lex >> use_hyperref;
|
||||
} else if (token == "\\pdf_title") {
|
||||
lex >> title;
|
||||
if (lex.isOK()) {
|
||||
lex.next(true);
|
||||
title = lex.getString();
|
||||
}
|
||||
} else if (token == "\\pdf_author") {
|
||||
lex >> author;
|
||||
if (lex.isOK()) {
|
||||
lex.next(true);
|
||||
author = lex.getString();
|
||||
}
|
||||
} else if (token == "\\pdf_subject") {
|
||||
lex >> subject;
|
||||
if (lex.isOK()) {
|
||||
lex.next(true);
|
||||
subject = lex.getString();
|
||||
}
|
||||
} else if (token == "\\pdf_keywords") {
|
||||
lex >> keywords;
|
||||
if (lex.isOK()) {
|
||||
lex.next(true);
|
||||
keywords = lex.getString();
|
||||
}
|
||||
} else if (token == "\\pdf_bookmarks") {
|
||||
lex >> bookmarks;
|
||||
} else if (token == "\\pdf_bookmarksnumbered") {
|
||||
@ -239,8 +251,10 @@ string PDFOptions::readToken(Lexer &lex, string const & token)
|
||||
} else if (token == "\\pdf_pagemode") {
|
||||
lex >> pagemode;
|
||||
} else if (token == "\\pdf_quoted_options") {
|
||||
lex >> quoted_options;
|
||||
lyxerr << "Q_O=" << quoted_options << endl;
|
||||
if (lex.isOK()) {
|
||||
lex.next(true);
|
||||
quoted_options = lex.getString();
|
||||
}
|
||||
} else {
|
||||
return token;
|
||||
}
|
||||
|
@ -1164,13 +1164,13 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
|
||||
<< "\\use_hyperref " << h_use_hyperref << '\n';
|
||||
if (h_use_hyperref == "true") {
|
||||
if (!h_pdf_title.empty())
|
||||
os << "\\pdf_title \"" << h_pdf_title << "\"\n";
|
||||
os << "\\pdf_title " << Lexer::quoteString(h_pdf_title) << '\n';
|
||||
if (!h_pdf_author.empty())
|
||||
os << "\\pdf_author \"" << h_pdf_author << "\"\n";
|
||||
os << "\\pdf_author " << Lexer::quoteString(h_pdf_author) << '\n';
|
||||
if (!h_pdf_subject.empty())
|
||||
os << "\\pdf_subject \"" << h_pdf_subject << "\"\n";
|
||||
os << "\\pdf_subject " << Lexer::quoteString(h_pdf_subject) << '\n';
|
||||
if (!h_pdf_keywords.empty())
|
||||
os << "\\pdf_keywords \"" << h_pdf_keywords << "\"\n";
|
||||
os << "\\pdf_keywords " << Lexer::quoteString(h_pdf_keywords) << '\n';
|
||||
os << "\\pdf_bookmarks " << h_pdf_bookmarks << "\n"
|
||||
"\\pdf_bookmarksnumbered " << h_pdf_bookmarksnumbered << "\n"
|
||||
"\\pdf_bookmarksopen " << h_pdf_bookmarksopen << "\n"
|
||||
@ -1183,7 +1183,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
|
||||
if (!h_pdf_pagemode.empty())
|
||||
os << "\\pdf_pagemode " << h_pdf_pagemode << '\n';
|
||||
if (!h_pdf_quoted_options.empty())
|
||||
os << "\\pdf_quoted_options \"" << h_pdf_quoted_options << "\"\n";
|
||||
os << "\\pdf_quoted_options " << Lexer::quoteString(h_pdf_quoted_options) << '\n';
|
||||
}
|
||||
os << "\\papersize " << h_papersize << "\n"
|
||||
<< "\\use_geometry " << h_use_geometry << '\n';
|
||||
|
Loading…
Reference in New Issue
Block a user