]> git.lyx.org Git - features.git/commitdiff
DocBook: fix encoding issues with complex ERT.
authorThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 31 Jul 2020 15:34:58 +0000 (17:34 +0200)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 31 Jul 2020 18:17:38 +0000 (20:17 +0200)
autotests/export/docbook/deutsches_ert.lyx [new file with mode: 0644]
autotests/export/docbook/deutsches_ert.xml [new file with mode: 0644]
src/insets/InsetERT.cpp
src/insets/InsetQuotes.cpp
src/output_docbook.cpp

diff --git a/autotests/export/docbook/deutsches_ert.lyx b/autotests/export/docbook/deutsches_ert.lyx
new file mode 100644 (file)
index 0000000..e9e692d
--- /dev/null
@@ -0,0 +1,271 @@
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 598
+\begin_document
+\begin_header
+\save_transient_properties true
+\origin unavailable
+\textclass scrbook
+\begin_preamble
+% Präambel nicht verändern!!!
+%
+% Die Präambel stellt sicher, dass das Benutzerhandbuch korrekt
+% in die Formate pdf, ps und dvi exportiert werden kann.
+% Wenn Probleme beim Exportieren auftreten, können Sie sich
+% an das LyX-Dokumentationsteam wenden.
+% EMail: lyx-docs@lists.lyx.org
+
+% the pages of the TOC are numbered roman
+% and a PDF-bookmark for the TOC is added
+\pagenumbering{roman}
+\let\myTOC\tableofcontents
+\renewcommand{\tableofcontents}{%
+ \pdfbookmark[1]{\contentsname}{}
+ \myTOC
+ \cleardoublepage
+ \pagenumbering{arabic}}
+
+% extra space for tables
+\newcommand{\extratablespace}[1]{\noalign{\vskip#1}}
+
+% Improve line breaking
+\tolerance 1414
+\hbadness 1414
+\emergencystretch 1.5em
+\hfuzz 0.3pt
+\end_preamble
+\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading
+\use_default_options false
+\begin_modules
+logicalmkup
+theorems-ams
+theorems-ams-extended
+multicol
+shapepar
+\end_modules
+\maintain_unincluded_children no
+\language ngerman
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "lmodern" "default"
+\font_sans "lmss" "default"
+\font_typewriter "lmtt" "default"
+\font_math "auto" "auto"
+\font_default_family default
+\use_non_tex_fonts false
+\font_sc false
+\font_roman_osf false
+\font_sans_osf false
+\font_typewriter_osf false
+\font_sf_scale 100 100
+\font_tt_scale 100 100
+\use_microtype false
+\use_dash_ligatures true
+\graphics default
+\default_output_format pdf2
+\output_sync 0
+\bibtex_command default
+\index_command makeindex
+\paperfontsize 12
+\spacing single
+\use_hyperref true
+\pdf_title "Handbuchergänzungen"
+\pdf_author "LyX Team, deutsche Übersetzung: Hartmut Haase"
+\pdf_subject "LyX-Dokumentation, Benutzerhandbuch, Ergänzungen"
+\pdf_keywords "LyX, Dokumentation"
+\pdf_bookmarks true
+\pdf_bookmarksnumbered true
+\pdf_bookmarksopen false
+\pdf_bookmarksopenlevel 1
+\pdf_breaklinks false
+\pdf_pdfborder false
+\pdf_colorlinks true
+\pdf_backref false
+\pdf_pdfusetitle false
+\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false"
+\papersize a4
+\use_geometry false
+\use_package amsmath 1
+\use_package amssymb 1
+\use_package cancel 1
+\use_package esint 1
+\use_package mathdots 1
+\use_package mathtools 1
+\use_package mhchem 1
+\use_package stackrel 1
+\use_package stmaryrd 1
+\use_package undertilde 1
+\cite_engine basic
+\cite_engine_type default
+\biblio_style plain
+\use_bibtopic false
+\use_indices false
+\paperorientation portrait
+\suppress_date false
+\justification true
+\use_refstyle 0
+\use_minted 0
+\use_lineno 0
+\notefontcolor #0000ff
+\index Stichwortverzeichnis
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 1
+\math_indentation default
+\math_numbering_side default
+\quotes_style german
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 2
+\paperpagestyle headings
+\tablestyle default
+\tracking_changes false
+\output_changes false
+\change_bars false
+\postpone_fragile_content false
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict true
+\docbook_table_output 0
+\end_header
+
+\begin_body
+
+\begin_layout Title
+Erweiterte \SpecialChar LyX
+ Features
+\end_layout
+
+\begin_layout Subtitle
+Version 2.3.x
+\end_layout
+
+\begin_layout Author
+vom \SpecialChar LyX
+-Team
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+
+\size normal
+Übersetzung und Bearbeitung: 
+\size default
+Hartmut
+\noun on
+\noun default
+Haase (
+\noun on
+HHa
+\noun default
+, bis März 2010),
+\begin_inset Newline newline
+\end_inset
+
+Jürgen Spitzmüller (Version 2.3.x, 2017)
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset CommandInset toc
+LatexCommand tableofcontents
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Chapter
+Einleitung
+\end_layout
+
+\begin_layout Standard
+Wählen Sie hierfür 
+\family sans
+Dokument\SpecialChar menuseparator
+Einstellungen\SpecialChar menuseparator
+LaTeX-Vorspann.
+
+\family default
+ Dies öffnet ein Editierfenster, in das Sie Ihre bevorzugten Befehle schreiben
+ können.
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+Das Editierverhalten in diesem Fenster ist spezifisch, also erwarten Sie
+ nicht, dass die \SpecialChar LyX
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+\begin_inset Quotes gld
+\end_inset
+
+=
+\end_layout
+
+\end_inset
+
+Tastenkombinationen darin funktionieren.
+\end_layout
+
+\end_inset
+
+ \SpecialChar LyX
+ fügt alles im 
+\family sans
+LaTeX-Vorspann
+\family default
+-Fenster zu seinem eingebauten Vorspann hinzu.
+ Bevor Sie Ihre eigenen Deklarationen zum Vorspann hinzufügen, sollten Sie
+ prüfen, ob \SpecialChar LyX
+ das nicht bereits unterstützt (Erinnern Sie sich, was wir über
+ das Rad noch einmal erfinden sagten?).
+ Außerdem: 
+\emph on
+stellen Sie sicher, dass Ihre Vorspannzeilen richtig sind
+\emph default
+.
+ \SpecialChar LyX
+ prüft das nicht.
+ Wenn der Vorspann fehlerhaft ist, bekommen Sie sehr wahrscheinlich die
+ Fehlermeldung 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+Missing 
+\backslash
+begin{document}
+\end_layout
+
+\end_inset
+
+.
+ Sollten Sie diese jemals bekommen, prüfen Sie Ihren Vorspann!.
+\begin_inset CommandInset index_print
+LatexCommand printindex
+type "idx"
+name "Stichwortverzeichnis"
+literal "false"
+
+\end_inset
+
+
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/docbook/deutsches_ert.xml b/autotests/export/docbook/deutsches_ert.xml
new file mode 100644 (file)
index 0000000..e5933ae
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- This DocBook file was created by LyX 2.4.0dev
+  See http://www.lyx.org/ for more information -->
+<book xml:lang="de_DE" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2">
+<info>
+<title>Erweiterte LyX Features</title>
+<subtitle>Version 2.3.x</subtitle>
+<author><personname>vom LyX-Team<footnote>Übersetzung und Bearbeitung: Hartmut<person> Haase (<person>HHa, bis März 2010),Jürgen Spitzmüller (Version 2.3.x, 2017)</person></person></footnote></personname></author>
+</info>
+<chapter>
+<chapter>Einleitung</chapter>
+<para>Wählen Sie hierfür <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;LaTeX-Vorspann. Dies öffnet ein Editierfenster, in das Sie Ihre bevorzugten Befehle schreiben können.<footnote><para>Das Editierverhalten in diesem Fenster ist spezifisch, also erwarten Sie nicht, dass die LyX<!-- &#8222;= -->Tastenkombinationen darin funktionieren.</para>
+</footnote> LyX fügt alles im <emphasis role='sans'>LaTeX-Vorspann-Fenster zu seinem eingebauten Vorspann hinzu. Bevor Sie Ihre eigenen Deklarationen zum Vorspann hinzufügen, sollten Sie prüfen, ob LyX das nicht bereits unterstützt (Erinnern Sie sich, was wir über das Rad noch einmal erfinden sagten?). Außerdem: <emphasis>stellen Sie sicher, dass Ihre Vorspannzeilen richtig sind. LyX prüft das nicht. Wenn der Vorspann fehlerhaft ist, bekommen Sie sehr wahrscheinlich die Fehlermeldung Missing \begin{document}. Sollten Sie diese jemals bekommen, prüfen Sie Ihren Vorspann!.</emphasis></emphasis></emphasis></para>
+</chapter>
+
+</book>
\ No newline at end of file
index eb4567175e5bff28c97fce6e0ef41374d8ac782a..57fc1e3419ebc1c9f281ebe76dde0aa93dae38a5 100644 (file)
@@ -28,6 +28,7 @@
 #include "xml.h"
 #include "ParagraphParameters.h"
 #include "Paragraph.h"
+#include <output_docbook.h>
 
 #include "support/docstream.h"
 #include "support/gettext.h"
@@ -91,22 +92,22 @@ int InsetERT::plaintext(odocstringstream & os,
 }
 
 
-void InsetERT::docbook(XMLStream & xs, OutputParams const &) const
+void InsetERT::docbook(XMLStream & xs, OutputParams const & runparams) const
 {
-       // FIXME can we do the same thing here as for LaTeX?
-       ParagraphList::const_iterator par = paragraphs().begin();
-       ParagraphList::const_iterator end = paragraphs().end();
+       auto const begin = paragraphs().begin();
+       auto par = begin;
+       auto const end = paragraphs().end();
 
        xs << XMLStream::ESCAPE_NONE << "<!-- ";
        while (par != end) {
-               pos_type siz = par->size();
-               for (pos_type i = 0; i < siz; ++i) {
-                       xs << par->getChar(i);
-               }
+               // Recreate the logic of makeParagraphs in output_docbook.cpp, but much simplified: never open <para>
+               // in an ERT, use simple line breaks.
+               par->simpleDocBookOnePar(buffer(), xs, runparams, text().outerFont(distance(begin, par)));
+
+               // New line after each paragraph of the ERT, save the last one.
                ++par;
-               if (par != end) {
+               if (par != end)
                        xs << "\n";
-               }
        }
        xs << XMLStream::ESCAPE_NONE << " -->";
 }
index 5358bbaf19d64deb9430f396ac4ad328cb23425c..b90f1c27dda850ae94e035260994dc5ec9ba11f2 100644 (file)
@@ -538,74 +538,8 @@ docstring InsetQuotesParams::getHTMLQuote(char_type c) const
 
 docstring InsetQuotesParams::getXMLQuote(char_type c) const
 {
-       string res;
-
-       switch (c){
-               case 0x201a: // ,
-                       res = "&#8218;";
-                       break;
-               case 0x2019: // '
-                       res = "&#8217;";
-                       break;
-               case 0x2018: // `
-                       res = "&#8216;";
-                       break;
-               case 0x2039: // <
-                       res = "&#8249;";
-                       break;
-               case 0x203a: // >
-                       res = "&#8250;";
-                       break;
-               case 0x0027: // ' (plain)
-                       res = "&#x27;";
-                       break;
-               case 0x201e: // ,,
-                       res = "&#8222;";
-                       break;
-               case 0x201d: // ''
-                       res = "&#8221;";
-                       break;
-               case 0x201c: // ``
-                       res = "&#8220;";
-                       break;
-               case 0x00ab: // <<
-                       res = "&#171;";
-                       break;
-               case 0x00bb: // >>
-                       res = "&#187;";
-                       break;
-               case 0x0022: // "
-                       res = "&#34;";
-                       break;
-               case 0x300c: // LEFT CORNER BRACKET
-                       res = "&#x300c;";
-                       break;
-               case 0x300d: // RIGHT CORNER BRACKET
-                       res = "&#x300d;";
-                       break;
-               case 0x300e: // LEFT WHITE CORNER BRACKET
-                       res = "&#x300e;";
-                       break;
-               case 0x300f: // RIGHT WHITE CORNER BRACKET
-                       res = "&#x300f;";
-                       break;
-               case 0x300a: // LEFT DOUBLE ANGLE BRACKET
-                       res = "&#x300a;";
-                       break;
-               case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
-                       res = "&#x300b;";
-                       break;
-               case 0x3008: // LEFT ANGLE BRACKET
-                       res = "&#x3008;";
-                       break;
-               case 0x3009: // RIGHT ANGLE BRACKET
-                       res = "&#x3009;";
-                       break;
-               default:
-                       break;
-       }
-
-       return from_ascii(res);
+       // Directly output the character Unicode form.
+       return from_ascii("&#" + to_string(c) + ";");
 }
 
 
@@ -1024,6 +958,7 @@ docstring InsetQuotes::getQuoteEntity(bool isHTML) const {
                        (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
        docstring res = isHTML ? quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_)) :
                                        quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_));
+
        // in French, thin spaces are added inside double guillemets
        if (prefixIs(context_lang_, "fr")
            && level_ == InsetQuotesParams::PrimaryQuotes
@@ -1032,9 +967,9 @@ docstring InsetQuotes::getQuoteEntity(bool isHTML) const {
                || style == InsetQuotesParams::SwissQuotes)) {
                // THIN SPACE (U+2009)
                docstring const thin_space = from_ascii("&#x2009;");
-               if (side_ == InsetQuotesParams::OpeningQuote)
+               if (side_ == InsetQuotesParams::OpeningQuote) // Open quote: space after
                        res += thin_space;
-               else
+               else // Close quote: space before
                        res = thin_space + res;
        }
        return res;
index b37cc7ac68c135b2dc67e22dfbe6d4e1be4a59f2..eb1a9a5a5f5cbcb8459fe1815135b5e084ff478f 100644 (file)
@@ -455,9 +455,8 @@ ParagraphList::const_iterator makeParagraphs(
                                ((open_par && (!runparams.docbook_in_par || nextpar != pend))
                                || (!open_par && runparams.docbook_in_par && par == pbegin && nextpar != pend));
 
-               if (open_par) {
+               if (open_par)
                        openParTag(xs, lay);
-               }
 
                par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0);