[LyX/master] XHTML: in InsetGraphics, use the bounding box that LyX computes for each image instead of using the scale.

2024-05-20 Thread Thibaut Cuvelier
commit ce5f84ff02e04a10d345776571ae0a2439b09e8f
Author: Thibaut Cuvelier 
Date:   Mon May 20 16:59:46 2024 +0200

XHTML: in InsetGraphics, use the bounding box that LyX computes for each 
image instead of using the scale.
---
 src/insets/InsetGraphics.cpp | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp
index d4d0fd7049..1d19507d00 100644
--- a/src/insets/InsetGraphics.cpp
+++ b/src/insets/InsetGraphics.cpp
@@ -1086,17 +1086,24 @@ docstring InsetGraphics::xhtml(XMLStream & xs, 
OutputParams const & op) const
bool const haveheight = !params().height.zero();
if (havewidth || haveheight) {
if (havewidth)
-   imgstyle += "width: " + params().width.asHTMLString() + 
";";
+   imgstyle = "width: " + params().width.asHTMLString() + 
";";
if (haveheight)
imgstyle += " height: " + 
params().height.asHTMLString() + ";";
} else if (params().scale != "100") {
-   // The `scale` CSS property is supposed to be used for 
responsive
-   // designs, but it behaves mostly as LyX. The only problem is 
that
-   // the image's bounding box is not scaled. (As opposed to a 
width,
-   // which is a percentage of the HTML container: the meaning of 
the
-   // percentage is completely different, but the bounding box has 
the
-   // right size.)
-   imgstyle = "scale: " + params().scale + "%;";
+   // Use the scale on the bounding box.
+   char* endPtr;
+   double const scale = strtod(params().scale.c_str(), );
+   if (*endPtr == '\0') { // Parsing was possible.
+   Length width = params().width;
+   width.value(scale * width.value());
+   Length height = params().height;
+   height.value(scale * height.value());
+
+   imgstyle = "width: " + width.asHTMLString() + "; ";
+   imgstyle += "height: " + height.asHTMLString() + ";";
+   }
+   // Otherwise, failure to parse the scale: no information to 
pass on
+   // to the HTML output.
}
if (!imgstyle.empty())
imgstyle = "style='" + imgstyle + "' ";
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] XHTML: export paragraph IDs also for list items, but not for the opening tag of the list.

2024-05-19 Thread Thibaut Cuvelier
commit 2d86b881242c3ea4756af28f8458aeb7cbfa6822
Author: Thibaut Cuvelier 
Date:   Mon May 20 03:21:00 2024 +0200

XHTML: export paragraph IDs also for list items, but not for the opening 
tag of the list.

The IDs are used to link to specific elements (for instance, the User's 
guide nomenclature).

The beginning of the list ( or ) has the same magic ID as the first 
item of the list.
---
 src/output_xhtml.cpp | 33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp
index c83fdeed82..4cb1d2f7c0 100644
--- a/src/output_xhtml.cpp
+++ b/src/output_xhtml.cpp
@@ -210,25 +210,32 @@ inline void closeLabelTag(XMLStream & xs, Layout const & 
lay)
 }
 
 
-inline void openItemTag(XMLStream & xs, Layout const & lay)
+inline void openItemTag(XMLStream & xs, Layout const & lay,
+std::string const & parlabel)
 {
if (lay.htmlitemtag() != "NONE") {
-   xs << xml::StartTag(lay.htmlitemtag(), lay.htmlitemattr(), 
true);
+   string attrs = lay.htmlitemattr();
+   if (!parlabel.empty())
+   attrs += " id='" + parlabel + "'";
+   xs << xml::StartTag(lay.htmlitemtag(), attrs, true);
}
 }
 
 
 void openItemTag(XMLStream & xs, Layout const & lay,
- ParagraphParameters const & params)
+ ParagraphParameters const & params,
+ std::string const & parlabel)
 {
if (lay.htmlitemtag() != "NONE") {
// FIXME Are there other things we should handle here?
string const align = alignmentToCSS(params.align());
if (align.empty()) {
-   openItemTag(xs, lay);
+   openItemTag(xs, lay, parlabel);
return;
}
string attrs = lay.htmlGetAttrString() + " style='text-align: " 
+ align + ";'";
+   if (!parlabel.empty())
+   attrs += " id='" + parlabel + "'";
xs << xml::StartTag(lay.htmlitemtag(), attrs);
}
 }
@@ -411,7 +418,8 @@ ParagraphList::const_iterator makeEnvironment(Buffer const 
& buf,
ParagraphList::const_iterator const begin = text.paragraphs().begin();
ParagraphList::const_iterator par = pbegin;
Layout const & bstyle = par->layout();
-   depth_type const origdepth = pbegin->params().depth();
+   depth_type const origdepth = par->params().depth();
+   string const parId = bstyle.htmlitemtag().empty() ? par->magicLabel() : 
"";
 
// open tag for this environment
if ((bstyle.labeltype == LABEL_ENUMERATE || bstyle.labeltype == 
LABEL_ITEMIZE)
@@ -444,12 +452,12 @@ ParagraphList::const_iterator makeEnvironment(Buffer 
const & buf,
// not a valid enumdepth...
break;
}
-   openParTag(xs, bstyle,
-  string( isenum ? "lyxenum" : "lyxitem" ) + " 
"
-   + to_utf8(enumcounter), 
pbegin->magicLabel());
+   const string cssClass = string(isenum ? "lyxenum" : "lyxitem") 
+ " "
+ + to_utf8(enumcounter);
+   openParTag(xs, bstyle, cssClass, parId);
}
else
-   openParTag(xs, bstyle, pbegin->magicLabel());
+   openParTag(xs, bstyle, parId);
xs << xml::CR();
 
// we will on occasion need to remember a layout from before.
@@ -491,7 +499,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const 
& buf,
pos_type sep = 0;
bool const labelfirst = style.htmllabelfirst();
if (!labelfirst)
-   openItemTag(xs, style, par->params());
+   openItemTag(xs, style, par->params(), 
par->magicLabel());
 
// label output
if (style.labeltype != LABEL_NO_LABEL &&
@@ -529,7 +537,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const 
& buf,
} // end label output
 
if (labelfirst)
-   openItemTag(xs, style, par->params());
+   openItemTag(xs, style, par->params(), 
par->magicLabel());
 
docstring deferred = 
par->simpleLyXHTMLOnePar(buf, xs, runparams,
text.outerFont(distance(begin, par

[LyX/master] XHTML: fix typo in comment.

2024-05-19 Thread Thibaut Cuvelier
commit a4f675a0408f4af13a7ea3a7856763dac8175e9a
Author: Thibaut Cuvelier 
Date:   Mon May 20 03:11:41 2024 +0200

XHTML: fix typo in comment.
---
 src/output_xhtml.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp
index f01b0b8e62..c83fdeed82 100644
--- a/src/output_xhtml.cpp
+++ b/src/output_xhtml.cpp
@@ -422,7 +422,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const 
& buf,
// (We also do not deal with 'resume' counters, though I'm not 
sure that can
// be done at all in HTML.)
 
-   // Code adapated from Buffer::Impl::setLabel
+   // Code adapted from Buffer::Impl::setLabel
bool const isenum = bstyle.labeltype == LABEL_ENUMERATE;
docstring enumcounter = bstyle.counter.empty() ?
( isenum ? from_ascii("enum") : 
from_ascii("lyxitem") ) :
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetGraphics: use the `scale` CSS property instead of `width` with percentages.

2024-05-19 Thread Thibaut Cuvelier
commit f2660d172c3f38e2dad1f32d7b3b4d953e2efb8a
Author: Thibaut Cuvelier 
Date:   Mon May 20 01:09:43 2024 +0200

InsetGraphics: use the `scale` CSS property instead of `width` with 
percentages.

The effect is closer to what LyX offers. Previously, the percentage was of 
the HTML container (often, the whole page), meaning that images were oversized. 
Now, the scale is respected in the same way as LyX, but its bounding box is 
off. Overall, the result is better, but not what users expect.
---
 src/insets/InsetGraphics.cpp | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp
index b092ff44ff..d4d0fd7049 100644
--- a/src/insets/InsetGraphics.cpp
+++ b/src/insets/InsetGraphics.cpp
@@ -1086,15 +1086,17 @@ docstring InsetGraphics::xhtml(XMLStream & xs, 
OutputParams const & op) const
bool const haveheight = !params().height.zero();
if (havewidth || haveheight) {
if (havewidth)
-   imgstyle += "width:" + params().width.asHTMLString() + 
";";
+   imgstyle += "width: " + params().width.asHTMLString() + 
";";
if (haveheight)
-   imgstyle += " height:" + params().height.asHTMLString() 
+ ";";
+   imgstyle += " height: " + 
params().height.asHTMLString() + ";";
} else if (params().scale != "100") {
-   // Note that this will not have the same effect as in LaTeX 
export:
-   // There, the image will be scaled from its original size. 
Here, the
-   // percentage will be interpreted by the browser, and the image 
will
-   // be scaled to a percentage of the window size.
-   imgstyle = "width:" + params().scale + "%;";
+   // The `scale` CSS property is supposed to be used for 
responsive
+   // designs, but it behaves mostly as LyX. The only problem is 
that
+   // the image's bounding box is not scaled. (As opposed to a 
width,
+   // which is a percentage of the HTML container: the meaning of 
the
+   // percentage is completely different, but the bounding box has 
the
+   // right size.)
+   imgstyle = "scale: " + params().scale + "%;";
}
if (!imgstyle.empty())
imgstyle = "style='" + imgstyle + "' ";
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Make comment clearer.

2024-05-18 Thread Thibaut Cuvelier
commit e3f2b10842cdc808e9f2bf235692f283009d3734
Author: Thibaut Cuvelier 
Date:   Sat May 18 19:38:52 2024 +0200

Make comment clearer.
---
 src/insets/InsetInfo.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp
index cfb5b7eafc..4ed6142430 100644
--- a/src/insets/InsetInfo.cpp
+++ b/src/insets/InsetInfo.cpp
@@ -1563,7 +1563,7 @@ void xhtmlShortcutInfo(XMLStream & xs, const 
InsetInfoParams & params) {
sequence = theTopLevelKeymap().printBindings(func, 
KeySequence::ForGui);
seq_untranslated = theTopLevelKeymap().printBindings(func, 
KeySequence::ForGui, true);
}
-   // No other possible case.
+   // No other possible case (`return` at the beginning of the function 
otherwise).
 
Language const * tryguilang = 
languages.getFromCode(Messages::guiLanguage());
// Some info insets use the language of the GUI (if available)
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetInfo: no need to output + explicitly in a shortcut, it is already contained in the sequence.

2024-05-18 Thread Thibaut Cuvelier
commit 7cfe36e6aa4460ae8641cd36f4aab5f013390326
Author: Thibaut Cuvelier 
Date:   Sat May 18 19:41:44 2024 +0200

InsetInfo: no need to output + explicitly in a shortcut, it is already 
contained in the sequence.
---
 src/insets/InsetInfo.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp
index 4ed6142430..7ed5662b10 100644
--- a/src/insets/InsetInfo.cpp
+++ b/src/insets/InsetInfo.cpp
@@ -1589,9 +1589,6 @@ void xhtmlShortcutInfo(XMLStream & xs, const 
InsetInfoParams & params) {
} else {
xs << c;
}
-
-   if (i > 0 && i + 1 < sequence.length())
-   xs << from_ascii("+");
}
 
xml::closeTag(xs, "bdo", "inline");
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] Amend 16660d12.

2024-04-05 Thread Thibaut Cuvelier
commit fd378450755b698cc3ddb1a8d14e8b78d19c57a2
Author: Thibaut Cuvelier 
Date:   Thu Mar 21 21:32:45 2024 +0100

Amend 16660d12.

The previous commit introduced wrong behaviours for <>. The new code 
carefully escapes what needs to be escaped from LaTeX, using the now-standard 
XML tools (XMLStream).
---
 autotests/export/xhtml/math_output_latex.lyx   |  2 +-
 autotests/export/xhtml/math_output_latex.xhtml |  2 +-
 src/insets/InsetLabel.cpp  |  2 +
 src/mathed/InsetMathHull.cpp   | 62 --
 src/mathed/InsetMathHull.h |  4 +-
 5 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/autotests/export/xhtml/math_output_latex.lyx 
b/autotests/export/xhtml/math_output_latex.lyx
index 59d77d2f9b..7c49de59f6 100644
--- a/autotests/export/xhtml/math_output_latex.lyx
+++ b/autotests/export/xhtml/math_output_latex.lyx
@@ -100,7 +100,7 @@ The problem occurs when adding a label.
 \begin_layout Standard
 \begin_inset Formula 
 \begin{equation}
-x^{2}\label{eq:1}
+x^{2}<\log x\label{eq:1}
 \end{equation}
 
 \end_inset
diff --git a/autotests/export/xhtml/math_output_latex.xhtml 
b/autotests/export/xhtml/math_output_latex.xhtml
index cec2d5ba0d..713def3459 100644
--- a/autotests/export/xhtml/math_output_latex.xhtml
+++ b/autotests/export/xhtml/math_output_latex.xhtml
@@ -22,7 +22,7 @@ div.standard {
 Math formula output as raw LaTeX
 The problem occurs when adding a 
label. https://www.lyx.org/trac/ticket/13048
 
-x^{2}(1)
+x^{2}<\log 
x(1)
 
 
 
diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp
index 1ca8ea08ae..ab5a5e1716 100644
--- a/src/insets/InsetLabel.cpp
+++ b/src/insets/InsetLabel.cpp
@@ -380,6 +380,8 @@ void InsetLabel::docbook(XMLStream & xs, OutputParams const 
& runparams) const
 
 docstring InsetLabel::xhtml(XMLStream & xs, OutputParams const &) const
 {
+   // Print the label as an HTML anchor, so that an external link can 
point to this equation.
+   // (URL: FILE.html#EQ-ID.)
// FIXME XHTML
// Unfortunately, the name attribute has been deprecated, so we have to 
use
// id here to get the document to validate as XHTML 1.1. This will 
cause a
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index bb368b3b93..94d293870d 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2574,35 +2574,56 @@ void InsetMathHull::mathmlize(MathMLStream & ms) const
 }
 
 
-void InsetMathHull::mathAsLatex(TeXMathStream & os) const
+docstring InsetMathHull::mathAsLatex() const
 {
-   MathEnsurer ensurer(os, false);
bool const havenumbers = haveNumbers();
bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
 
if (!havetable) {
+   odocstringstream ls;
+   otexrowstream ots(ls);
+   TeXMathStream os(ots, false, true, TeXMathStream::wsPreview);
+   ModeSpecifier specifier(os, MATH_MODE);
+   MathEnsurer ensurer(os, false);
+
os << cell(index(0, 0));
-   return;
+   return ls.str();
}
 
-   os << "";
+   odocstringstream ods;
+   XMLStream xs(ods);
+
+   xs << xml::StartTag("table", "class='mathtable'");
for (row_type row = 0; row < nrows(); ++row) {
-   os << "";
+   xs << xml::StartTag("tr");
for (col_type col = 0; col < ncols(); ++col) {
-   os << "";
-   os << cell(index(row, col));
-   os << "";
+   xs << xml::StartTag("td", "class='math'");
+
+   odocstringstream ls;
+   otexrowstream ots(ls);
+   TeXMathStream os(ots, false, true, 
TeXMathStream::wsPreview);
+   ModeSpecifier specifier(os, MATH_MODE);
+   MathEnsurer ensurer(os, false);
+
+   os << cell(index(0, 0));
+   // ls.str() contains a raw LaTeX string, which might 
require some encoding before being valid XML.
+   xs << ls.str();
+
+   xs << xml::EndTag("td");
}
if (havenumbers) {
-   os << "";
+   xs << xml::StartTag("td");
docstring const & num = numbers_[row];
-   if (!num.empty())
-   os << '(' << num << ')';
-   os << "";
+   if (!num.empty()) {
+   xs << '(' << num << ')';
+ 

[LyX features/biginset] MathML in HTML: don't escape <> for a raw LaTeX output.

2024-04-05 Thread Thibaut Cuvelier
commit 16660d12b4333f6486259048dec2b0a2e48a64d9
Author: Thibaut Cuvelier 
Date:   Thu Mar 21 00:29:23 2024 +0100

MathML in HTML: don't escape <> for a raw LaTeX output.

In some cases (I only found numbered equations), the LaTeX output still has 
a bit of HTML. For numbered equations, using \tag{X} (as suggested in 
https://www.lyx.org/trac/ticket/13048) would require fiddling with the output. 
KaTeX doesn't support \label. This patch is probably the easiest and most 
reliable fix.

Fixes https://www.lyx.org/trac/ticket/13048.
---
 autotests/export/xhtml/math_output_latex.lyx   | 112 +
 autotests/export/xhtml/math_output_latex.xhtml |  28 +++
 src/mathed/InsetMathHull.cpp   |   3 +-
 3 files changed, 142 insertions(+), 1 deletion(-)

diff --git a/autotests/export/xhtml/math_output_latex.lyx 
b/autotests/export/xhtml/math_output_latex.lyx
new file mode 100644
index 00..59d77d2f9b
--- /dev/null
+++ b/autotests/export/xhtml/math_output_latex.lyx
@@ -0,0 +1,112 @@
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 620
+\begin_document
+\begin_header
+\save_transient_properties true
+\origin unavailable
+\textclass article
+\use_default_options true
+\maintain_unincluded_children no
+\language american
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "default" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "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 default
+\output_sync 0
+\bibtex_command default
+\index_command default
+\float_placement class
+\float_alignment class
+\paperfontsize default
+\spacing single
+\use_hyperref false
+\papersize default
+\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 1
+\use_formatted_ref 0
+\use_minted 0
+\use_lineno 0
+\index Index
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style english
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tablestyle default
+\tracking_changes false
+\output_changes false
+\change_bars false
+\postpone_fragile_content true
+\html_math_output 3
+\html_css_as_file 0
+\html_be_strict false
+\docbook_table_output 0
+\docbook_mathml_prefix 1
+\end_header
+
+\begin_body
+
+\begin_layout Title
+Math formula output as raw LaTeX
+\end_layout
+
+\begin_layout Standard
+The problem occurs when adding a label.
+ https://www.lyx.org/trac/ticket/13048
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula 
+\begin{equation}
+x^{2}\label{eq:1}
+\end{equation}
+
+\end_inset
+
+
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/xhtml/math_output_latex.xhtml 
b/autotests/export/xhtml/math_output_latex.xhtml
new file mode 100644
index 00..cec2d5ba0d
--- /dev/null
+++ b/autotests/export/xhtml/math_output_latex.xhtml
@@ -0,0 +1,28 @@
+
+http://www.w3.org/1999/xhtml; lang="en-US">
+
+
+Math formula output as raw LaTeX
+
+/* Layout-provided Styles */
+h1.title {
+font-size: x-large;
+margin-bottom: 1ex;
+text-align: center;
+
+}
+div.standard {
+   margin-bottom: 2ex;
+}
+
+
+
+
+
+Math formula output as raw LaTeX
+The problem occurs when adding a 
label. https://www.lyx.org/trac/ticket/13048
+
+x^{2}(1)
+
+
+
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 2ba98b3d4d..bb368b3b93 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2729,7 +2729,8 @@ docstring InsetMathHull::xhtml(XMLStream & xs, 
OutputParams const & op) const
// probably should allow for some kind of customization here
string const tag = (getType() == hullSimple) ? "span" : "div";
xs << xml::StartTag(tag, "class='math'")
-  << latex
+  << XMLStream::ESCAPE_AND << latex // Don't escape <> tags: 
latex might contain them
+  // (typically, when there is a label).
   << xml::EndTag(tag)
   << xml::CR();
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] MathML: stop stretching all delimiters.

2024-04-05 Thread Thibaut Cuvelier
commit 8f820d7ccb0cb6129c8e3c1d495905d61db97355
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:40:16 2024 +0100

MathML: stop stretching all delimiters.

No form? Reference: https://w3c.github.io/mathml-core/#dfn-form. The MathML 
processor is smart enough to determine whether the delimiter is prefix or 
postfix.

No stretchy/symmetric/fence in all cases? Reference: 
https://w3c.github.io/mathml-core/#algorithm-for-determining-the-properties-of-an-embellished-operator
 and https://w3c.github.io/mathml-core/#operator-dictionary-human (example 
entry: U+0028). Delimiters have the right properties by default.
---
 src/mathed/InsetMathDelim.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index d32029b818..fab72db88d 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -190,15 +190,16 @@ void InsetMathDelim::mathematica(MathematicaStream & os) 
const
 void InsetMathDelim::mathmlize(MathMLStream & ms) const
 {
// Ignore the delimiter if: it is empty or only a space (one character).
+   const std::string attr = is_extracted_ ? "stretchy='false'" : "";
if (!left_.empty() && ((left_.size() == 1 && left_[0] != ' ') || 
left_.size() > 1)) {
ms << MTag("mrow")
-  << MTagInline("mo", "form='prefix' fence='true' stretchy='true' 
symmetric='true'")
+  << MTagInline("mo", attr)
   << convertDelimToXMLEscape(left_)
   << ETagInline("mo");
}
ms << cell(0);
if (!right_.empty() && ((right_.size() == 1 && right_[0] != ' ') || 
right_.size() > 1)) {
-   ms << MTagInline("mo", "form='postfix' fence='true' stretchy='true' 
symmetric='true'")
+   ms << MTagInline("mo", attr)
   << convertDelimToXMLEscape(right_)
   << ETagInline("mo")
   << ETag("mrow");
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] MathML: don't let the processor stretch operators when they are single characters for LyX.

2024-04-05 Thread Thibaut Cuvelier
commit 7e6597a5b47c22ed22966a75c149264dacd6e289
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 02:00:47 2024 +0100

MathML: don't let the processor stretch operators when they are single 
characters for LyX.

The main goal is to match TeX' behaviour. If you want stretchy operators, 
use InsetMathDelim / \left & \right. This patch will change the output in many 
files, but making the rendering much closer to that of TeX (which users should 
expect, due to LyX' roots in TeX).
---
 src/mathed/InsetMathChar.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index 71aba6f6f7..a642a5e6da 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -230,6 +230,8 @@ void InsetMathChar::octave(OctaveStream & os) const
 // mathalpha, then we'll treat it as an identifier, otherwise as an
 // operator.
 // Worst case: We get bad spacing, or bad italics.
+// In any case, never let MathML stretch a single character when it
+// is recognised as an operator, to match TeX' behaviour.
 void InsetMathChar::mathmlize(MathMLStream & ms) const
 {
std::string entity;
@@ -253,7 +255,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
}
 
if (!entity.empty()) {
-   ms << MTagInline("mo")
+   ms << MTagInline("mo", "stretchy='false'")
   << from_ascii(entity)
   << ETagInline("mo");
return;
@@ -262,7 +264,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
char const * type =
(isAlphaASCII(char_) || Encodings::isMathAlpha(char_))
? "mi" : "mo";
-   ms << MTagInline(type)
+   ms << MTagInline(type, std::string(type) == "mo" ? "stretchy='false'" : 
"")
   << char_type(char_)
   << ETagInline(type);
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] MathML: don't output delimiters in InsetMathBinom and InsetMathDelim if the delimiter is a space.

2024-04-05 Thread Thibaut Cuvelier
commit be03d699463fba896f90e3046b0814d527368771
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:30:48 2024 +0100

MathML: don't output delimiters in InsetMathBinom and
 InsetMathDelim if the delimiter is a space.
---
 src/mathed/InsetMathDelim.cpp | 23 ++-
 src/mathed/InsetMathFrac.cpp  | 21 +
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index 78d26fceea..d32029b818 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -189,15 +189,20 @@ void InsetMathDelim::mathematica(MathematicaStream & os) 
const
 
 void InsetMathDelim::mathmlize(MathMLStream & ms) const
 {
-   ms << MTag("mrow")
-  << MTagInline("mo", "form='prefix' fence='true' stretchy='true' 
symmetric='true'")
-  << convertDelimToXMLEscape(left_)
-  << ETagInline("mo")
-  << cell(0)
-  << MTagInline("mo", "form='postfix' fence='true' stretchy='true' 
symmetric='true'")
-  << convertDelimToXMLEscape(right_)
-  << ETagInline("mo")
-  << ETag("mrow");
+   // Ignore the delimiter if: it is empty or only a space (one character).
+   if (!left_.empty() && ((left_.size() == 1 && left_[0] != ' ') || 
left_.size() > 1)) {
+   ms << MTag("mrow")
+  << MTagInline("mo", "form='prefix' fence='true' stretchy='true' 
symmetric='true'")
+  << convertDelimToXMLEscape(left_)
+  << ETagInline("mo");
+   }
+   ms << cell(0);
+   if (!right_.empty() && ((right_.size() == 1 && right_[0] != ' ') || 
right_.size() > 1)) {
+   ms << MTagInline("mo", "form='postfix' fence='true' stretchy='true' 
symmetric='true'")
+  << convertDelimToXMLEscape(right_)
+  << ETagInline("mo")
+  << ETag("mrow");
+   }
 }
 
 
diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index f6f2f95b0a..b0ff55bc4d 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -768,15 +768,20 @@ void InsetMathBinom::mathmlize(MathMLStream & ms) const
rdelim = ']';
break;
}
-   ms << MTagInline("mo", "fence='true' stretchy='true' form='prefix'")
-  << ldelim
-  << ETagInline("mo")
-  << MTagInline("mfrac", "linethickness='0'")
+
+   if (ldelim != ' ') {
+   ms << MTagInline("mo", "fence='true' stretchy='true' form='prefix'")
+  << ldelim
+  << ETagInline("mo");
+   }
+   ms << MTagInline("mfrac", "linethickness='0'")
   << cell(0) << cell(1)
-   << ETagInline("mfrac")
-  << MTagInline("mo", "fence='true' stretchy='true' form='postfix'")
-  << rdelim
-  << ETagInline("mo");
+  << ETagInline("mfrac");
+   if (rdelim != ' ') {
+   ms << MTagInline("mo", "fence='true' stretchy='true' 
form='postfix'")
+  << rdelim
+  << ETagInline("mo");
+   }
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] Extract vert, langle, rangle in MathExtern like parentheses and brackets.

2024-04-05 Thread Thibaut Cuvelier
commit 9e6b810b37f28499a5573468ae61d68be0bb2e75
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:22:12 2024 +0100

Extract vert, langle, rangle in MathExtern like parentheses and brackets.

This patch is part of a series that aims at solving 
https://www.lyx.org/trac/ticket/12891. It is an excerpt of the patch that lynx 
published at https://www.lyx.org/trac/ticket/12270.
---
 src/mathed/MathExtern.cpp | 67 ++-
 1 file changed, 54 insertions(+), 13 deletions(-)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index b07c08b56e..e273aac791 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -292,6 +292,19 @@ bool testString(MathAtom const & at, char const * const 
str)
return testString(at, from_ascii(str));
 }
 
+
+bool testSymbol(MathAtom const & at, docstring const & name)
+{
+   return at->asSymbolInset() && at->asSymbolInset()->name() == name;
+}
+
+
+bool testSymbol(MathAtom const & at, char const * const name)
+{
+   return testSymbol(at, from_ascii(name));
+}
+
+
 // search end of nested sequence
 MathData::iterator endNestSearch(
MathData::iterator it,
@@ -523,12 +536,52 @@ MathAtom replaceBracketDelims(const MathData & ar)
 }
 
 
-// replace '('...')' and '['...']' sequences by a real InsetMathDelim
+bool testOpenVert(MathAtom const & at)
+{
+   return testSymbol(at, "lvert");
+}
+
+
+bool testCloseVert(MathAtom const & at)
+{
+   return testSymbol(at, "rvert");
+}
+
+
+MathAtom replaceVertDelims(const MathData & ar)
+{
+   return MathAtom(new InsetMathDelim(const_cast(ar.buffer()),
+   from_ascii("lvert"), from_ascii("rvert"), ar, true));
+}
+
+
+bool testOpenAngled(MathAtom const & at)
+{
+   return testSymbol(at, "langle");
+}
+
+
+bool testCloseAngled(MathAtom const & at)
+{
+   return testSymbol(at, "rangle");
+}
+
+
+MathAtom replaceAngledDelims(const MathData & ar)
+{
+   return MathAtom(new InsetMathDelim(const_cast(ar.buffer()),
+   from_ascii("langle"), from_ascii("rangle"), ar, true));
+}
+
+
+// replace '('...')', '['...']', '|'...'|', and '<'...'>' sequences by a real 
InsetMathDelim
 void extractDelims(MathData & ar)
 {
//lyxerr << "\nDelims from: " << ar << endl;
replaceNested(ar, testOpenParen, testCloseParen, replaceParenDelims);
replaceNested(ar, testOpenBracket, testCloseBracket, 
replaceBracketDelims);
+   replaceNested(ar, testOpenVert, testCloseVert, replaceVertDelims);
+   replaceNested(ar, testOpenAngled, testCloseAngled, replaceAngledDelims);
//lyxerr << "\nDelims to: " << ar << endl;
 }
 
@@ -622,18 +675,6 @@ void extractFunctions(MathData & ar, ExternalMath kind)
 // search integrals
 //
 
-bool testSymbol(MathAtom const & at, docstring const & name)
-{
-   return at->asSymbolInset() && at->asSymbolInset()->name() == name;
-}
-
-
-bool testSymbol(MathAtom const & at, char const * const name)
-{
-   return testSymbol(at, from_ascii(name));
-}
-
-
 bool testIntSymbol(MathAtom const & at)
 {
return testSymbol(at, from_ascii("int"));
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] Improve const correctness.

2024-04-05 Thread Thibaut Cuvelier
commit b1a4eb118cd3d271a35b2260cde077e21c62c32c
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:15:48 2024 +0100

Improve const correctness.
---
 src/mathed/MathExtern.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index d101904e83..b07c08b56e 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -295,7 +295,7 @@ bool testString(MathAtom const & at, char const * const str)
 // search end of nested sequence
 MathData::iterator endNestSearch(
MathData::iterator it,
-   MathData::iterator last,
+   const MathData::iterator& last,
TestItemFunc testOpen,
TestItemFunc testClose
 )
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] Memorise whether delims are extracted from MathExtern.

2024-04-05 Thread Thibaut Cuvelier
commit 93444892c504fdd7b8fdfbc7f2bf67f9b250eb82
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:07:25 2024 +0100

Memorise whether delims are extracted from MathExtern.

This patch is part of a series that aims at solving 
https://www.lyx.org/trac/ticket/12891. It should not change any output.
---
 src/mathed/InsetMathDelim.cpp | 12 ++--
 src/mathed/InsetMathDelim.h   |  6 ++
 src/mathed/MathExtern.cpp |  4 ++--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index 486ed97580..78d26fceea 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -45,13 +45,21 @@ static docstring convertDelimToLatexName(docstring const & 
name)
 
 InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l,
docstring const & r)
-   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0)
+   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0), 
is_extracted_(false)
 {}
 
 
 InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l, docstring 
const & r,
MathData const & ar)
-   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0)
+   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0), 
is_extracted_(false)
+{
+   cell(0) = ar;
+}
+
+
+InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l, docstring 
const & r,
+   MathData const & ar, bool const is_extracted)
+   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0), 
is_extracted_(is_extracted)
 {
cell(0) = ar;
 }
diff --git a/src/mathed/InsetMathDelim.h b/src/mathed/InsetMathDelim.h
index cad8da49de..3d8bd2ce36 100644
--- a/src/mathed/InsetMathDelim.h
+++ b/src/mathed/InsetMathDelim.h
@@ -27,6 +27,9 @@ public:
InsetMathDelim(Buffer * buf, docstring const & left, docstring const & 
right,
MathData const &);
///
+   InsetMathDelim(Buffer * buf, docstring const & left, docstring const & 
right,
+  MathData const &, bool const is_extracted);
+   ///
InsetMathDelim * asDelimInset() override { return this; }
///
InsetMathDelim const * asDelimInset() const override { return this; }
@@ -73,6 +76,9 @@ private:
Inset * clone() const override;
///
mutable int dw_;
+   /// Is it extracted by MathExtern routines? They try to extract as much
+   /// semantics from a raw LaTeX formula in terms of LyX insets.
+   bool const is_extracted_;
 };
 
 } // namespace lyx
diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index 22124cc13d..d101904e83 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -500,7 +500,7 @@ bool testCloseParen(MathAtom const & at)
 MathAtom replaceParenDelims(const MathData & ar)
 {
return MathAtom(new InsetMathDelim(const_cast(ar.buffer()),
-   from_ascii("("), from_ascii(")"), ar));
+   from_ascii("("), from_ascii(")"), ar, true));
 }
 
 
@@ -519,7 +519,7 @@ bool testCloseBracket(MathAtom const & at)
 MathAtom replaceBracketDelims(const MathData & ar)
 {
return MathAtom(new InsetMathDelim(const_cast(ar.buffer()),
-   from_ascii("["), from_ascii("]"), ar));
+   from_ascii("["), from_ascii("]"), ar, true));
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] Reduce code duplication.

2024-04-05 Thread Thibaut Cuvelier
commit 1680eaf5f0edeed089e2bdc2b539b80187b88d3c
Author: Thibaut Cuvelier 
Date:   Sun Mar 10 16:55:12 2024 +0100

Reduce code duplication.
---
 src/mathed/MathExtern.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index daf171981f..22124cc13d 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -630,7 +630,7 @@ bool testSymbol(MathAtom const & at, docstring const & name)
 
 bool testSymbol(MathAtom const & at, char const * const name)
 {
-   return at->asSymbolInset() && at->asSymbolInset()->name() == 
from_ascii(name);
+   return testSymbol(at, from_ascii(name));
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] MathML: consider ordinary and alphabetical characters as identifiers instead of operators.

2024-04-05 Thread Thibaut Cuvelier
commit 011c3d73c0c3137dcd67bf8bb09644ac064b2342
Author: Thibaut Cuvelier 
Date:   Sat Mar 9 20:59:12 2024 +0100

MathML: consider ordinary and alphabetical characters as identifiers 
instead of operators.

The goal is to consider all Greek letters as identifiers instead of 
operators.

Solves: https://www.lyx.org/trac/ticket/12948.
---
 .../export/docbook/mathml_greek_operators.lyx  | 112 +
 .../export/docbook/mathml_greek_operators.xml  |  20 
 src/mathed/MathParser.cpp  |   4 +-
 3 files changed, 135 insertions(+), 1 deletion(-)

diff --git a/autotests/export/docbook/mathml_greek_operators.lyx 
b/autotests/export/docbook/mathml_greek_operators.lyx
new file mode 100644
index 00..f7d2ce
--- /dev/null
+++ b/autotests/export/docbook/mathml_greek_operators.lyx
@@ -0,0 +1,112 @@
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 620
+\begin_document
+\begin_header
+\save_transient_properties true
+\origin unavailable
+\textclass article
+\use_default_options true
+\maintain_unincluded_children no
+\language american
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "default" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "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 default
+\output_sync 0
+\bibtex_command default
+\index_command default
+\float_placement class
+\float_alignment class
+\paperfontsize default
+\use_hyperref false
+\papersize default
+\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
+\use_bibtopic false
+\use_indices false
+\paperorientation portrait
+\suppress_date false
+\justification true
+\use_refstyle 1
+\use_formatted_ref 0
+\use_minted 0
+\use_lineno 0
+\index Index
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style english
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tablestyle default
+\tracking_changes false
+\output_changes false
+\change_bars false
+\postpone_fragile_content true
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict false
+\docbook_table_output 0
+\docbook_mathml_prefix 1
+\end_header
+
+\begin_body
+
+\begin_layout Title
+MathML:
+ all Greek letters are symbols,
+ none of them is an operator
+\end_layout
+
+\begin_layout Standard
+Issue:
+ https://www.lyx.org/trac/ticket/12948
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula 
+\[
+1\alpha2\Xi3
+\]
+
+\end_inset
+
+
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/docbook/mathml_greek_operators.xml 
b/autotests/export/docbook/mathml_greek_operators.xml
new file mode 100644
index 00..c5fc17c0b8
--- /dev/null
+++ b/autotests/export/docbook/mathml_greek_operators.xml
@@ -0,0 +1,20 @@
+
+
+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">
+MathML: all Greek letters are symbols, none of them is an 
operator
+Issue: https://www.lyx.org/trac/ticket/12948
+
+1\alpha2\Xi3
+
+ 
+
+ 1
+ 
+ 2
+ 
+ 3
+
+
+
+
\ No newline at end of file
diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp
index e94b6cea32..9b43da8cdd 100644
--- a/src/mathed/MathParser.cpp
+++ b/src/mathed/MathParser.cpp
@@ -2141,8 +2141,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
 // FIXME This will likely need some work.
 char const * latexkeys::MathMLtype() const
 {
-   if (extra == "mathord")
+   // Consider as identifier (mml:mi): ordinary and alphabetical 
characters.
+   if (extra == "mathord" || extra == "mathalpha")
return "mi";
+   // Consider as operators (mml:mo): everything else.
return "mo";
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] Simplify a loop with a for-each.

2024-04-05 Thread Thibaut Cuvelier
commit 1b11dfeca5c4e11585129221d966e84c5c775402
Author: Thibaut Cuvelier 
Date:   Sat Mar 9 20:46:54 2024 +0100

Simplify a loop with a for-each.

These loops were brought by C++11. The next step could be using std::any_of.
---
 src/mathed/MathSupport.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp
index 57e8c6ee4e..585320f11a 100644
--- a/src/mathed/MathSupport.cpp
+++ b/src/mathed/MathSupport.cpp
@@ -1070,10 +1070,10 @@ bool isAlphaSymbol(MathAtom const & at)
 
if (at->asFontInset()) {
MathData const & ar = at->asFontInset()->cell(0);
-   for (size_t i = 0; i < ar.size(); ++i) {
-   if (!(ar[i]->asCharInset() ||
- (ar[i]->asSymbolInset() &&
-  ar[i]->asSymbolInset()->isOrdAlpha(
+   for (const auto & i : ar) {
+   if (!(i->asCharInset() ||
+ (i->asSymbolInset() &&
+  i->asSymbolInset()->isOrdAlpha(
return false;
}
return true;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] DocBook: add missing mapping for AASTeX 6.3.

2024-04-05 Thread Thibaut Cuvelier
commit 04beccca4c7170273748e14827b8af62e5726b25
Author: Thibaut Cuvelier 
Date:   Sat Mar 9 15:09:45 2024 +0100

DocBook: add missing mapping for AASTeX 6.3.

The result is far from perfect, see the TODOs. The corresponding tests are 
still inverted.
---
 development/autotests/invertedTests |  2 ++
 lib/layouts/aastex6.layout  |  9 -
 lib/layouts/aastex62.layout | 12 +++-
 lib/layouts/aastex63.layout | 16 +---
 4 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/development/autotests/invertedTests 
b/development/autotests/invertedTests
index c88e67cda5..ec366b9745 100644
--- a/development/autotests/invertedTests
+++ b/development/autotests/invertedTests
@@ -412,6 +412,8 @@ export/doc(|/de|/es|/fr|/ja|/ru)/Additional_docbook5
 #   - AASTeX.
 export/export/docbook/bibliography_precooked_aastex_docbook5
 
export/(examples|templates)/Articles/American_Astronomical_Society_%28AASTeX_v._6.2%29_docbook5
+export/(examples|templates)/Articles/American_Astronomical_Society_%28AASTeX_v._6.3%29_docbook5
+export/(examples|templates)/Articles/American_Astronomical_Society_%28AASTeX_v._6.3.1%29_docbook5
 #   - Springer. (The svmono_light should still pass.)
 export/templates/Books/Springer.*/.*_docbook5
 !export/export/docbook/svmono_light_docbook5
diff --git a/lib/layouts/aastex6.layout b/lib/layouts/aastex6.layout
index c6ab5ea03f..3ae8486cce 100644
--- a/lib/layouts/aastex6.layout
+++ b/lib/layouts/aastex6.layout
@@ -44,7 +44,14 @@
 #
 # TODO: - support for new commands (see below)
 #   - aastex6.cls loads hyperref (with pre-set options) and url
-# -> option clash if "Use Hyerref" is selected in Document>Settings
+# -> option clash if "Use Hyperref" is selected in Document>Settings
+#   - in DocBook, the appendix is not output (not a standard LyX appendix
+# separator (needs a layout update)
+#   - in DocBook, the "Software" part should really be a section on its 
own,
+# but that would require a way to provide the section title within the
+# layout (needs a layout update)
+#   - in DocBook, the table notes are not supported at all (move the 
remarks
+# into the table cells instead of outputting tablenotemark in the 
cells?)
 
 Format 104
 
diff --git a/lib/layouts/aastex62.layout b/lib/layouts/aastex62.layout
index 5080cc06e8..5bfc03111e 100644
--- a/lib/layouts/aastex62.layout
+++ b/lib/layouts/aastex62.layout
@@ -48,7 +48,14 @@
 #
 # TODO: - support for new commands (see below)
 #   - aastex6.cls loads hyperref (with pre-set options) and url
-# -> option clash if "Use Hyerref" is selected in Document>Settings
+# -> option clash if "Use Hy^perref" is selected in Document>Settings
+#   - in DocBook, the appendix is not output (not a standard LyX appendix
+# separator (needs a layout update)
+#   - in DocBook, the "Software" part should really be a section on its 
own,
+# but that would require a way to provide the section title within the
+# layout (needs a layout update)
+#   - in DocBook, the table notes are not supported at all (move the 
remarks
+# into the table cells instead of outputting tablenotemark in the 
cells?)
 
 Format 104
 
@@ -231,6 +238,9 @@ Style Acknowledgments
LabelFont
Color   textlabel2
EndFont
+   DocBookTag  para
+   DocBookWrapperTag   acknowledgements
+   DocBookSection  true
 End
 
 Counter appendix
diff --git a/lib/layouts/aastex63.layout b/lib/layouts/aastex63.layout
index e2438986d7..e94d490e91 100644
--- a/lib/layouts/aastex63.layout
+++ b/lib/layouts/aastex63.layout
@@ -52,9 +52,16 @@
 ##
 # TODO: - support for new commands (see below)
 #   - aastex6.cls loads hyperref (with pre-set options) and url
-# -> option clash if "Use Hyerref" is selected in Document>Settings
+# -> option clash if "Use Hyperref" is selected in Document>Settings
 # support for new commands in aastex 6.3 and aastex 6.31 versions
 # string freeze for lyx-2.4.0, must be done for lyx-2.4.1
+#   - in DocBook, the appendix is not output (not a standard LyX appendix
+# separator (needs a layout update)
+#   - in DocBook, the "Software" part should really be a section on its 
own,
+# but that would require a way to provide the section title within the
+# layout (needs a layout update)
+#   - in DocBook, the table notes are not supported at all (move the 
remarks
+# into the table cells instead of outputting tablenotemark in the 
cells?)
 
 Format 104
 
@@ -232,11 +239,14 @@ Style Acknowledgments
Font
Shape   Up
EndFont
-   LabelType   Above
-   Margin  Static
+   LabelType   Above
+   

[LyX features/biginset] DocBook: amend e3020a6b.

2024-04-05 Thread Thibaut Cuvelier
commit 5c5765061fa1ce1b829c1b1dad05d3fc8d879079
Author: Thibaut Cuvelier 
Date:   Fri Mar 1 13:45:28 2024 +0100

DocBook: amend e3020a6b.

Book authorship and authorship can be quite distinct. As far as I know, 
there is no standard way to represent book authorship in DocBook bibliographies.
---
 autotests/export/docbook/basic.xml |  9 -
 src/BiblioInfo.cpp | 15 ---
 src/BiblioInfo.h   |  5 -
 src/insets/InsetBibtex.cpp | 32 +---
 4 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/autotests/export/docbook/basic.xml 
b/autotests/export/docbook/basic.xml
index cafbe46547..82bec18b72 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -424,7 +424,14 @@ I am no more code. 
 
 
 
-
+
+
+
+Michel
+Foucault
+
+
+
 
 
 A small paper
diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index 0f697ab297..253fb3759c 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -1748,13 +1748,19 @@ string citationStyleToString(const CitationStyle & cs, 
bool const latex)
 }
 
 
-void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf)
+void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf,
+ const std::string type)
 {
// This function closely mimics getAuthorList, but produces DocBook 
instead of text.
// It has been greatly simplified, as the complete list of authors is 
always produced. No separators are required,
// as the output has a database-like shape.
// constructName has also been merged within, as it becomes really 
simple and leads to no copy-paste.
 
+   if (! type.empty() && (type != "author" && type != "book")) {
+   LYXERR0("ERROR! Unexpected author contribution `" << type 
<<"'.");
+   return;
+   }
+
if (authorsString.empty()) {
return;
}
@@ -1772,7 +1778,10 @@ void authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream & xs
auto it = authors.cbegin();
auto en = authors.cend();
for (size_t i = 0; it != en; ++it, ++i) {
-   xs << xml::StartTag("author");
+   const std::string tag = (type.empty() || type == "author") ? 
"author" : "othercredit";
+   const std::string attr = (type == "book") ? R"(class="other" 
otherclass="bookauthor")" : "";
+
+   xs << xml::StartTag(tag, attr);
xs << xml::CR();
xs << xml::StartTag("personname");
xs << xml::CR();
@@ -1812,7 +1821,7 @@ void authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream & xs
 
xs << xml::EndTag("personname");
xs << xml::CR();
-   xs << xml::EndTag("author");
+   xs << xml::EndTag(tag);
xs << xml::CR();
 
// Could add an affiliation after , but not stored 
in BibTeX.
diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h
index 7a8ffb9081..aeaf0fcecc 100644
--- a/src/BiblioInfo.h
+++ b/src/BiblioInfo.h
@@ -37,7 +37,10 @@ CitationStyle citationStyleFromString(std::string const & 
latex_str,
 std::string citationStyleToString(CitationStyle const &, bool const latex = 
false);
 
 /// Transforms the information about authors into a  (directly 
written to a XMLStream).
-void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf);
+/// Type: "author" or empty means author of the entry (article, book, etc.); 
"book" means author of the book
+/// (but not necessarily of this entry in particular).
+void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf,
+std::string 
type);
 
 
 /// Class to represent information about a BibTeX or
diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index b4bf535014..d452434ab5 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1402,29 +1402,15 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
 
// 
// Example: 
http://tdg.docbook.org/tdg/5.1/authorgroup.html
-   if (hasTag("fullnames:author") || 
hasTag("fullbynames:bookauthor")) {
-   // If several author tags are present, only 
output one.

[LyX features/biginset] DocBook: authorsToDocBookAuthorGroup never needs to return anything.

2024-04-05 Thread Thibaut Cuvelier
commit 3973bbcf9915ad16cdd7dec3c20bd2f722dfb52e
Author: Thibaut Cuvelier 
Date:   Fri Mar 1 13:32:17 2024 +0100

DocBook: authorsToDocBookAuthorGroup never needs to return anything.
---
 src/BiblioInfo.cpp | 11 +--
 src/BiblioInfo.h   |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index a9245c6a77..0f697ab297 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -1748,7 +1748,7 @@ string citationStyleToString(const CitationStyle & cs, 
bool const latex)
 }
 
 
-docstring authorsToDocBookAuthorGroup(docstring const & authorsString, 
XMLStream & xs, Buffer const & buf)
+void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf)
 {
// This function closely mimics getAuthorList, but produces DocBook 
instead of text.
// It has been greatly simplified, as the complete list of authors is 
always produced. No separators are required,
@@ -1756,7 +1756,7 @@ docstring authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream
// constructName has also been merged within, as it becomes really 
simple and leads to no copy-paste.
 
if (authorsString.empty()) {
-   return docstring();
+   return;
}
 
// Split the input list of authors into individual authors.
@@ -1776,9 +1776,10 @@ docstring authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream
xs << xml::CR();
xs << xml::StartTag("personname");
xs << xml::CR();
-   docstring name = *it;
+   const docstring name = *it;
 
-   // All authors go in a . If more structure is 
known, use it; otherwise (just "et al."), print it as such.
+   // All authors go in a . If more structure is 
known, use it; otherwise (just "et al."),
+   // print it as such.
if (name == "others") {
xs << buf.B_(etal);
} else {
@@ -1818,8 +1819,6 @@ docstring authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream
}
xs << xml::EndTag("authorgroup");
xs << xml::CR();
-
-   return docstring();
 }
 
 } // namespace lyx
diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h
index f4051bf225..7a8ffb9081 100644
--- a/src/BiblioInfo.h
+++ b/src/BiblioInfo.h
@@ -37,7 +37,7 @@ CitationStyle citationStyleFromString(std::string const & 
latex_str,
 std::string citationStyleToString(CitationStyle const &, bool const latex = 
false);
 
 /// Transforms the information about authors into a  (directly 
written to a XMLStream).
-docstring authorsToDocBookAuthorGroup(docstring const & authorsString, 
XMLStream & xs, Buffer const & buf);
+void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf);
 
 
 /// Class to represent information about a BibTeX or
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] DocBook: support bookauthor in bibliographies.

2024-04-05 Thread Thibaut Cuvelier
commit e3020a6b2d240d0e1ae2aec8dfd754f6cd64dee1
Author: Thibaut Cuvelier 
Date:   Fri Mar 1 12:55:40 2024 +0100

DocBook: support bookauthor in bibliographies.
---
 autotests/export/docbook/basic.bib | 11 +++
 autotests/export/docbook/basic.lyx |  2 +-
 autotests/export/docbook/basic.xml | 31 +--
 src/insets/InsetBibtex.cpp | 25 ++---
 4 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/autotests/export/docbook/basic.bib 
b/autotests/export/docbook/basic.bib
index 88a9fe7b14..b106326c4d 100644
--- a/autotests/export/docbook/basic.bib
+++ b/autotests/export/docbook/basic.bib
@@ -107,3 +107,14 @@ volume = {MCMXCVII},
   month= 7,
   note = {An optional note}
 }
+
+@incollection{Foucault:Kritik-EN92,
+author = {Foucault, Michel},
+title = {What is Critique?},
+bookauthor = {Foucault, Michel},
+booktitle = {The Politics of Truth},
+pages = {41-82},
+publisher = {Semiotext(e)},
+address = {Los Angeles},
+year = {1997}
+}
diff --git a/autotests/export/docbook/basic.lyx 
b/autotests/export/docbook/basic.lyx
index d1078b9721..83b907fb54 100644
--- a/autotests/export/docbook/basic.lyx
+++ b/autotests/export/docbook/basic.lyx
@@ -876,7 +876,7 @@ Many things,
  
 \begin_inset CommandInset citation
 LatexCommand cite
-key "article,book,booklet,conference,inbook,incollection"
+key "article,book,booklet,conference,inbook,incollection,Foucault:Kritik-EN92"
 literal "false"
 
 \end_inset
diff --git a/autotests/export/docbook/basic.xml 
b/autotests/export/docbook/basic.xml
index 2248a2cbf4..cafbe46547 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -264,7 +264,7 @@ I am no more code. 
 
 I am the sixth section and I really like bibliographies
 This text has references. First reference: . 
Second reference: . Both at the same time: 
, . A book: . 
-Many things, just testing for completeness: , , , , , . 
+Many things, just testing for completeness: , , , , , , . 
 
 
 I am the seventh section and I deal with indices
@@ -358,12 +358,17 @@ I am no more code. 
 
 
 The title of the work
+4
+3
 201-213
 inbook
 
 The name of the publisher
-
+The address of the publisher
 1993
+
+
+
 
 
 
@@ -372,6 +377,7 @@ I am no more code. 
 
 
 
+An optional note
 
 
 The title of the work
@@ -399,6 +405,27 @@ I am no more code. 
 
 An optional note
 
+
+What is Critique?
+41-82
+incollection
+
+Semiotext(e)
+Los Angeles
+1997
+
+The Politics of Truth
+
+
+
+
+Michel
+Foucault
+
+
+
+
+
 
 A small paper
 -1
diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index 2e6f7f7fb7..b4bf535014 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1142,6 +1142,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
// Store the mapping between BibTeX and DocBook.
map toDocBookTag;
toDocBookTag["fullnames:author"] = "SPECIFIC"; // No direct translation 
to DocBook: .
+   toDocBookTag["fullbynames:bookauthor"] = "SPECIFIC"; // No direct 
translation to DocBook: .
toDocBookTag["publisher"] = "SPECIFIC"; // No direct translation to 
DocBook: .
toDocBookTag["address"] = "SPECIFIC"; // No direct translation to 
DocBook: .
toDocBookTag["editor"] = "SPECIFIC";  // No direct translation to 
DocBook: .
@@ -1401,11 +1402,29 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
 
// 
// Example: 
http://tdg.docbook.org/tdg/5.1/authorgroup.html
-   if (hasTag("fullnames:author")) {
+   if (hasTag("fullnames:author") || 
hasTag("fullbynames:bookauthor")) {
+   // If several author tags are present, only 
output one.
+   const docstring authorName = getTag(
+   hasTag("fullnames:author") ? 
"fullnames:author" : "fullbynames:bookauthor");
+
// Perform full parsing of the BibTeX string, 
dealing with the many corner cases that might
// be encountered.
-   
authorsToDocBookAuthorGroup(getTag("fullnames:author"), xs, buffer());
-   eraseTag("fullnames:author");
+   authorsToDocBookAuthorGroup(authorName, xs, 
buffer());
+
+   if (hasTag("fullnames:author") && 
hasTag("fullbynames:bookauthor")) {
+   xs << XMLStream::ESCAPE_NONE <<
+  from_utf8(

[LyX/master] Amend 16660d12.

2024-03-21 Thread Thibaut Cuvelier
commit fd378450755b698cc3ddb1a8d14e8b78d19c57a2
Author: Thibaut Cuvelier 
Date:   Thu Mar 21 21:32:45 2024 +0100

Amend 16660d12.

The previous commit introduced wrong behaviours for <>. The new code 
carefully escapes what needs to be escaped from LaTeX, using the now-standard 
XML tools (XMLStream).
---
 autotests/export/xhtml/math_output_latex.lyx   |  2 +-
 autotests/export/xhtml/math_output_latex.xhtml |  2 +-
 src/insets/InsetLabel.cpp  |  2 +
 src/mathed/InsetMathHull.cpp   | 62 --
 src/mathed/InsetMathHull.h |  4 +-
 5 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/autotests/export/xhtml/math_output_latex.lyx 
b/autotests/export/xhtml/math_output_latex.lyx
index 59d77d2f9b..7c49de59f6 100644
--- a/autotests/export/xhtml/math_output_latex.lyx
+++ b/autotests/export/xhtml/math_output_latex.lyx
@@ -100,7 +100,7 @@ The problem occurs when adding a label.
 \begin_layout Standard
 \begin_inset Formula 
 \begin{equation}
-x^{2}\label{eq:1}
+x^{2}<\log x\label{eq:1}
 \end{equation}
 
 \end_inset
diff --git a/autotests/export/xhtml/math_output_latex.xhtml 
b/autotests/export/xhtml/math_output_latex.xhtml
index cec2d5ba0d..713def3459 100644
--- a/autotests/export/xhtml/math_output_latex.xhtml
+++ b/autotests/export/xhtml/math_output_latex.xhtml
@@ -22,7 +22,7 @@ div.standard {
 Math formula output as raw LaTeX
 The problem occurs when adding a 
label. https://www.lyx.org/trac/ticket/13048
 
-x^{2}(1)
+x^{2}<\log 
x(1)
 
 
 
diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp
index 1ca8ea08ae..ab5a5e1716 100644
--- a/src/insets/InsetLabel.cpp
+++ b/src/insets/InsetLabel.cpp
@@ -380,6 +380,8 @@ void InsetLabel::docbook(XMLStream & xs, OutputParams const 
& runparams) const
 
 docstring InsetLabel::xhtml(XMLStream & xs, OutputParams const &) const
 {
+   // Print the label as an HTML anchor, so that an external link can 
point to this equation.
+   // (URL: FILE.html#EQ-ID.)
// FIXME XHTML
// Unfortunately, the name attribute has been deprecated, so we have to 
use
// id here to get the document to validate as XHTML 1.1. This will 
cause a
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index bb368b3b93..94d293870d 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2574,35 +2574,56 @@ void InsetMathHull::mathmlize(MathMLStream & ms) const
 }
 
 
-void InsetMathHull::mathAsLatex(TeXMathStream & os) const
+docstring InsetMathHull::mathAsLatex() const
 {
-   MathEnsurer ensurer(os, false);
bool const havenumbers = haveNumbers();
bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
 
if (!havetable) {
+   odocstringstream ls;
+   otexrowstream ots(ls);
+   TeXMathStream os(ots, false, true, TeXMathStream::wsPreview);
+   ModeSpecifier specifier(os, MATH_MODE);
+   MathEnsurer ensurer(os, false);
+
os << cell(index(0, 0));
-   return;
+   return ls.str();
}
 
-   os << "";
+   odocstringstream ods;
+   XMLStream xs(ods);
+
+   xs << xml::StartTag("table", "class='mathtable'");
for (row_type row = 0; row < nrows(); ++row) {
-   os << "";
+   xs << xml::StartTag("tr");
for (col_type col = 0; col < ncols(); ++col) {
-   os << "";
-   os << cell(index(row, col));
-   os << "";
+   xs << xml::StartTag("td", "class='math'");
+
+   odocstringstream ls;
+   otexrowstream ots(ls);
+   TeXMathStream os(ots, false, true, 
TeXMathStream::wsPreview);
+   ModeSpecifier specifier(os, MATH_MODE);
+   MathEnsurer ensurer(os, false);
+
+   os << cell(index(0, 0));
+   // ls.str() contains a raw LaTeX string, which might 
require some encoding before being valid XML.
+   xs << ls.str();
+
+   xs << xml::EndTag("td");
}
if (havenumbers) {
-   os << "";
+   xs << xml::StartTag("td");
docstring const & num = numbers_[row];
-   if (!num.empty())
-   os << '(' << num << ')';
-   os << "";
+   if (!num.empty()) {
+   xs << '(' << num << ')';
+ 

[LyX/master] MathML in HTML: don't escape <> for a raw LaTeX output.

2024-03-20 Thread Thibaut Cuvelier
commit 16660d12b4333f6486259048dec2b0a2e48a64d9
Author: Thibaut Cuvelier 
Date:   Thu Mar 21 00:29:23 2024 +0100

MathML in HTML: don't escape <> for a raw LaTeX output.

In some cases (I only found numbered equations), the LaTeX output still has 
a bit of HTML. For numbered equations, using \tag{X} (as suggested in 
https://www.lyx.org/trac/ticket/13048) would require fiddling with the output. 
KaTeX doesn't support \label. This patch is probably the easiest and most 
reliable fix.

Fixes https://www.lyx.org/trac/ticket/13048.
---
 autotests/export/xhtml/math_output_latex.lyx   | 112 +
 autotests/export/xhtml/math_output_latex.xhtml |  28 +++
 src/mathed/InsetMathHull.cpp   |   3 +-
 3 files changed, 142 insertions(+), 1 deletion(-)

diff --git a/autotests/export/xhtml/math_output_latex.lyx 
b/autotests/export/xhtml/math_output_latex.lyx
new file mode 100644
index 00..59d77d2f9b
--- /dev/null
+++ b/autotests/export/xhtml/math_output_latex.lyx
@@ -0,0 +1,112 @@
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 620
+\begin_document
+\begin_header
+\save_transient_properties true
+\origin unavailable
+\textclass article
+\use_default_options true
+\maintain_unincluded_children no
+\language american
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "default" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "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 default
+\output_sync 0
+\bibtex_command default
+\index_command default
+\float_placement class
+\float_alignment class
+\paperfontsize default
+\spacing single
+\use_hyperref false
+\papersize default
+\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 1
+\use_formatted_ref 0
+\use_minted 0
+\use_lineno 0
+\index Index
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style english
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tablestyle default
+\tracking_changes false
+\output_changes false
+\change_bars false
+\postpone_fragile_content true
+\html_math_output 3
+\html_css_as_file 0
+\html_be_strict false
+\docbook_table_output 0
+\docbook_mathml_prefix 1
+\end_header
+
+\begin_body
+
+\begin_layout Title
+Math formula output as raw LaTeX
+\end_layout
+
+\begin_layout Standard
+The problem occurs when adding a label.
+ https://www.lyx.org/trac/ticket/13048
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula 
+\begin{equation}
+x^{2}\label{eq:1}
+\end{equation}
+
+\end_inset
+
+
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/xhtml/math_output_latex.xhtml 
b/autotests/export/xhtml/math_output_latex.xhtml
new file mode 100644
index 00..cec2d5ba0d
--- /dev/null
+++ b/autotests/export/xhtml/math_output_latex.xhtml
@@ -0,0 +1,28 @@
+
+http://www.w3.org/1999/xhtml; lang="en-US">
+
+
+Math formula output as raw LaTeX
+
+/* Layout-provided Styles */
+h1.title {
+font-size: x-large;
+margin-bottom: 1ex;
+text-align: center;
+
+}
+div.standard {
+   margin-bottom: 2ex;
+}
+
+
+
+
+
+Math formula output as raw LaTeX
+The problem occurs when adding a 
label. https://www.lyx.org/trac/ticket/13048
+
+x^{2}(1)
+
+
+
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 2ba98b3d4d..bb368b3b93 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2729,7 +2729,8 @@ docstring InsetMathHull::xhtml(XMLStream & xs, 
OutputParams const & op) const
// probably should allow for some kind of customization here
string const tag = (getType() == hullSimple) ? "span" : "div";
xs << xml::StartTag(tag, "class='math'")
-  << latex
+  << XMLStream::ESCAPE_AND << latex // Don't escape <> tags: 
latex might contain them
+  // (typically, when there is a label).
   << xml::EndTag(tag)
   << xml::CR();
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: stop stretching all delimiters.

2024-03-10 Thread Thibaut Cuvelier
commit 8f820d7ccb0cb6129c8e3c1d495905d61db97355
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:40:16 2024 +0100

MathML: stop stretching all delimiters.

No form? Reference: https://w3c.github.io/mathml-core/#dfn-form. The MathML 
processor is smart enough to determine whether the delimiter is prefix or 
postfix.

No stretchy/symmetric/fence in all cases? Reference: 
https://w3c.github.io/mathml-core/#algorithm-for-determining-the-properties-of-an-embellished-operator
 and https://w3c.github.io/mathml-core/#operator-dictionary-human (example 
entry: U+0028). Delimiters have the right properties by default.
---
 src/mathed/InsetMathDelim.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index d32029b818..fab72db88d 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -190,15 +190,16 @@ void InsetMathDelim::mathematica(MathematicaStream & os) 
const
 void InsetMathDelim::mathmlize(MathMLStream & ms) const
 {
// Ignore the delimiter if: it is empty or only a space (one character).
+   const std::string attr = is_extracted_ ? "stretchy='false'" : "";
if (!left_.empty() && ((left_.size() == 1 && left_[0] != ' ') || 
left_.size() > 1)) {
ms << MTag("mrow")
-  << MTagInline("mo", "form='prefix' fence='true' stretchy='true' 
symmetric='true'")
+  << MTagInline("mo", attr)
   << convertDelimToXMLEscape(left_)
   << ETagInline("mo");
}
ms << cell(0);
if (!right_.empty() && ((right_.size() == 1 && right_[0] != ' ') || 
right_.size() > 1)) {
-   ms << MTagInline("mo", "form='postfix' fence='true' stretchy='true' 
symmetric='true'")
+   ms << MTagInline("mo", attr)
   << convertDelimToXMLEscape(right_)
   << ETagInline("mo")
   << ETag("mrow");
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: don't let the processor stretch operators when they are single characters for LyX.

2024-03-10 Thread Thibaut Cuvelier
commit 7e6597a5b47c22ed22966a75c149264dacd6e289
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 02:00:47 2024 +0100

MathML: don't let the processor stretch operators when they are single 
characters for LyX.

The main goal is to match TeX' behaviour. If you want stretchy operators, 
use InsetMathDelim / \left & \right. This patch will change the output in many 
files, but making the rendering much closer to that of TeX (which users should 
expect, due to LyX' roots in TeX).
---
 src/mathed/InsetMathChar.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index 71aba6f6f7..a642a5e6da 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -230,6 +230,8 @@ void InsetMathChar::octave(OctaveStream & os) const
 // mathalpha, then we'll treat it as an identifier, otherwise as an
 // operator.
 // Worst case: We get bad spacing, or bad italics.
+// In any case, never let MathML stretch a single character when it
+// is recognised as an operator, to match TeX' behaviour.
 void InsetMathChar::mathmlize(MathMLStream & ms) const
 {
std::string entity;
@@ -253,7 +255,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
}
 
if (!entity.empty()) {
-   ms << MTagInline("mo")
+   ms << MTagInline("mo", "stretchy='false'")
   << from_ascii(entity)
   << ETagInline("mo");
return;
@@ -262,7 +264,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
char const * type =
(isAlphaASCII(char_) || Encodings::isMathAlpha(char_))
? "mi" : "mo";
-   ms << MTagInline(type)
+   ms << MTagInline(type, std::string(type) == "mo" ? "stretchy='false'" : 
"")
   << char_type(char_)
   << ETagInline(type);
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: don't output delimiters in InsetMathBinom and InsetMathDelim if the delimiter is a space.

2024-03-10 Thread Thibaut Cuvelier
commit be03d699463fba896f90e3046b0814d527368771
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:30:48 2024 +0100

MathML: don't output delimiters in InsetMathBinom and
 InsetMathDelim if the delimiter is a space.
---
 src/mathed/InsetMathDelim.cpp | 23 ++-
 src/mathed/InsetMathFrac.cpp  | 21 +
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index 78d26fceea..d32029b818 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -189,15 +189,20 @@ void InsetMathDelim::mathematica(MathematicaStream & os) 
const
 
 void InsetMathDelim::mathmlize(MathMLStream & ms) const
 {
-   ms << MTag("mrow")
-  << MTagInline("mo", "form='prefix' fence='true' stretchy='true' 
symmetric='true'")
-  << convertDelimToXMLEscape(left_)
-  << ETagInline("mo")
-  << cell(0)
-  << MTagInline("mo", "form='postfix' fence='true' stretchy='true' 
symmetric='true'")
-  << convertDelimToXMLEscape(right_)
-  << ETagInline("mo")
-  << ETag("mrow");
+   // Ignore the delimiter if: it is empty or only a space (one character).
+   if (!left_.empty() && ((left_.size() == 1 && left_[0] != ' ') || 
left_.size() > 1)) {
+   ms << MTag("mrow")
+  << MTagInline("mo", "form='prefix' fence='true' stretchy='true' 
symmetric='true'")
+  << convertDelimToXMLEscape(left_)
+  << ETagInline("mo");
+   }
+   ms << cell(0);
+   if (!right_.empty() && ((right_.size() == 1 && right_[0] != ' ') || 
right_.size() > 1)) {
+   ms << MTagInline("mo", "form='postfix' fence='true' stretchy='true' 
symmetric='true'")
+  << convertDelimToXMLEscape(right_)
+  << ETagInline("mo")
+  << ETag("mrow");
+   }
 }
 
 
diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index f6f2f95b0a..b0ff55bc4d 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -768,15 +768,20 @@ void InsetMathBinom::mathmlize(MathMLStream & ms) const
rdelim = ']';
break;
}
-   ms << MTagInline("mo", "fence='true' stretchy='true' form='prefix'")
-  << ldelim
-  << ETagInline("mo")
-  << MTagInline("mfrac", "linethickness='0'")
+
+   if (ldelim != ' ') {
+   ms << MTagInline("mo", "fence='true' stretchy='true' form='prefix'")
+  << ldelim
+  << ETagInline("mo");
+   }
+   ms << MTagInline("mfrac", "linethickness='0'")
   << cell(0) << cell(1)
-   << ETagInline("mfrac")
-  << MTagInline("mo", "fence='true' stretchy='true' form='postfix'")
-  << rdelim
-  << ETagInline("mo");
+  << ETagInline("mfrac");
+   if (rdelim != ' ') {
+   ms << MTagInline("mo", "fence='true' stretchy='true' 
form='postfix'")
+  << rdelim
+  << ETagInline("mo");
+   }
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Extract vert, langle, rangle in MathExtern like parentheses and brackets.

2024-03-10 Thread Thibaut Cuvelier
commit 9e6b810b37f28499a5573468ae61d68be0bb2e75
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:22:12 2024 +0100

Extract vert, langle, rangle in MathExtern like parentheses and brackets.

This patch is part of a series that aims at solving 
https://www.lyx.org/trac/ticket/12891. It is an excerpt of the patch that lynx 
published at https://www.lyx.org/trac/ticket/12270.
---
 src/mathed/MathExtern.cpp | 67 ++-
 1 file changed, 54 insertions(+), 13 deletions(-)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index b07c08b56e..e273aac791 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -292,6 +292,19 @@ bool testString(MathAtom const & at, char const * const 
str)
return testString(at, from_ascii(str));
 }
 
+
+bool testSymbol(MathAtom const & at, docstring const & name)
+{
+   return at->asSymbolInset() && at->asSymbolInset()->name() == name;
+}
+
+
+bool testSymbol(MathAtom const & at, char const * const name)
+{
+   return testSymbol(at, from_ascii(name));
+}
+
+
 // search end of nested sequence
 MathData::iterator endNestSearch(
MathData::iterator it,
@@ -523,12 +536,52 @@ MathAtom replaceBracketDelims(const MathData & ar)
 }
 
 
-// replace '('...')' and '['...']' sequences by a real InsetMathDelim
+bool testOpenVert(MathAtom const & at)
+{
+   return testSymbol(at, "lvert");
+}
+
+
+bool testCloseVert(MathAtom const & at)
+{
+   return testSymbol(at, "rvert");
+}
+
+
+MathAtom replaceVertDelims(const MathData & ar)
+{
+   return MathAtom(new InsetMathDelim(const_cast(ar.buffer()),
+   from_ascii("lvert"), from_ascii("rvert"), ar, true));
+}
+
+
+bool testOpenAngled(MathAtom const & at)
+{
+   return testSymbol(at, "langle");
+}
+
+
+bool testCloseAngled(MathAtom const & at)
+{
+   return testSymbol(at, "rangle");
+}
+
+
+MathAtom replaceAngledDelims(const MathData & ar)
+{
+   return MathAtom(new InsetMathDelim(const_cast(ar.buffer()),
+   from_ascii("langle"), from_ascii("rangle"), ar, true));
+}
+
+
+// replace '('...')', '['...']', '|'...'|', and '<'...'>' sequences by a real 
InsetMathDelim
 void extractDelims(MathData & ar)
 {
//lyxerr << "\nDelims from: " << ar << endl;
replaceNested(ar, testOpenParen, testCloseParen, replaceParenDelims);
replaceNested(ar, testOpenBracket, testCloseBracket, 
replaceBracketDelims);
+   replaceNested(ar, testOpenVert, testCloseVert, replaceVertDelims);
+   replaceNested(ar, testOpenAngled, testCloseAngled, replaceAngledDelims);
//lyxerr << "\nDelims to: " << ar << endl;
 }
 
@@ -622,18 +675,6 @@ void extractFunctions(MathData & ar, ExternalMath kind)
 // search integrals
 //
 
-bool testSymbol(MathAtom const & at, docstring const & name)
-{
-   return at->asSymbolInset() && at->asSymbolInset()->name() == name;
-}
-
-
-bool testSymbol(MathAtom const & at, char const * const name)
-{
-   return testSymbol(at, from_ascii(name));
-}
-
-
 bool testIntSymbol(MathAtom const & at)
 {
return testSymbol(at, from_ascii("int"));
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Improve const correctness.

2024-03-10 Thread Thibaut Cuvelier
commit b1a4eb118cd3d271a35b2260cde077e21c62c32c
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:15:48 2024 +0100

Improve const correctness.
---
 src/mathed/MathExtern.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index d101904e83..b07c08b56e 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -295,7 +295,7 @@ bool testString(MathAtom const & at, char const * const str)
 // search end of nested sequence
 MathData::iterator endNestSearch(
MathData::iterator it,
-   MathData::iterator last,
+   const MathData::iterator& last,
TestItemFunc testOpen,
TestItemFunc testClose
 )
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Memorise whether delims are extracted from MathExtern.

2024-03-10 Thread Thibaut Cuvelier
commit 93444892c504fdd7b8fdfbc7f2bf67f9b250eb82
Author: Thibaut Cuvelier 
Date:   Mon Mar 11 01:07:25 2024 +0100

Memorise whether delims are extracted from MathExtern.

This patch is part of a series that aims at solving 
https://www.lyx.org/trac/ticket/12891. It should not change any output.
---
 src/mathed/InsetMathDelim.cpp | 12 ++--
 src/mathed/InsetMathDelim.h   |  6 ++
 src/mathed/MathExtern.cpp |  4 ++--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index 486ed97580..78d26fceea 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -45,13 +45,21 @@ static docstring convertDelimToLatexName(docstring const & 
name)
 
 InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l,
docstring const & r)
-   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0)
+   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0), 
is_extracted_(false)
 {}
 
 
 InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l, docstring 
const & r,
MathData const & ar)
-   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0)
+   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0), 
is_extracted_(false)
+{
+   cell(0) = ar;
+}
+
+
+InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l, docstring 
const & r,
+   MathData const & ar, bool const is_extracted)
+   : InsetMathNest(buf, 1), left_(l), right_(r), dw_(0), 
is_extracted_(is_extracted)
 {
cell(0) = ar;
 }
diff --git a/src/mathed/InsetMathDelim.h b/src/mathed/InsetMathDelim.h
index cad8da49de..3d8bd2ce36 100644
--- a/src/mathed/InsetMathDelim.h
+++ b/src/mathed/InsetMathDelim.h
@@ -27,6 +27,9 @@ public:
InsetMathDelim(Buffer * buf, docstring const & left, docstring const & 
right,
MathData const &);
///
+   InsetMathDelim(Buffer * buf, docstring const & left, docstring const & 
right,
+  MathData const &, bool const is_extracted);
+   ///
InsetMathDelim * asDelimInset() override { return this; }
///
InsetMathDelim const * asDelimInset() const override { return this; }
@@ -73,6 +76,9 @@ private:
Inset * clone() const override;
///
mutable int dw_;
+   /// Is it extracted by MathExtern routines? They try to extract as much
+   /// semantics from a raw LaTeX formula in terms of LyX insets.
+   bool const is_extracted_;
 };
 
 } // namespace lyx
diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index 22124cc13d..d101904e83 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -500,7 +500,7 @@ bool testCloseParen(MathAtom const & at)
 MathAtom replaceParenDelims(const MathData & ar)
 {
return MathAtom(new InsetMathDelim(const_cast(ar.buffer()),
-   from_ascii("("), from_ascii(")"), ar));
+   from_ascii("("), from_ascii(")"), ar, true));
 }
 
 
@@ -519,7 +519,7 @@ bool testCloseBracket(MathAtom const & at)
 MathAtom replaceBracketDelims(const MathData & ar)
 {
return MathAtom(new InsetMathDelim(const_cast(ar.buffer()),
-   from_ascii("["), from_ascii("]"), ar));
+   from_ascii("["), from_ascii("]"), ar, true));
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Reduce code duplication.

2024-03-10 Thread Thibaut Cuvelier
commit 1680eaf5f0edeed089e2bdc2b539b80187b88d3c
Author: Thibaut Cuvelier 
Date:   Sun Mar 10 16:55:12 2024 +0100

Reduce code duplication.
---
 src/mathed/MathExtern.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index daf171981f..22124cc13d 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -630,7 +630,7 @@ bool testSymbol(MathAtom const & at, docstring const & name)
 
 bool testSymbol(MathAtom const & at, char const * const name)
 {
-   return at->asSymbolInset() && at->asSymbolInset()->name() == 
from_ascii(name);
+   return testSymbol(at, from_ascii(name));
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: consider ordinary and alphabetical characters as identifiers instead of operators.

2024-03-09 Thread Thibaut Cuvelier
commit 011c3d73c0c3137dcd67bf8bb09644ac064b2342
Author: Thibaut Cuvelier 
Date:   Sat Mar 9 20:59:12 2024 +0100

MathML: consider ordinary and alphabetical characters as identifiers 
instead of operators.

The goal is to consider all Greek letters as identifiers instead of 
operators.

Solves: https://www.lyx.org/trac/ticket/12948.
---
 .../export/docbook/mathml_greek_operators.lyx  | 112 +
 .../export/docbook/mathml_greek_operators.xml  |  20 
 src/mathed/MathParser.cpp  |   4 +-
 3 files changed, 135 insertions(+), 1 deletion(-)

diff --git a/autotests/export/docbook/mathml_greek_operators.lyx 
b/autotests/export/docbook/mathml_greek_operators.lyx
new file mode 100644
index 00..f7d2ce
--- /dev/null
+++ b/autotests/export/docbook/mathml_greek_operators.lyx
@@ -0,0 +1,112 @@
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 620
+\begin_document
+\begin_header
+\save_transient_properties true
+\origin unavailable
+\textclass article
+\use_default_options true
+\maintain_unincluded_children no
+\language american
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "default" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "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 default
+\output_sync 0
+\bibtex_command default
+\index_command default
+\float_placement class
+\float_alignment class
+\paperfontsize default
+\use_hyperref false
+\papersize default
+\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
+\use_bibtopic false
+\use_indices false
+\paperorientation portrait
+\suppress_date false
+\justification true
+\use_refstyle 1
+\use_formatted_ref 0
+\use_minted 0
+\use_lineno 0
+\index Index
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style english
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tablestyle default
+\tracking_changes false
+\output_changes false
+\change_bars false
+\postpone_fragile_content true
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict false
+\docbook_table_output 0
+\docbook_mathml_prefix 1
+\end_header
+
+\begin_body
+
+\begin_layout Title
+MathML:
+ all Greek letters are symbols,
+ none of them is an operator
+\end_layout
+
+\begin_layout Standard
+Issue:
+ https://www.lyx.org/trac/ticket/12948
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula 
+\[
+1\alpha2\Xi3
+\]
+
+\end_inset
+
+
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/docbook/mathml_greek_operators.xml 
b/autotests/export/docbook/mathml_greek_operators.xml
new file mode 100644
index 00..c5fc17c0b8
--- /dev/null
+++ b/autotests/export/docbook/mathml_greek_operators.xml
@@ -0,0 +1,20 @@
+
+
+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">
+MathML: all Greek letters are symbols, none of them is an 
operator
+Issue: https://www.lyx.org/trac/ticket/12948
+
+1\alpha2\Xi3
+
+ 
+
+ 1
+ 
+ 2
+ 
+ 3
+
+
+
+
\ No newline at end of file
diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp
index e94b6cea32..9b43da8cdd 100644
--- a/src/mathed/MathParser.cpp
+++ b/src/mathed/MathParser.cpp
@@ -2141,8 +2141,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
 // FIXME This will likely need some work.
 char const * latexkeys::MathMLtype() const
 {
-   if (extra == "mathord")
+   // Consider as identifier (mml:mi): ordinary and alphabetical 
characters.
+   if (extra == "mathord" || extra == "mathalpha")
return "mi";
+   // Consider as operators (mml:mo): everything else.
return "mo";
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Simplify a loop with a for-each.

2024-03-09 Thread Thibaut Cuvelier
commit 1b11dfeca5c4e11585129221d966e84c5c775402
Author: Thibaut Cuvelier 
Date:   Sat Mar 9 20:46:54 2024 +0100

Simplify a loop with a for-each.

These loops were brought by C++11. The next step could be using std::any_of.
---
 src/mathed/MathSupport.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp
index 57e8c6ee4e..585320f11a 100644
--- a/src/mathed/MathSupport.cpp
+++ b/src/mathed/MathSupport.cpp
@@ -1070,10 +1070,10 @@ bool isAlphaSymbol(MathAtom const & at)
 
if (at->asFontInset()) {
MathData const & ar = at->asFontInset()->cell(0);
-   for (size_t i = 0; i < ar.size(); ++i) {
-   if (!(ar[i]->asCharInset() ||
- (ar[i]->asSymbolInset() &&
-  ar[i]->asSymbolInset()->isOrdAlpha(
+   for (const auto & i : ar) {
+   if (!(i->asCharInset() ||
+ (i->asSymbolInset() &&
+  i->asSymbolInset()->isOrdAlpha(
return false;
}
return true;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] DocBook: add missing mapping for AASTeX 6.3.

2024-03-09 Thread Thibaut Cuvelier
commit 04beccca4c7170273748e14827b8af62e5726b25
Author: Thibaut Cuvelier 
Date:   Sat Mar 9 15:09:45 2024 +0100

DocBook: add missing mapping for AASTeX 6.3.

The result is far from perfect, see the TODOs. The corresponding tests are 
still inverted.
---
 development/autotests/invertedTests |  2 ++
 lib/layouts/aastex6.layout  |  9 -
 lib/layouts/aastex62.layout | 12 +++-
 lib/layouts/aastex63.layout | 16 +---
 4 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/development/autotests/invertedTests 
b/development/autotests/invertedTests
index c88e67cda5..ec366b9745 100644
--- a/development/autotests/invertedTests
+++ b/development/autotests/invertedTests
@@ -412,6 +412,8 @@ export/doc(|/de|/es|/fr|/ja|/ru)/Additional_docbook5
 #   - AASTeX.
 export/export/docbook/bibliography_precooked_aastex_docbook5
 
export/(examples|templates)/Articles/American_Astronomical_Society_%28AASTeX_v._6.2%29_docbook5
+export/(examples|templates)/Articles/American_Astronomical_Society_%28AASTeX_v._6.3%29_docbook5
+export/(examples|templates)/Articles/American_Astronomical_Society_%28AASTeX_v._6.3.1%29_docbook5
 #   - Springer. (The svmono_light should still pass.)
 export/templates/Books/Springer.*/.*_docbook5
 !export/export/docbook/svmono_light_docbook5
diff --git a/lib/layouts/aastex6.layout b/lib/layouts/aastex6.layout
index c6ab5ea03f..3ae8486cce 100644
--- a/lib/layouts/aastex6.layout
+++ b/lib/layouts/aastex6.layout
@@ -44,7 +44,14 @@
 #
 # TODO: - support for new commands (see below)
 #   - aastex6.cls loads hyperref (with pre-set options) and url
-# -> option clash if "Use Hyerref" is selected in Document>Settings
+# -> option clash if "Use Hyperref" is selected in Document>Settings
+#   - in DocBook, the appendix is not output (not a standard LyX appendix
+# separator (needs a layout update)
+#   - in DocBook, the "Software" part should really be a section on its 
own,
+# but that would require a way to provide the section title within the
+# layout (needs a layout update)
+#   - in DocBook, the table notes are not supported at all (move the 
remarks
+# into the table cells instead of outputting tablenotemark in the 
cells?)
 
 Format 104
 
diff --git a/lib/layouts/aastex62.layout b/lib/layouts/aastex62.layout
index 5080cc06e8..5bfc03111e 100644
--- a/lib/layouts/aastex62.layout
+++ b/lib/layouts/aastex62.layout
@@ -48,7 +48,14 @@
 #
 # TODO: - support for new commands (see below)
 #   - aastex6.cls loads hyperref (with pre-set options) and url
-# -> option clash if "Use Hyerref" is selected in Document>Settings
+# -> option clash if "Use Hy^perref" is selected in Document>Settings
+#   - in DocBook, the appendix is not output (not a standard LyX appendix
+# separator (needs a layout update)
+#   - in DocBook, the "Software" part should really be a section on its 
own,
+# but that would require a way to provide the section title within the
+# layout (needs a layout update)
+#   - in DocBook, the table notes are not supported at all (move the 
remarks
+# into the table cells instead of outputting tablenotemark in the 
cells?)
 
 Format 104
 
@@ -231,6 +238,9 @@ Style Acknowledgments
LabelFont
Color   textlabel2
EndFont
+   DocBookTag  para
+   DocBookWrapperTag   acknowledgements
+   DocBookSection  true
 End
 
 Counter appendix
diff --git a/lib/layouts/aastex63.layout b/lib/layouts/aastex63.layout
index e2438986d7..e94d490e91 100644
--- a/lib/layouts/aastex63.layout
+++ b/lib/layouts/aastex63.layout
@@ -52,9 +52,16 @@
 ##
 # TODO: - support for new commands (see below)
 #   - aastex6.cls loads hyperref (with pre-set options) and url
-# -> option clash if "Use Hyerref" is selected in Document>Settings
+# -> option clash if "Use Hyperref" is selected in Document>Settings
 # support for new commands in aastex 6.3 and aastex 6.31 versions
 # string freeze for lyx-2.4.0, must be done for lyx-2.4.1
+#   - in DocBook, the appendix is not output (not a standard LyX appendix
+# separator (needs a layout update)
+#   - in DocBook, the "Software" part should really be a section on its 
own,
+# but that would require a way to provide the section title within the
+# layout (needs a layout update)
+#   - in DocBook, the table notes are not supported at all (move the 
remarks
+# into the table cells instead of outputting tablenotemark in the 
cells?)
 
 Format 104
 
@@ -232,11 +239,14 @@ Style Acknowledgments
Font
Shape   Up
EndFont
-   LabelType   Above
-   Margin  Static
+   LabelType   Above
+   

[LyX/master] DocBook: amend e3020a6b.

2024-03-01 Thread Thibaut Cuvelier
commit 5c5765061fa1ce1b829c1b1dad05d3fc8d879079
Author: Thibaut Cuvelier 
Date:   Fri Mar 1 13:45:28 2024 +0100

DocBook: amend e3020a6b.

Book authorship and authorship can be quite distinct. As far as I know, 
there is no standard way to represent book authorship in DocBook bibliographies.
---
 autotests/export/docbook/basic.xml |  9 -
 src/BiblioInfo.cpp | 15 ---
 src/BiblioInfo.h   |  5 -
 src/insets/InsetBibtex.cpp | 32 +---
 4 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/autotests/export/docbook/basic.xml 
b/autotests/export/docbook/basic.xml
index cafbe46547..82bec18b72 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -424,7 +424,14 @@ I am no more code. 
 
 
 
-
+
+
+
+Michel
+Foucault
+
+
+
 
 
 A small paper
diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index 0f697ab297..253fb3759c 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -1748,13 +1748,19 @@ string citationStyleToString(const CitationStyle & cs, 
bool const latex)
 }
 
 
-void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf)
+void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf,
+ const std::string type)
 {
// This function closely mimics getAuthorList, but produces DocBook 
instead of text.
// It has been greatly simplified, as the complete list of authors is 
always produced. No separators are required,
// as the output has a database-like shape.
// constructName has also been merged within, as it becomes really 
simple and leads to no copy-paste.
 
+   if (! type.empty() && (type != "author" && type != "book")) {
+   LYXERR0("ERROR! Unexpected author contribution `" << type 
<<"'.");
+   return;
+   }
+
if (authorsString.empty()) {
return;
}
@@ -1772,7 +1778,10 @@ void authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream & xs
auto it = authors.cbegin();
auto en = authors.cend();
for (size_t i = 0; it != en; ++it, ++i) {
-   xs << xml::StartTag("author");
+   const std::string tag = (type.empty() || type == "author") ? 
"author" : "othercredit";
+   const std::string attr = (type == "book") ? R"(class="other" 
otherclass="bookauthor")" : "";
+
+   xs << xml::StartTag(tag, attr);
xs << xml::CR();
xs << xml::StartTag("personname");
xs << xml::CR();
@@ -1812,7 +1821,7 @@ void authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream & xs
 
xs << xml::EndTag("personname");
xs << xml::CR();
-   xs << xml::EndTag("author");
+   xs << xml::EndTag(tag);
xs << xml::CR();
 
// Could add an affiliation after , but not stored 
in BibTeX.
diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h
index 7a8ffb9081..aeaf0fcecc 100644
--- a/src/BiblioInfo.h
+++ b/src/BiblioInfo.h
@@ -37,7 +37,10 @@ CitationStyle citationStyleFromString(std::string const & 
latex_str,
 std::string citationStyleToString(CitationStyle const &, bool const latex = 
false);
 
 /// Transforms the information about authors into a  (directly 
written to a XMLStream).
-void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf);
+/// Type: "author" or empty means author of the entry (article, book, etc.); 
"book" means author of the book
+/// (but not necessarily of this entry in particular).
+void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf,
+std::string 
type);
 
 
 /// Class to represent information about a BibTeX or
diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index b4bf535014..d452434ab5 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1402,29 +1402,15 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
 
// 
// Example: 
http://tdg.docbook.org/tdg/5.1/authorgroup.html
-   if (hasTag("fullnames:author") || 
hasTag("fullbynames:bookauthor")) {
-   // If several author tags are present, only 
output one.

[LyX/master] DocBook: authorsToDocBookAuthorGroup never needs to return anything.

2024-03-01 Thread Thibaut Cuvelier
commit 3973bbcf9915ad16cdd7dec3c20bd2f722dfb52e
Author: Thibaut Cuvelier 
Date:   Fri Mar 1 13:32:17 2024 +0100

DocBook: authorsToDocBookAuthorGroup never needs to return anything.
---
 src/BiblioInfo.cpp | 11 +--
 src/BiblioInfo.h   |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index a9245c6a77..0f697ab297 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -1748,7 +1748,7 @@ string citationStyleToString(const CitationStyle & cs, 
bool const latex)
 }
 
 
-docstring authorsToDocBookAuthorGroup(docstring const & authorsString, 
XMLStream & xs, Buffer const & buf)
+void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf)
 {
// This function closely mimics getAuthorList, but produces DocBook 
instead of text.
// It has been greatly simplified, as the complete list of authors is 
always produced. No separators are required,
@@ -1756,7 +1756,7 @@ docstring authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream
// constructName has also been merged within, as it becomes really 
simple and leads to no copy-paste.
 
if (authorsString.empty()) {
-   return docstring();
+   return;
}
 
// Split the input list of authors into individual authors.
@@ -1776,9 +1776,10 @@ docstring authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream
xs << xml::CR();
xs << xml::StartTag("personname");
xs << xml::CR();
-   docstring name = *it;
+   const docstring name = *it;
 
-   // All authors go in a . If more structure is 
known, use it; otherwise (just "et al."), print it as such.
+   // All authors go in a . If more structure is 
known, use it; otherwise (just "et al."),
+   // print it as such.
if (name == "others") {
xs << buf.B_(etal);
} else {
@@ -1818,8 +1819,6 @@ docstring authorsToDocBookAuthorGroup(docstring const & 
authorsString, XMLStream
}
xs << xml::EndTag("authorgroup");
xs << xml::CR();
-
-   return docstring();
 }
 
 } // namespace lyx
diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h
index f4051bf225..7a8ffb9081 100644
--- a/src/BiblioInfo.h
+++ b/src/BiblioInfo.h
@@ -37,7 +37,7 @@ CitationStyle citationStyleFromString(std::string const & 
latex_str,
 std::string citationStyleToString(CitationStyle const &, bool const latex = 
false);
 
 /// Transforms the information about authors into a  (directly 
written to a XMLStream).
-docstring authorsToDocBookAuthorGroup(docstring const & authorsString, 
XMLStream & xs, Buffer const & buf);
+void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & 
xs, Buffer const & buf);
 
 
 /// Class to represent information about a BibTeX or
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] DocBook: support bookauthor in bibliographies.

2024-03-01 Thread Thibaut Cuvelier
commit e3020a6b2d240d0e1ae2aec8dfd754f6cd64dee1
Author: Thibaut Cuvelier 
Date:   Fri Mar 1 12:55:40 2024 +0100

DocBook: support bookauthor in bibliographies.
---
 autotests/export/docbook/basic.bib | 11 +++
 autotests/export/docbook/basic.lyx |  2 +-
 autotests/export/docbook/basic.xml | 31 +--
 src/insets/InsetBibtex.cpp | 25 ++---
 4 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/autotests/export/docbook/basic.bib 
b/autotests/export/docbook/basic.bib
index 88a9fe7b14..b106326c4d 100644
--- a/autotests/export/docbook/basic.bib
+++ b/autotests/export/docbook/basic.bib
@@ -107,3 +107,14 @@ volume = {MCMXCVII},
   month= 7,
   note = {An optional note}
 }
+
+@incollection{Foucault:Kritik-EN92,
+author = {Foucault, Michel},
+title = {What is Critique?},
+bookauthor = {Foucault, Michel},
+booktitle = {The Politics of Truth},
+pages = {41-82},
+publisher = {Semiotext(e)},
+address = {Los Angeles},
+year = {1997}
+}
diff --git a/autotests/export/docbook/basic.lyx 
b/autotests/export/docbook/basic.lyx
index d1078b9721..83b907fb54 100644
--- a/autotests/export/docbook/basic.lyx
+++ b/autotests/export/docbook/basic.lyx
@@ -876,7 +876,7 @@ Many things,
  
 \begin_inset CommandInset citation
 LatexCommand cite
-key "article,book,booklet,conference,inbook,incollection"
+key "article,book,booklet,conference,inbook,incollection,Foucault:Kritik-EN92"
 literal "false"
 
 \end_inset
diff --git a/autotests/export/docbook/basic.xml 
b/autotests/export/docbook/basic.xml
index 2248a2cbf4..cafbe46547 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -264,7 +264,7 @@ I am no more code. 
 
 I am the sixth section and I really like bibliographies
 This text has references. First reference: . 
Second reference: . Both at the same time: 
, . A book: . 
-Many things, just testing for completeness: , , , , , . 
+Many things, just testing for completeness: , , , , , , . 
 
 
 I am the seventh section and I deal with indices
@@ -358,12 +358,17 @@ I am no more code. 
 
 
 The title of the work
+4
+3
 201-213
 inbook
 
 The name of the publisher
-
+The address of the publisher
 1993
+
+
+
 
 
 
@@ -372,6 +377,7 @@ I am no more code. 
 
 
 
+An optional note
 
 
 The title of the work
@@ -399,6 +405,27 @@ I am no more code. 
 
 An optional note
 
+
+What is Critique?
+41-82
+incollection
+
+Semiotext(e)
+Los Angeles
+1997
+
+The Politics of Truth
+
+
+
+
+Michel
+Foucault
+
+
+
+
+
 
 A small paper
 -1
diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index 2e6f7f7fb7..b4bf535014 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1142,6 +1142,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
// Store the mapping between BibTeX and DocBook.
map toDocBookTag;
toDocBookTag["fullnames:author"] = "SPECIFIC"; // No direct translation 
to DocBook: .
+   toDocBookTag["fullbynames:bookauthor"] = "SPECIFIC"; // No direct 
translation to DocBook: .
toDocBookTag["publisher"] = "SPECIFIC"; // No direct translation to 
DocBook: .
toDocBookTag["address"] = "SPECIFIC"; // No direct translation to 
DocBook: .
toDocBookTag["editor"] = "SPECIFIC";  // No direct translation to 
DocBook: .
@@ -1401,11 +1402,29 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
 
// 
// Example: 
http://tdg.docbook.org/tdg/5.1/authorgroup.html
-   if (hasTag("fullnames:author")) {
+   if (hasTag("fullnames:author") || 
hasTag("fullbynames:bookauthor")) {
+   // If several author tags are present, only 
output one.
+   const docstring authorName = getTag(
+   hasTag("fullnames:author") ? 
"fullnames:author" : "fullbynames:bookauthor");
+
// Perform full parsing of the BibTeX string, 
dealing with the many corner cases that might
// be encountered.
-   
authorsToDocBookAuthorGroup(getTag("fullnames:author"), xs, buffer());
-   eraseTag("fullnames:author");
+   authorsToDocBookAuthorGroup(authorName, xs, 
buffer());
+
+   if (hasTag("fullnames:author") && 
hasTag("fullbynames:bookauthor")) {
+   xs << XMLStream::ESCAPE_NONE <<
+  from_utf8(

[LyX/master] Amend 8e0bc01d

2024-02-26 Thread Thibaut Cuvelier
commit 27c01ee1d37e979f044329bcf07b9e910ed2b7ad
Author: Thibaut Cuvelier 
Date:   Tue Feb 27 00:45:10 2024 +0100

Amend 8e0bc01d

std::set::find only appeared in C++20. Rather use std::set::find for 
compatibility.
---
 src/insets/InsetBibtex.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index 8a2a697648..2e6f7f7fb7 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1220,7 +1220,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
if (docbookTag == "SPECIFIC") {
delayedTags[match[1]] = match[2];
} else {
-   if 
(alreadyOutputDocBookTags.contains(docbookTag)) {
+   if 
(alreadyOutputDocBookTags.find(docbookTag) != alreadyOutputDocBookTags.end()) {
xs << XMLStream::ESCAPE_NONE <<
   from_utf8("

[LyX/master] DocBook: in a table, fix a typo in a condition.

2024-02-26 Thread Thibaut Cuvelier
commit baccce7d2de92dcf57eb2afa8492e56a4805b1af
Author: Thibaut Cuvelier 
Date:   Mon Feb 26 16:09:26 2024 +0100

DocBook: in a table, fix a typo in a condition.

Before this patch, all table cells had a semicolon at the beginning of 
their style:


+
 Table 1
 
-
+
 Table 2
 
-
+
 Table 3
 
 
 
-
+
 Row 1
 
-
-
+
+
 Col 3, row 1
 
 
 
-
+
 Row 2
 
-
-
+
+
 Col 3, row 2
 
 
@@ -187,31 +187,31 @@ I am no more code. 
 I am a table caption above the table.
 
 
-
+
 Table 1
 
-
+
 Table 2
 
-
+
 Table 3
 
 
 
-
+
 Row 1
 
-
-
+
+
 Col 3, row 1
 
 
 
-
+
 Row 2
 
-
-
+
+
 Col 3, row 2
 
 
@@ -220,31 +220,31 @@ I am no more code. 
 
 
 
-
+
 Table that has no caption 1
 
-
+
 Table that has no caption 2
 
-
+
 Table that has no caption 3
 
 
 
-
+
 Row 1
 
-
-
+
+
 Col 3, row 1
 
 
 
-
+
 Row 2
 
-
-
+
+
 Col 3, row 2
 
 
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 9b4f175f74..5242775e7f 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -3842,7 +3842,7 @@ docstring Tabular::xmlRow(XMLStream & xs, const row_type 
row, OutputParams const
const std::vector styles = 
computeCssStylePerCell(row, c, cell);
 
std::string attr_str_prefix = "style='" + style.str();
-   if (!styles.empty())
+   if (!style.str().empty())
attr_str_prefix += "; ";
for (auto it = styles.begin(); it != styles.end(); 
++it) {
attr_str_prefix += *it;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] DocBook: when a similar tag is present multiple times in the bibliography entry, output it only once.

2024-02-26 Thread Thibaut Cuvelier
commit 8e0bc01d50fc7d7af454cb8bed4d098f85b3f73b
Author: Thibaut Cuvelier 
Date:   Mon Feb 26 16:04:22 2024 +0100

DocBook: when a similar tag is present multiple times in the bibliography 
entry, output it only once.

Other copies have an error message.
---
 autotests/export/docbook/basic.xml | 32 +++
 src/insets/InsetBibtex.cpp | 80 ++
 2 files changed, 68 insertions(+), 44 deletions(-)

diff --git a/autotests/export/docbook/basic.xml 
b/autotests/export/docbook/basic.xml
index 87c951f359..c03a26c12d 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -1,5 +1,5 @@
 
-
 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">
 
@@ -67,30 +67,8 @@
 
  
   
-   
-
- I
- a
- m
- a
- f
- o
- r
- m
- u
- l
- a
- w
- i
- t
- h
- a
- r
- e
- f
- .
-
-   
+   Iamaformulawitharef
+   .
   
   
(1)
@@ -285,8 +263,8 @@ I am no more code. 
 
 
 I am the sixth section and I really like bibliographies
-This text has references. First reference: . 
Second reference: . Both at the same time: 
, . A book: . 
-Many things, just testing for completeness: , , , , , . 
+This text has references. First reference: . 
Second reference: . Both at the same time: 
, . A book: . 
+Many things, just testing for completeness: , , , , , . 
 
 
 I am the seventh section and I deal with indices
diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index 6d38631f81..8a2a697648 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1128,7 +1128,6 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
make_pair("url", "uri")
};
// Relations between documents.
-   // TODO: some elements should be mutually exclusive; right now, all of 
them are output.
vector> relations = { // 
make_pair("journal", "journal"),
make_pair("journaltitle", "journal"),
@@ -1149,7 +1148,6 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
toDocBookTag["fullbynames:editor"] = "SPECIFIC";  // No direct 
translation to DocBook: .
toDocBookTag["institution"] = "SPECIFIC"; // No direct translation to 
DocBook: .
 
-   // TODO: some elements should be mutually exclusive; right now, all of 
them are output.
toDocBookTag["title"] = "title";
toDocBookTag["fulltitle"] = "title";
toDocBookTag["quotetitle"] = "title";
@@ -1162,7 +1160,6 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
toDocBookTag["year"] = "SPECIFIC"; // No direct translation to DocBook: 
.
toDocBookTag["month"] = "SPECIFIC"; // No direct translation to 
DocBook: .
 
-   // TODO: some elements should be mutually exclusive; right now, all of 
them are output.
toDocBookTag["journal"] = "SPECIFIC"; // No direct translation to 
DocBook: .
toDocBookTag["journaltitle"] = "SPECIFIC"; // No direct translation to 
DocBook: .
toDocBookTag["fulljournaltitle"] = "SPECIFIC"; // No direct translation 
to DocBook: .
@@ -1210,22 +1207,35 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
map delayedTags;
 
// Read all tags from HTML and convert those that have a 1:1 
matching.
+   // Avoid outputting the same tag twice in DocBook: several 
bibliography tags might map to the same DocBook
+   // element, avoid outputting the same DocBook tag twice to keep 
a valid output. "SPECIFIC" tags are handled in
+   // a more specific way later on (among the delayed tags).
+   set alreadyOutputDocBookTags;
while (tagIt != tagEnd) {
string tag = tagIt->str(); // regex_match cannot work 
with temporary strings.
++tagIt;
 
if (regex_match(tag, match, tagRegex)) {
-   if (toDocBookTag[match[1]] == "SPECIFIC") {
+   const string docbookTag = 
toDocBookTag[match[1]];
+   if (docbookTag == "SPECIFIC") {
delayedTags[match[1]] = match[2];
} else {
-   xs << 
xml::StartTag(toDocBookTag[match[1]]);
- 

[LyX/master] DocBook: in bibliographies, fix support for editors.

2024-02-26 Thread Thibaut Cuvelier
commit 2be72a1534af143bda34b382189198667c10136b
Author: Thibaut Cuvelier 
Date:   Mon Feb 26 15:50:12 2024 +0100

DocBook: in bibliographies, fix support for editors.

Also, add TODOs for similar problems lurking around.
---
 autotests/export/docbook/basic.xml | 57 +++---
 src/insets/InsetBibtex.cpp | 38 -
 2 files changed, 65 insertions(+), 30 deletions(-)

diff --git a/autotests/export/docbook/basic.xml 
b/autotests/export/docbook/basic.xml
index b589ee63b9..87c951f359 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -1,7 +1,7 @@
 
 
-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">
+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">
 
 I am a title
 
@@ -24,43 +24,39 @@
 
  
 
- 
-  
-  w
-  i
-  t
-  h
-  
-  a
-  
-  f
-  o
-  r
-  m
-  u
-  l
-  a
- 
+ 
+ w
+ i
+ t
+ h
+ 
+ a
+ 
+ f
+ o
+ r
+ m
+ u
+ l
+ a
 
 
 . 
 
-Now, we're outside quotes.
+Now, were outside quotes.
 
 Formula!
 
  
 
- 
-  F
-  o
-  r
-  m
-  u
-  l
-  a
-  !
- 
+ F
+ o
+ r
+ m
+ u
+ l
+ a
+ !
 
 
 
@@ -420,6 +416,9 @@ I am no more code. 
 
 
 
+
+The editor
+
 An optional note
 
 
diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index b073f619e6..6d38631f81 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1128,6 +1128,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
make_pair("url", "uri")
};
// Relations between documents.
+   // TODO: some elements should be mutually exclusive; right now, all of 
them are output.
vector> relations = { // 
make_pair("journal", "journal"),
make_pair("journaltitle", "journal"),
@@ -1144,9 +1145,11 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
toDocBookTag["fullnames:author"] = "SPECIFIC"; // No direct translation 
to DocBook: .
toDocBookTag["publisher"] = "SPECIFIC"; // No direct translation to 
DocBook: .
toDocBookTag["address"] = "SPECIFIC"; // No direct translation to 
DocBook: .
-   toDocBookTag["editor"] = "editor";
+   toDocBookTag["editor"] = "SPECIFIC";  // No direct translation to 
DocBook: .
+   toDocBookTag["fullbynames:editor"] = "SPECIFIC";  // No direct 
translation to DocBook: .
toDocBookTag["institution"] = "SPECIFIC"; // No direct translation to 
DocBook: .
 
+   // TODO: some elements should be mutually exclusive; right now, all of 
them are output.
toDocBookTag["title"] = "title";
toDocBookTag["fulltitle"] = "title";
toDocBookTag["quotetitle"] = "title";
@@ -1159,6 +1162,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
toDocBookTag["year"] = "SPECIFIC"; // No direct translation to DocBook: 
.
toDocBookTag["month"] = "SPECIFIC"; // No direct translation to 
DocBook: .
 
+   // TODO: some elements should be mutually exclusive; right now, all of 
them are output.
toDocBookTag["journal"] = "SPECIFIC"; // No direct translation to 
DocBook: .
toDocBookTag["journaltitle"] = "SPECIFIC"; // No direct translation to 
DocBook: .
toDocBookTag["fulljournaltitle"] = "SPECIFIC"; // No direct translation 
to DocBook: .
@@ -1359,6 +1363,38 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
eraseTag("fullnames:author");
}
 
+   // 
+   // Example: http://tdg.docbook.org/tdg/5.1/editor.html
+   if (hasTag("editor") || hasTag("fullbynames:editor")) {
+   // If several editor tags are present, only 
output one.
+   const docstring editorName = 
getTag(hasTag("editor") ? "editor" : "fullbynames:editor");
+
+   // Arbitrarily decide that the editor is always 
a person. There is no reliable information in the input
+   // to make the distinction between a person 
() and an organisation ().
+   xs << xml::StartTag("editor"

[LyX/master] Use C++11 string literals to make code easier to read.

2024-02-26 Thread Thibaut Cuvelier
commit 6b1441036f35767c0b60af510222ba792b17b829
Author: Thibaut Cuvelier 
Date:   Mon Feb 26 15:24:36 2024 +0100

Use C++11 string literals to make code easier to read.
---
 src/insets/InsetIndex.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index 68669b0b7e..64bb398099 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -505,9 +505,9 @@ void InsetIndex::docbook(XMLStream & xs, OutputParams const 
& runparams) const
// Generate the attributes.
docstring id = xml::cleanID(newIndexTerms);
if (hasStartRange) {
-   attrs = indexType + " class=\"startofrange\" 
xml:id=\"" + id + "\"";
+   attrs = indexType + R"( class="startofrange" 
xml:id=")" + id + "\"";
} else {
-   attrs = " class=\"endofrange\" startref=\"" + 
id + "\"";
+   attrs = R"( class="endofrange" startref=")" + 
id + "\"";
}
}
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] DocBook: restore index ranges.

2024-02-26 Thread Thibaut Cuvelier
commit 3fdf3aafe8a2da25c10152c97e6e7824ace42e96
Author: Thibaut Cuvelier 
Date:   Mon Feb 26 15:15:32 2024 +0100

DocBook: restore index ranges.
---
 src/insets/InsetIndex.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index 54058b8ea7..68669b0b7e 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -386,7 +386,10 @@ void InsetIndex::docbook(XMLStream & xs, OutputParams 
const & runparams) const
}
 
// Handle ranges. Happily, in the raw LaTeX mode, (| and |) can only be 
at the end of the string!
-   const bool hasInsetRange = params_.range != 
InsetIndexParams::PageRange::None;
+   // Handle both modern ranges (params_.range) and legacy ones (with a 
suffix |( or |) as in pure LaTeX).
+   const bool hasInsetRange = params_.range != 
InsetIndexParams::PageRange::None ||
+   latexString.find(from_ascii("|(")) != 
lyx::docstring::npos ||
+   latexString.find(from_ascii("|)")) != 
lyx::docstring::npos;
const bool hasStartRange = params_.range == 
InsetIndexParams::PageRange::Start ||
latexString.find(from_ascii("|(")) != 
lyx::docstring::npos;
const bool hasEndRange = params_.range == 
InsetIndexParams::PageRange::End ||
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] DocBook: simplify building an error message.

2024-02-26 Thread Thibaut Cuvelier
commit 5dd36404f2234395aa709f3723607a485e464dbb
Author: Thibaut Cuvelier 
Date:   Mon Feb 26 15:09:10 2024 +0100

DocBook: simplify building an error message.
---
 src/insets/InsetIndex.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index c7e88f0cd2..54058b8ea7 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -450,7 +450,7 @@ void InsetIndex::docbook(XMLStream & xs, OutputParams const 
& runparams) const
// TODO: Could handle formatting as significance="preferred"?
if (!command.empty()) {
docstring error = from_utf8("Unsupported feature: an index 
entry contains a | with an unsupported command, ")
- + command + from_utf8(". ") + 
from_utf8("Complete entry: \"") + latexString + from_utf8("\"");
+ + command + from_utf8(". Complete 
entry: \"") + latexString + from_utf8("\"");
LYXERR0(error);
xs << XMLStream::ESCAPE_NONE << (from_utf8("\n"));
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] DocBook: update bibliography handling for 337f9534260.

2024-02-26 Thread Thibaut Cuvelier
commit c71f7039148ba112ed3d0e56b19bce063a04323a
Author: Thibaut Cuvelier 
Date:   Mon Feb 26 14:36:01 2024 +0100

DocBook: update bibliography handling for 337f9534260.
---
 autotests/export/docbook/basic.lyx | 129 -
 src/insets/InsetBibtex.cpp |   8 +++
 2 files changed, 105 insertions(+), 32 deletions(-)

diff --git a/autotests/export/docbook/basic.lyx 
b/autotests/export/docbook/basic.lyx
index 3c4a5b6fb0..d1078b9721 100644
--- a/autotests/export/docbook/basic.lyx
+++ b/autotests/export/docbook/basic.lyx
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 599
+\lyxformat 620
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -57,6 +57,7 @@
 \suppress_date false
 \justification true
 \use_refstyle 1
+\use_formatted_ref 0
 \use_minted 0
 \use_lineno 0
 \index Index
@@ -87,6 +88,7 @@
 \html_css_as_file 0
 \html_be_strict false
 \docbook_table_output 0
+\docbook_mathml_prefix 1
 \end_header
 
 \begin_body
@@ -147,7 +149,8 @@ I am a quote
 \end_layout
 
 \begin_layout Standard
-Now, we're outside quotes.
+Now,
+ we're outside quotes.
 \end_layout
 
 \begin_layout Standard
@@ -177,6 +180,7 @@ reference "sec:Sec-2kqgsdiflhqsdlifgjuzer=povtuizmvnuer=t 
vmsrmfli  uh =a'\"rtpf
 plural "false"
 caps "false"
 noprefix "false"
+nolink "false"
 
 \end_inset
 
@@ -184,8 +188,9 @@ noprefix "false"
 \end_layout
 
 \begin_layout Standard
-Also, a formula with an user-defined macro that outputs well in LaTeX but
- cannot in MathML: 
+Also,
+ a formula with an user-defined macro that outputs well in LaTeX but cannot in 
MathML:
+ 
 \begin_inset Formula $\testmacro$
 \end_inset
 
@@ -268,6 +273,7 @@ reference "sec:Sec-1"
 plural "false"
 caps "false"
 noprefix "false"
+nolink "false"
 
 \end_inset
 
@@ -284,7 +290,8 @@ First item.
 \begin_inset Newline newline
 \end_inset
 
-Second line of the first item, after a line break.
+Second line of the first item,
+ after a line break.
  
 \end_layout
 
@@ -365,7 +372,8 @@ I repeat that in a footnote.
 \end_layout
 
 \begin_layout Standard
-On the other hand, 
+On the other hand,
+ 
 \begin_inset Foot
 status open
 
@@ -392,7 +400,9 @@ I am the fifth section and I deal with floats
 \end_layout
 
 \begin_layout Standard
-Now, three tables: 
+Now,
+ three tables:
+ 
 \end_layout
 
 \begin_layout Standard
@@ -463,7 +473,8 @@ Row 1
 \begin_inset Text
 
 \begin_layout Plain Layout
-Col 3, row 1
+Col 3,
+ row 1
 \end_layout
 
 \end_inset
@@ -492,7 +503,8 @@ Row 2
 \begin_inset Text
 
 \begin_layout Plain Layout
-Col 3, row 2
+Col 3,
+ row 2
 \end_layout
 
 \end_inset
@@ -602,7 +614,8 @@ Row 1
 \begin_inset Text
 
 \begin_layout Plain Layout
-Col 3, row 1
+Col 3,
+ row 1
 \end_layout
 
 \end_inset
@@ -631,7 +644,8 @@ Row 2
 \begin_inset Text
 
 \begin_layout Plain Layout
-Col 3, row 2
+Col 3,
+ row 2
 \end_layout
 
 \end_inset
@@ -717,7 +731,8 @@ Row 1
 \begin_inset Text
 
 \begin_layout Plain Layout
-Col 3, row 1
+Col 3,
+ row 1
 \end_layout
 
 \end_inset
@@ -746,7 +761,8 @@ Row 2
 \begin_inset Text
 
 \begin_layout Plain Layout
-Col 3, row 2
+Col 3,
+ row 2
 \end_layout
 
 \end_inset
@@ -765,7 +781,9 @@ Col 3, row 2
 \end_layout
 
 \begin_layout Standard
-Then, one figure: 
+Then,
+ one figure:
+ 
 \end_layout
 
 \begin_layout Standard
@@ -809,7 +827,8 @@ I am the sixth section and I really like bibliographies
 
 \begin_layout Standard
 This text has references.
- First reference: 
+ First reference:
+ 
 \begin_inset CommandInset citation
 LatexCommand cite
 key "big"
@@ -818,7 +837,8 @@ literal "false"
 \end_inset
 
 .
- Second reference: 
+ Second reference:
+ 
 \begin_inset CommandInset citation
 LatexCommand cite
 key "small"
@@ -827,7 +847,8 @@ literal "false"
 \end_inset
 
 .
- Both at the same time: 
+ Both at the same time:
+ 
 \begin_inset CommandInset citation
 LatexCommand cite
 key "big,small"
@@ -836,7 +857,8 @@ literal "false"
 \end_inset
 
 .
- A book: 
+ A book:
+ 
 \begin_inset CommandInset citation
 LatexCommand cite
 key "Gro60"
@@ -849,7 +871,9 @@ literal "false"
 \end_layout
 
 \begin_layout Standard
-Many things, just testing for completeness: 
+Many things,
+ just testing for completeness:
+ 
 \begin_inset CommandInset citation
 LatexCommand cite
 key "article,book,booklet,conference,inbook,incollection"
@@ -866,8 +890,12 @@ I am the seventh section and I deal with indices
 \end_layout
 
 \begin_layout Standard
-First, a term to index: 
+First,
+ a term to index:
+ 
 \begin_inset Index idx
+range none
+pageformat default
 status open
 
 \begin_layout Plain Layout
@@ -877,8 +905,11 @@ Term to index
 \end_inset
 
 .
- Then a term to add to the second index: 
+ Then a term to add to the second index:
+ 
 \begin_inset Index oth
+range none
+pageformat defa

[LyX/master] Update comment: a function was renamed.

2024-02-25 Thread Thibaut Cuvelier
commit e311606a30d0cbc3603a0187f68dd6a44fd402cd
Author: Thibaut Cuvelier 
Date:   Mon Feb 26 02:17:48 2024 +0100

Update comment: a function was renamed.
---
 src/insets/InsetBibitem.cpp | 2 +-
 src/output_docbook.cpp  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp
index 82d8185200..6336da32d4 100644
--- a/src/insets/InsetBibitem.cpp
+++ b/src/insets/InsetBibitem.cpp
@@ -344,7 +344,7 @@ void InsetBibitem::updateBuffer(ParIterator const & it, 
UpdateType utype, bool c
 
 void InsetBibitem::docbook(XMLStream &, OutputParams const &) const
 {
-   // Nothing to do: everything is implemented in 
makeParagraphBibliography.
+   // Nothing to do: everything is implemented in makeBibliography.
 }
 
 
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 983d4e7bef..204fc430f7 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -382,7 +382,7 @@ void makeParagraph(
TABULAR_CODE,
FLOAT_CODE,
BIBTEX_CODE, // Bibliographies cannot be in paragraphs. 
Bibitems should still be handled as paragraphs,
-   // though (see makeParagraphBibliography).
+   // though (see makeBibliography).
ERT_CODE, // ERTs are in comments, not paragraphs.
LISTINGS_CODE,
BOX_CODE,
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetMathHull: add a missing const (plus strange indentation fixed).

2023-01-21 Thread Thibaut Cuvelier
commit fca8e542890c841ac95209c7714c591308372491
Author: Thibaut Cuvelier 
Date:   Sun Jan 22 02:45:25 2023 +0100

InsetMathHull: add a missing const (plus strange indentation fixed).
---
 src/mathed/InsetMathHull.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 9c4e6e9..537d667 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2582,7 +2582,7 @@ void InsetMathHull::mathmlize(MathMLStream & ms) const
 void InsetMathHull::mathAsLatex(TeXMathStream & os) const
 {
MathEnsurer ensurer(os, false);
-   bool havenumbers = haveNumbers();
+   bool const havenumbers = haveNumbers();
bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
 
if (!havetable) {
@@ -2603,7 +2603,7 @@ void InsetMathHull::mathAsLatex(TeXMathStream & os) const
docstring const & num = numbers_[row];
if (!num.empty())
os << '(' << num << ')';
- os << "";
+   os << "";
}
os << "";
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetMathHull: replace 0 by nullptr.

2023-01-21 Thread Thibaut Cuvelier
commit e7d57338b955a60b26cc60e9674d4b5937f37169
Author: Thibaut Cuvelier 
Date:   Sun Jan 22 01:25:03 2023 +0100

InsetMathHull: replace 0 by nullptr.
---
 src/mathed/InsetMathHull.cpp |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 0bb9b8e..8fbd5c2 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -148,7 +148,7 @@ namespace {
 } // namespace
 
 
-static InsetLabel * dummy_pointer = 0;
+static InsetLabel * dummy_pointer = nullptr;
 
 InsetMathHull::InsetMathHull(Buffer * buf)
: InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, NONUMBER),
@@ -703,7 +703,7 @@ static docstring latexString(InsetMathHull const & inset)
// \newcommand{\xxx}{\text{$\phi$}}) gets processed twice. The
// first time as a whole, and the second time only the inner math.
// In this last case inset.buffer() would be invalid.
-   static Encoding const * encoding = 0;
+   static Encoding const * encoding = nullptr;
if (inset.isBufferValid())
encoding = &(inset.buffer().params().encoding());
otexrowstream ots(ls);
@@ -1356,7 +1356,7 @@ void InsetMathHull::glueall(HullType type)
MathData ar;
for (idx_type i = 0; i < nargs(); ++i)
ar.append(cell(i));
-   InsetLabel * label = 0;
+   InsetLabel * label = nullptr;
if (type == hullEquation) {
// preserve first non-empty label
for (row_type row = 0; row < nrows(); ++row) {
@@ -2741,7 +2741,7 @@ docstring InsetMathHull::xhtml(XMLStream & xs, 
OutputParams const & op) const
 void InsetMathHull::toString(odocstream & os) const
 {
odocstringstream ods;
-   plaintext(ods, OutputParams(0));
+   plaintext(ods, OutputParams(nullptr));
os << ods.str();
 }
 
@@ -2749,7 +2749,7 @@ void InsetMathHull::toString(odocstream & os) const
 void InsetMathHull::forOutliner(docstring & os, size_t const, bool const) const
 {
odocstringstream ods;
-   OutputParams op(0);
+   OutputParams op(nullptr);
op.for_toc = true;
// FIXME: this results in spilling TeX into the LyXHTML output since the
// outliner is used to generate the LyXHTML list of figures/etc.
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: make InsetMathHull::mathmlize easier to read while doing less work

2023-01-21 Thread Thibaut Cuvelier
commit d066a66a51b423ece3588198b6d29a9a67ac49b5
Author: Thibaut Cuvelier 
Date:   Sun Jan 22 01:49:03 2023 +0100

MathML: make InsetMathHull::mathmlize easier to read while doing less work

If `havetable == true`, a lot of the code didn't make any sense: in 
particular, it was outputting a level of  too many.

Also, add some comments and rewrite the comment about mlabeledtr.

Contributed by lynx: https://www.lyx.org/trac/ticket/12629
---
 src/mathed/InsetMathHull.cpp |   52 ++---
 1 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 8fbd5c2..9c4e6e9 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2532,33 +2532,37 @@ void InsetMathHull::mathmlize(MathMLStream & ms) const
 {
bool const havetable = haveNumbers() || nrows() > 1 || ncols() > 1;
 
-if (havetable) {
-if (getType() == hullSimple) {
-   ms << MTag("mtable");
-} else if (getType() >= hullAlign && getType() <= hullXXAlignAt) {
-string alignment;
-for (col_type col = 0; col < ncols(); ++col) {
-alignment += (col % 2) ? "left " : "right ";
-}
-ms << MTag("mtable", "displaystyle='true' columnalign='" + 
alignment + "'");
-   } else {
-   ms << MTag("mtable", "displaystyle='true'");
+   // Simplest case: single row, single column, no numbering.
+   if (!havetable) {
+   ms << cell(index(0, 0));
+   return;
+   }
+
+   // More complex case: wrap elements in a table.
+if (getType() == hullSimple) {
+ms << MTag("mtable");
+} else if (getType() >= hullAlign && getType() <= hullXXAlignAt) {
+   // hullAlign, hullAlignAt, hullXAlignAt, hullXXAlignAt
+string alignment;
+for (col_type col = 0; col < ncols(); ++col) {
+alignment += (col % 2) ? "left " : "right ";
 }
+ms << MTag("mtable", "displaystyle='true' columnalign='" + alignment + 
"'");
+} else {
+ms << MTag("mtable", "displaystyle='true'");
 }
 
-   char const * const celltag = havetable ? "mtd" : "mrow";
-   // FIXME There does not seem to be wide support at the moment
-   // for mlabeledtr, so we have to use just mtr for now.
-   // char const * const rowtag = haveNumbers() ? "mlabeledtr" : "mtr";
-   char const * const rowtag = "mtr";
for (row_type row = 0; row < nrows(); ++row) {
-   if (havetable)
-   ms << MTag(rowtag);
+   // No Wed browser supports mlabeledtr in 2023, even though it 
has been introduced in
+   // MathML 2 (2003). Moreover, it is not supported in MathML 4 
Core.
+   ms << MTag("mtr");
+
for (col_type col = 0; col < ncols(); ++col) {
-   ms << MTag(celltag)
+   ms << MTag("mtd")
   << cell(index(row, col))
-  << ETag(celltag);
+  << ETag("mtd");
}
+
// fleqn?
if (haveNumbers()) {
ms << MTag("mtd");
@@ -2567,11 +2571,11 @@ void InsetMathHull::mathmlize(MathMLStream & ms) const
ms << MTagInline("mtext") << '(' << num << ')' 
<< ETagInline("mtext");
ms << ETag("mtd");
}
-   if (havetable)
-   ms << ETag(rowtag);
+
+   ms << ETag("mtr");
}
-   if (havetable)
-   ms << ETag("mtable");
+
+   ms << ETag("mtable");
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: remove useless code

2023-01-19 Thread Thibaut Cuvelier
commit 5f7c26fbe52e2a55039996ad267e553dabbe9aa9
Author: Thibaut Cuvelier 
Date:   Fri Jan 20 02:19:33 2023 +0100

MathML: remove useless code

Contributed by lynx: https://www.lyx.org/trac/ticket/12629
---
 src/mathed/InsetMathChar.cpp |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index a5001fc..483bbb8 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -258,8 +258,6 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
char const * type =
(isAlphaASCII(char_) || Encodings::isMathAlpha(char_))
? "mi" : "mo";
-   // we don't use MTag and ETag because we do not want the spacing before 
the end tag.
-   docstring tag = from_ascii(ms.namespacedTag(type));
ms << MTagInline(type)
   << char_type(char_)
   << ETagInline(type);
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: use standard {M/E}Tag{, Inline} instead of bespoke constructs

2023-01-19 Thread Thibaut Cuvelier
commit bf0da33c9a0af098fd9c4f1bd96bc8cb964ab878
Author: Thibaut Cuvelier 
Date:   Fri Jan 20 02:21:27 2023 +0100

MathML: use standard {M/E}Tag{,Inline} instead of bespoke constructs

Also, replace lspace='thinmathspace' by constructs that are not deprecated.

Contributed by lynx: https://www.lyx.org/trac/ticket/12629
---
 src/mathed/InsetMathDecoration.cpp |4 ++--
 src/mathed/InsetMathExInt.cpp  |8 ++--
 src/mathed/InsetMathFrac.cpp   |   12 ++--
 src/mathed/InsetMathMacro.cpp  |4 +---
 src/mathed/InsetMathMatrix.cpp |9 +
 src/mathed/InsetMathOverset.cpp|4 ++--
 src/mathed/InsetMathSideset.cpp|   10 +-
 src/mathed/InsetMathStackrel.cpp   |8 
 src/mathed/InsetMathSymbol.cpp |5 ++---
 src/mathed/InsetMathUnderset.cpp   |   10 +-
 src/mathed/InsetMathXArrow.cpp |4 ++--
 11 files changed, 36 insertions(+), 42 deletions(-)

diff --git a/src/mathed/InsetMathDecoration.cpp 
b/src/mathed/InsetMathDecoration.cpp
index e0a5d85..96323bf 100644
--- a/src/mathed/InsetMathDecoration.cpp
+++ b/src/mathed/InsetMathDecoration.cpp
@@ -246,9 +246,9 @@ void InsetMathDecoration::mathmlize(MathMLStream & ms) const
std::string decoration = cur->second.entity;
ms << MTag(outag)
   << cell(0)
-  << "<" << from_ascii(ms.namespacedTag("mo")) << " stretchy=\"true\">"
+  << MTagInline("mo", "stretchy='true'")
   << from_ascii(decoration)
-  << ""
+  << ETagInline("mo")
   << ETag(outag);
 }
 
diff --git a/src/mathed/InsetMathExInt.cpp b/src/mathed/InsetMathExInt.cpp
index c5c7262..03f516d 100644
--- a/src/mathed/InsetMathExInt.cpp
+++ b/src/mathed/InsetMathExInt.cpp
@@ -152,13 +152,9 @@ void InsetMathExInt::mathmlize(MathMLStream & ms) const
else if (upper)
ms << ETag("msup");
ms << cell(0)
-  << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
-  << "  "
-   << ""
+  << MTagInline("mo") << "" << ETagInline("mo") // 

   << MTag("mrow")
-  << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
-  << "  "
-  << ""
+  << MTagInline("mo") << "" << ETagInline("mo") // 

   << cell(1)
   << ETag("mrow");
 }
diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index 4ce758e..f6f2f95 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -768,15 +768,15 @@ void InsetMathBinom::mathmlize(MathMLStream & ms) const
rdelim = ']';
break;
}
-   ms << "<" << from_ascii(ms.namespacedTag("mo")) << " fence='true' 
stretchy='true' form='prefix'>"
+   ms << MTagInline("mo", "fence='true' stretchy='true' form='prefix'")
   << ldelim
-  << ""
-  << "<" << from_ascii(ms.namespacedTag("mfrac")) << " 
linethickness='0'>"
+  << ETagInline("mo")
+  << MTagInline("mfrac", "linethickness='0'")
   << cell(0) << cell(1)
-   << ""
-  << "<" << from_ascii(ms.namespacedTag("mo")) << " fence='true' 
stretchy='true' form='postfix'>"
+   << ETagInline("mfrac")
+  << MTagInline("mo", "fence='true' stretchy='true' form='postfix'")
   << rdelim
-  << "";
+  << ETagInline("mo");
 }
 
 
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index 8204aaa..1e36f5a 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -1306,9 +1306,7 @@ void InsetMathMacro::mathmlize(MathMLStream & ms) const
docstring const xmlname = d->macro_->xmlname();
if (!xmlname.empty()) {
char const * type = d->macro_->MathMLtype();
-   ms << "<" << from_ascii(ms.namespacedTag(type)) << ">"
-  << xmlname
-  << "";
+   ms << MTagInline(type) << xmlname << ETagInline(type);
   

[LyX/master] MathML: replace HTML entities with XML ones in more places

2023-01-19 Thread Thibaut Cuvelier
commit 66fab7038831874ab2466e60d094287e4fb8901a
Author: Thibaut Cuvelier 
Date:   Fri Jan 20 02:25:08 2023 +0100

MathML: replace HTML entities with XML ones in more places

This part should have been committed with bc73a857 in the first place.
---
 src/mathed/InsetMathExInt.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathExInt.cpp b/src/mathed/InsetMathExInt.cpp
index 4812eec..c5c7262 100644
--- a/src/mathed/InsetMathExInt.cpp
+++ b/src/mathed/InsetMathExInt.cpp
@@ -153,11 +153,11 @@ void InsetMathExInt::mathmlize(MathMLStream & ms) const
ms << ETag("msup");
ms << cell(0)
   << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
-  << "  "
+  << "  "
<< ""
   << MTag("mrow")
   << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
-  << "  "
+  << "  "
   << ""
   << cell(1)
   << ETag("mrow");
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: improve formatting of formula in XHTML hull

2023-01-19 Thread Thibaut Cuvelier
commit f9fd652aae3634f6eb3739b372811d1e7d6558f8
Author: Thibaut Cuvelier 
Date:   Fri Jan 20 02:42:07 2023 +0100

MathML: improve formatting of formula in XHTML hull

Contributed by lynx: https://www.lyx.org/trac/ticket/12629
---
 src/mathed/InsetMathHull.cpp |   20 +---
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 746da1d..f043882 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2632,15 +2632,21 @@ docstring InsetMathHull::xhtml(XMLStream & xs, 
OutputParams const & op) const
success = true;
} catch (MathExportException const &) {}
if (success) {
+   string const name_space_declaration = 
"xmlns='http://www.w3.org/1998/Math/MathML'";
if (getType() == hullSimple)
-   xs << xml::StartTag("math",
-   
"xmlns=\"http://www.w3.org/1998/Math/MathML\";, true);
-   else
-   xs << xml::StartTag("math",
- "display=\"block\" 
xmlns=\"http://www.w3.org/1998/Math/MathML\";, true);
+   xs << xml::StartTag("math", name_space_declaration, 
true);
+   else {
+   if (!xs.isLastTagCR())
+xs << xml::CR();
+   xs << xml::StartTag("math", name_space_declaration + " 
display='block'", true);
+   }
+
xs << XMLStream::ESCAPE_NONE
-<< os.str()
-<< xml::EndTag("math");
+  << os.str();
+
+   if (!xs.isLastTagCR())
+   xs << xml::CR();
+   xs << xml::EndTag("math") << xml::CR();
}
} else if (mathtype == BufferParams::HTML) {
odocstringstream os;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: remove extraneous in fractions

2023-01-19 Thread Thibaut Cuvelier
commit 0c227d3dfa48500d4889f8a39f627a7db8ad5666
Author: Thibaut Cuvelier 
Date:   Fri Jan 20 02:30:35 2023 +0100

MathML: remove extraneous  in fractions

Contributed by lynx: https://www.lyx.org/trac/ticket/12629
---
 src/mathed/InsetMathFrac.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index 2431f68..4ce758e 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -506,8 +506,8 @@ void InsetMathFrac::mathmlize(MathMLStream & ms) const
switch (kind_) {
case ATOP:
ms << MTag("mfrac", "linethickness='0'")
-  << MTag("mrow") << cell(0) << ETag("mrow")
-  << MTag("mrow") << cell(1) << ETag("mrow")
+  << cell(0)
+  << cell(1)
   << ETag("mfrac");
break;
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML in HTML: in case of conversion failure, add a comment

2023-01-19 Thread Thibaut Cuvelier
commit 598c6a0a879f604703f7fd9ce5d6a3fd03c983ef
Author: Thibaut Cuvelier 
Date:   Fri Jan 20 02:45:20 2023 +0100

MathML in HTML: in case of conversion failure, add a comment
---
 src/mathed/InsetMathHull.cpp |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index f043882..0bb9b8e 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2648,6 +2648,7 @@ docstring InsetMathHull::xhtml(XMLStream & xs, 
OutputParams const & op) const
xs << xml::CR();
xs << xml::EndTag("math") << xml::CR();
}
+   // In case of failure, generate an image.
} else if (mathtype == BufferParams::HTML) {
odocstringstream os;
HtmlStream ms(os);
@@ -2662,6 +2663,7 @@ docstring InsetMathHull::xhtml(XMLStream & xs, 
OutputParams const & op) const
   << os.str()
   << xml::EndTag(tag);
}
+   // In case of failure, generate an image.
}
 
// what we actually want is this:
@@ -2676,7 +2678,7 @@ docstring InsetMathHull::xhtml(XMLStream & xs, 
OutputParams const & op) const
//
// so this is for Images.
if (!success && mathtype != BufferParams::LaTeX) {
-   graphics::PreviewImage const * pimage = 0;
+   graphics::PreviewImage const * pimage = nullptr;
if (!op.dryrun) {
loadPreview(docit_);
pimage = preview_->getPreviewImage(buffer());
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML: remove meta content-type, it is only for HTML5, not XHTML5 (LyX is generating XML-compatible HTML, i.e. XHTML5).

2023-01-10 Thread Thibaut Cuvelier
commit 861af2b84f8e094a58f84112554e3f21ab78e05f
Author: Thibaut Cuvelier 
Date:   Wed Jan 11 01:12:22 2023 +0100

LyXHTML: remove meta content-type, it is only for HTML5, not XHTML5 (LyX is 
generating XML-compatible HTML, i.e. XHTML5).
---
 src/Buffer.cpp |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 2e43a15..4d7adc3 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2254,9 +2254,7 @@ Buffer::ExportStatus 
Buffer::writeLyXHTMLSource(odocstream & os,
os << "\n"
   << "http://www.w3.org/1999/xhtml\; lang=\"" << 
from_ascii(htmlCode) << "\">\n"
   << "\n"
-  << "\n"
-  // FIXME Presumably need to set this right
-  << "\n";
+  << "\n";
 
docstring const & doctitle = features.htmlTitle();
os << ""
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetTabular LyXHTML: fix wrong escape.

2023-01-10 Thread Thibaut Cuvelier
commit fb70f89983c8ca3d263ce6e73f058c3fb2f41c8f
Author: Thibaut Cuvelier 
Date:   Wed Jan 11 00:26:28 2023 +0100

InsetTabular LyXHTML: fix wrong escape.
---
 src/insets/InsetTabular.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 1ec96da..163f162 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -3677,7 +3677,7 @@ std::string Tabular::getHAlignAsCssAttribute(idx_type 
cell) const
// experimental.
// https://www.w3.org/TR/css-text-4/#character-alignment
Language const *lang = 
buffer().paragraphs().front().getParLanguage(buffer().params());
-   return "text-align: '" + to_utf8(lang->decimalSeparator()) + 
"'";
+   return "text-align: \"" + to_utf8(lang->decimalSeparator()) + 
"\"";
}
default:
return "text-align: center";
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] KOMA Book: fix HTML validation issues.

2023-01-10 Thread Thibaut Cuvelier
commit 65a9a2ac11be413273b3b0e0c4b8382a52b568a8
Author: Thibaut Cuvelier 
Date:   Wed Jan 11 00:21:23 2023 +0100

KOMA Book: fix HTML validation issues.

Some elements had a  title, while only one such title is expected per 
page.
---
 lib/layouts/scrbook.layout |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/layouts/scrbook.layout b/lib/layouts/scrbook.layout
index dcdc2bb..7058838 100644
--- a/lib/layouts/scrbook.layout
+++ b/lib/layouts/scrbook.layout
@@ -18,6 +18,7 @@ NoStyle Abstract
 Style Chapter
LabelString "\thechapter"
TocLevel 0
+   HTMLTag   h2
DocBookTagtitle
DocBookTagTypeparagraph
DocBookSectionTag chapter
@@ -36,8 +37,9 @@ Style Bibliography
TopSep  4
LabelString "Bibliography"
LabelFont
- SeriesBold
- Size  Largest
+ SeriesBold
+ Size  Largest
EndFont
TocLevel0
+   HTMLTag h2
 End
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Export tests: use a better function name.

2023-01-09 Thread Thibaut Cuvelier
commit 253d532974791d7606401590ad38f9641e26d127
Author: Thibaut Cuvelier 
Date:   Mon Jan 9 04:19:51 2023 +0100

Export tests: use a better function name.
---
 development/autotests/export.cmake |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/development/autotests/export.cmake 
b/development/autotests/export.cmake
index 0185d5b..aed57b8 100755
--- a/development/autotests/export.cmake
+++ b/development/autotests/export.cmake
@@ -195,7 +195,7 @@ macro(check_xhtml_xmlparser xhtml_file)
   Summary(_err "Checking \"${TempDir}/${xhtml_file}\" with xmlParser.pl")
 endmacro()
 
-macro(check_xhtml_jing xhtml_file)
+macro(check_docbook_jing xhtml_file)
   message(STATUS "Calling: ${JAVA_EXECUTABLE} -jar 
\"${TOP_SRC_DIR}/development/tools/jing.jar\" 
\"https://docbook.org/xml/5.2b09/rng/docbook.rng\; 
\"${TempDir}/${xhtml_file}\"")
   set(_outputfile "${TempDir}/${xhtml_file}.jing_out")
   execute_process(
@@ -329,8 +329,7 @@ else()
 endif()
 if (JAVA_EXECUTABLE)
   if (format MATCHES "docbook5")
-# check with jing
-check_xhtml_jing(${result_file_name})
+check_docbook_jing(${result_file_name})
   else()
 #check_xhtml_validate(${result_file_name})
   endif()
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Simplify simplehtml_validity.py

2023-01-09 Thread Thibaut Cuvelier
commit fa5b08e24d398cb76049f2962ae171485f480133
Author: Thibaut Cuvelier 
Date:   Mon Jan 9 04:16:34 2023 +0100

Simplify simplehtml_validity.py
---
 development/autotests/simplehtml_validity.py |   19 +++
 1 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/development/autotests/simplehtml_validity.py 
b/development/autotests/simplehtml_validity.py
index 0cc71f3..896b4a2 100644
--- a/development/autotests/simplehtml_validity.py
+++ b/development/autotests/simplehtml_validity.py
@@ -12,17 +12,14 @@
 # Run:
 # pip install html5validator>=0.4.2
 
-import collections
-import glob
 import sys
-import tempfile
 import os
 
 import html5validator
 
 
 if len(sys.argv) != 2:
-print('Expecting one argument, the path to the LyX-create xhtml file')
+print('Expecting one argument, the path to the LyX-created XHTML file')
 sys.exit(-1)
 if not os.path.exists(sys.argv[1]):
 print('The given path does not point to an existing file')
@@ -35,19 +32,9 @@ xhtml_list = [xhtml_file_name]
 validator = html5validator.Validator(format='text')
 error_count = validator.validate(xhtml_list)
 
-n_invalid = 0
-n_valid = 0
 if error_count == 0:
-n_valid += 1
-print(f'> Found no validation error!')
+print('> Found no validation error!')
 sys.exit(0)
 else:
-n_invalid += 1
-print(f'> Found {error_count} validation error{"" if error_count == 1 else 
"s"}!')
+print('> Found a validation error!')
 sys.exit(-2)
-
-if n_invalid == 0:
-print("That's excellent! Give yourself a pat on the back!")
-sys.exit(0)
-else:
-sys.exit(-3)
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML: avoid using v/align HTML attributes in tables, they are deprecated (like most attributes for td).

2023-01-08 Thread Thibaut Cuvelier
commit 9ae793c6070cf31acd2e8f531b184fd6fc4a9279
Author: Thibaut Cuvelier 
Date:   Mon Jan 9 01:50:05 2023 +0100

LyXHTML: avoid using v/align HTML attributes in tables, they are deprecated 
(like most attributes for td).

Also implement alignment at character in CSS.
---
 src/insets/InsetTabular.cpp |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 265a016..1ec96da 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -3798,7 +3798,7 @@ docstring Tabular::xmlRow(XMLStream & xs, const row_type 
row, OutputParams const
if (output_format == XmlOutputFormat::XHTML) {
// In HTML5, prefer to use CSS instead of attributes 
for alignment
// (align and valign).
-   style << getHAlignAsCssAttribute(cell) << " "
+   style << getHAlignAsCssAttribute(cell) << "; "
  << getVAlignAsCssAttribute(cell);
} else {
// In DocBook, both for HTML and CALS tables, stick to 
attributes.
@@ -3825,9 +3825,11 @@ docstring Tabular::xmlRow(XMLStream & xs, const row_type 
row, OutputParams const
if (is_xhtml_table) {
const std::vector styles = 
computeCssStylePerCell(row, c, cell);
 
-   std::string attr_str_prefix = "style='" ;
+   std::string attr_str_prefix = "style='" + style.str();
+   if (!styles.empty())
+   attr_str_prefix += "; ";
for (auto it = styles.begin(); it != styles.end(); 
++it) {
-   attr << *it;
+   attr_str_prefix += *it;
if (it != styles.end() - 1)
attr_str_prefix += "; ";
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML: avoid using v/align HTML attributes in tables, they are deprecated (like most attributes for td).

2023-01-08 Thread Thibaut Cuvelier
commit 1f370a33536008c80c8e363a8097a9daef772c65
Author: Thibaut Cuvelier 
Date:   Mon Jan 9 01:50:05 2023 +0100

LyXHTML: avoid using v/align HTML attributes in tables, they are deprecated 
(like most attributes for td).

Also implement alignment at character in CSS.
---
 src/insets/InsetTabular.cpp |  103 +++
 src/insets/InsetTabular.h   |   10 +++-
 2 files changed, 82 insertions(+), 31 deletions(-)

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 18481a5..265a016 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -3628,31 +3628,63 @@ std::string Tabular::getVAlignAsXmlAttribute(idx_type 
cell) const
 }
 
 
-std::string Tabular::getHAlignAsXmlAttribute(idx_type cell, const 
XmlOutputFormat output_format) const
+std::string Tabular::getVAlignAsCssAttribute(idx_type cell) const
+{
+   switch (getVAlignment(cell)) {
+   case LYX_VALIGN_TOP:
+   return "vertical-align: top";
+   case LYX_VALIGN_BOTTOM:
+   return "vertical-align: bottom";
+   case LYX_VALIGN_MIDDLE:
+   return "vertical-align: middle";
+   default:
+   // This case only silences a compiler warning, as all the cases 
are covered above.
+   return "";
+   }
+}
+
+
+std::string Tabular::getHAlignAsXmlAttribute(idx_type cell) const
 {
switch (getAlignment(cell)) {
case LYX_ALIGN_LEFT:
return "align='left'";
case LYX_ALIGN_RIGHT:
return "align='right'";
+   case LYX_ALIGN_BLOCK:
+   return "align='justify'";
+   case LYX_ALIGN_DECIMAL: {
+   Language const *lang = 
buffer().paragraphs().front().getParLanguage(buffer().params());
+   return "align='char' char='" + 
to_utf8(lang->decimalSeparator()) + "'";
+   }
+   default:
+   return "align='center'";
+   }
+}
 
+
+std::string Tabular::getHAlignAsCssAttribute(idx_type cell) const
+{
+   switch (getAlignment(cell)) {
+   case LYX_ALIGN_LEFT:
+   return "text-align: left";
+   case LYX_ALIGN_RIGHT:
+   return "text-align: right";
+   case LYX_ALIGN_BLOCK:
+   return "text-align: justify";
+   case LYX_ALIGN_DECIMAL: {
+   // In theory, character-level alignment is supported for CSS4, 
but it's
+   // experimental.
+   // https://www.w3.org/TR/css-text-4/#character-alignment
+   Language const *lang = 
buffer().paragraphs().front().getParLanguage(buffer().params());
+   return "text-align: '" + to_utf8(lang->decimalSeparator()) + 
"'";
+   }
default:
-   // HTML only supports left, right, and center.
-   if (output_format == XmlOutputFormat::XHTML)
-   return "align='center'";
-
-   // DocBook also has justify and decimal.
-   if (getAlignment(cell) == LYX_ALIGN_BLOCK) {
-   return "align='justify'";
-   } else if (getAlignment(cell) == LYX_ALIGN_DECIMAL) {
-   Language const *tlang = 
buffer().paragraphs().front().getParLanguage(buffer().params());
-   return "align='char' char='" + 
to_utf8(tlang->decimalSeparator()) + "'";
-   } else {
-   return "align='center'";
-   }
+   return "text-align: center";
}
 }
 
+
 Tabular::XmlRowWiseBorders Tabular::computeXmlBorders(row_type row) const
 {
Tabular::XmlRowWiseBorders borders;
@@ -3755,25 +3787,24 @@ docstring Tabular::xmlRow(XMLStream & xs, const 
row_type row, OutputParams const
if (isPartOfMultiColumn(row, c) || isPartOfMultiRow(row, c))
continue;
 
-   stringstream attr;
-
-   if (is_xhtml_table) {
-   const std::vector styles = 
computeCssStylePerCell(row, c, cell);
-   attr << "style='" ;
-   for (auto it = styles.begin(); it != styles.end(); ++it) {
-   attr << *it;
-   if (it != styles.end() - 1)
-   attr << "; ";
-   }
-   attr << "' ";
-   }
+   stringstream attr; // Tag-level attributes, both for HTML and 
CALS.
+   stringstream style; // Tag-level CSS, only for HTML tables 
output in HTML.
 
if (is_cals_table) {
if (!cals_row_has_rowsep && bottomLine(cell))
attr <

[LyX/master] InsetMathBox: remove debugging code.

2023-01-08 Thread Thibaut Cuvelier
commit 1b09bc965d2013a75ab7dc2b5416a1ce0d883c90
Author: Thibaut Cuvelier 
Date:   Mon Jan 9 01:11:52 2023 +0100

InsetMathBox: remove debugging code.
---
 src/mathed/InsetMathBox.cpp |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index 30cbd14..1fe3f20 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -74,8 +74,6 @@ void splitAndWrapInMText(MathMLStream & ms, MathData const & 
cell,
inset_contents = ostmp.str();
}
 
-   std::cout << '"' << to_ascii(inset_contents) << '"' << std::endl;
-
// No tags are allowed within : split the string if there are 
tags.
std::vector parts;
while (true) {
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Amend 2d56c01dcfaf04744ab6d854af3965919cc07b82

2023-01-08 Thread Thibaut Cuvelier
commit 24cda9e94a4b7306fe8852f3e94200ba617d2452
Author: Thibaut Cuvelier 
Date:   Sun Jan 8 22:51:01 2023 +0100

Amend 2d56c01dcfaf04744ab6d854af3965919cc07b82
---
 src/insets/InsetIndex.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index 7db133a..f494b07 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -1855,7 +1855,8 @@ docstring InsetPrintIndex::xhtml(XMLStream &, 
OutputParams const & op) const
 
// Collect the index entries in a form we can use them.
vector entries;
-   const docstring & indexType = params().getParamOr("type", 
from_ascii("idx"));
+   const docstring defaultIndexType = from_ascii("idx");
+   const docstring & indexType = params().getParamOr("type", 
defaultIndexType);
for (const TocItem& item : *toc) {
const auto* inset = static_cast(&(item.dit().inset()));
if (item.isOutput() && inset && inset->params().index == 
indexType)
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetIndex: make a condition more bullet-proof, a nullptr could be dereferenced.

2023-01-08 Thread Thibaut Cuvelier
commit 2d56c01dcfaf04744ab6d854af3965919cc07b82
Author: Thibaut Cuvelier 
Date:   Sun Jan 8 22:19:39 2023 +0100

InsetIndex: make a condition more bullet-proof, a nullptr could be 
dereferenced.

Error noticed by Coverity:

*** CID 382777:  Memory - illegal accesses  (RETURN_LOCAL)
/home/lasgoutt/src/lyx/coverity/lyx/src/insets/InsetIndex.cpp: 1866 in 
_ZNK3lyx15InsetPrintIndex5xhtmlB5cxx11ERNS_9XMLStreamERKNS_12OutputParamsE()
1860
1861// Collect the index entries in a form we can use them.
1862vector entries;
1863const docstring & indexType = params().getParamOr("type", 
from_ascii("idx"));
1864for (const TocItem& item : *toc) {
1865const auto* inset = static_cast(&(item.dit().inset()));
>>> CID 382777:  Memory - illegal accesses  (RETURN_LOCAL)
>>> Using "indexType", which points to an out-of-scope temporary 
variable of type "lyx::docstring const".
1866if (item.isOutput() && inset->params().index == 
indexType)
1867entries.emplace_back(IndexEntry{inset, 
});
1868}
1869
1870// If all the index entries are in notes or not displayed, 
get out sooner.
1871if (entries.empty())
---
 src/insets/InsetIndex.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index f460015..7db133a 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -1858,7 +1858,7 @@ docstring InsetPrintIndex::xhtml(XMLStream &, 
OutputParams const & op) const
const docstring & indexType = params().getParamOr("type", 
from_ascii("idx"));
for (const TocItem& item : *toc) {
const auto* inset = static_cast(&(item.dit().inset()));
-   if (item.isOutput() && inset->params().index == indexType)
+   if (item.isOutput() && inset && inset->params().index == 
indexType)
entries.emplace_back(IndexEntry{inset, });
}
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetIndex: remove unused code that created Coverity errors.

2023-01-08 Thread Thibaut Cuvelier
commit b42269f065f6b7705f6cc8e26dda638f07ff363a
Author: Thibaut Cuvelier 
Date:   Sun Jan 8 22:17:02 2023 +0100

InsetIndex: remove unused code that created Coverity errors.
---
 src/insets/InsetIndex.cpp |   13 -
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index 32cabca..f460015 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -1432,19 +1432,6 @@ public:
parseAsLegacy();
}
 
-   /// When parsing this entry, some errors may be found; they are 
reported as a single string.
-   // It is up to the caller to send this string to LYXERR and the output 
file, as needed.
-   const docstring & output_error() const
-   {
-   return output_error_;
-   }
-
-   void output_error(XMLStream xs) const
-   {
-   LYXERR0(output_error());
-   xs << XMLStream::ESCAPE_NONE << (from_utf8("\n"));
-   }
-
 
 private:
bool isModern()
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetIndex: add a missing destructor for IndexNode and call it from xhtml() to avoid leaking resources.

2023-01-08 Thread Thibaut Cuvelier
commit 6e4cf808da4ea846d0f5195d0d684daf4912af43
Author: Thibaut Cuvelier 
Date:   Sun Jan 8 22:03:26 2023 +0100

InsetIndex: add a missing destructor for IndexNode and call it from xhtml() 
to avoid leaking resources.

Corresponding Coverity finding:

** CID 382778:  Resource leaks  (RESOURCE_LEAK)
/home/lasgoutt/src/lyx/coverity/lyx/src/insets/InsetIndex.cpp: 1909 in 
_ZNK3lyx15InsetPrintIndex5xhtmlB5cxx11ERNS_9XMLStreamERKNS_12OutputParamsE()



*** CID 382778:  Resource leaks  (RESOURCE_LEAK)
/home/lasgoutt/src/lyx/coverity/lyx/src/insets/InsetIndex.cpp: 1909 in 
_ZNK3lyx15InsetPrintIndex5xhtmlB5cxx11ERNS_9XMLStreamERKNS_12OutputParamsE()
1903}
1904
1905xs << xml::EndTag("ul");
1906xs << xml::CR();
1907xs << xml::EndTag("div");
1908
>>> CID 382778:  Resource leaks  (RESOURCE_LEAK)
>>> Variable "index_root" going out of scope leaks the storage it 
points to.
1909return ods.str();
1910 }
1911
---
 src/insets/InsetIndex.cpp |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index a6fcae7..32cabca 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -1658,6 +1658,14 @@ std::string generateCssClassAtDepth(unsigned depth) {
 struct IndexNode {
std::vector entries;
std::vector children;
+
+   ~IndexNode() {
+   for (IndexNode * child : children) {
+   if (!child)
+   continue;
+   delete child;
+   }
+   }
 };
 
 docstring termAtLevel(const IndexNode* node, unsigned depth)
@@ -1901,6 +1909,7 @@ docstring InsetPrintIndex::xhtml(XMLStream &, 
OutputParams const & op) const
for (const IndexNode* node : index_root->children) {
outputIndexPage(xs, node);
}
+   delete index_root;
 
xs << xml::EndTag("ul");
xs << xml::CR();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetMathBox: split the boxed text into and other tags, while boxing the whole inset within an .

2023-01-07 Thread Thibaut Cuvelier
commit e70cdfd3a222f12ab25a8c7296b180018bc06381
Author: Thibaut Cuvelier 
Date:   Sun Jan 8 02:27:36 2023 +0100

InsetMathBox: split the boxed text into  and other tags, while 
boxing the whole inset within an .

Rationales:
- previously,  was used, but it's being deprecated for MathML 4 
Core in favour of CSS and  (not a big deal in itself)
- the whole box cannot be hosted within the same tag, because neither 
 nor  can have text, they need an intermediate container,  
(which cannot hold anything else that pure text)
- new behaviour: always output a container for the whole box that has the 
right attributes, i.e. an ; split the content of the cell to have text 
and other tags set apart (text in , other tags left as they were)

Old behaviour, invalid MathML (2 to 4):
text.

New behaviour, valid MathML:
text.
---
 src/mathed/InsetMathBox.cpp |   89 +++---
 1 files changed, 74 insertions(+), 15 deletions(-)

diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index f3ba7a7..30cbd14 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -25,6 +25,7 @@
 #include "frontends/Painter.h"
 
 #include 
+#include 
 #include 
 
 using namespace lyx::support;
@@ -57,16 +58,82 @@ void InsetMathBox::normalize(NormalStream & os) const
 }
 
 
+namespace {
+void splitAndWrapInMText(MathMLStream & ms, MathData const & cell,
+const std::string & attributes)
+{
+   // First, generate the inset into a string of its own.
+   docstring inset_contents;
+   {
+   odocstringstream ostmp;
+   MathMLStream mstmp(ostmp, ms.xmlns());
+
+   SetMode textmode(mstmp, true);
+   mstmp << cell;
+
+   inset_contents = ostmp.str();
+   }
+
+   std::cout << '"' << to_ascii(inset_contents) << '"' << std::endl;
+
+   // No tags are allowed within : split the string if there are 
tags.
+   std::vector parts;
+   while (true) {
+   std::size_t angle_pos = inset_contents.find('<');
+   if (angle_pos == docstring::npos)
+   break;
+
+   // String structure:
+   // - prefix: pure text, no tag
+   // - tag to split: something like 1 or more 
complicated
+   //   (like nested tags), with or without name space
+   // - rest to be taken care of in the next iteration
+
+   // Push the part before the tag.
+   parts.emplace_back(inset_contents.substr(0, angle_pos));
+   inset_contents = inset_contents.substr(angle_pos);
+   // Now, inset_contents starts with the tag to isolate, so that
+   // inset_contents[0] == '<'
+
+   // Push the tag, up to its end. Process: find the tag name 
(either
+   // before > or the first attribute of the tag), then the 
matching end
+   // tag, then proceed with pushing.
+   const std::size_t tag_name_end =
+   std::min(inset_contents.find(' ', 1), 
inset_contents.find('>', 1));
+   const std::size_t tag_name_length = tag_name_end - 1;
+   const docstring tag_name = inset_contents.substr(1, 
tag_name_length);
+
+   const std::size_t end_tag_start =
+   inset_contents.find(tag_name, tag_name_end + 1);
+   const std::size_t end_tag = inset_contents.find('>', 
end_tag_start);
+
+   parts.emplace_back(inset_contents.substr(0, end_tag + 1));
+   inset_contents = inset_contents.substr(end_tag + 1);
+   }
+   parts.emplace_back(inset_contents);
+
+   // Finally, output the complete inset: escape the test in , 
leave
+   // the other tags untouched.
+   ms << MTag("mrow", attributes);
+   for (int i = 0; i < parts.size(); i += 2) {
+   ms << MTag("mtext")
+  << parts[i]
+  << ETag("mtext");
+   if (parts.size() > i + 1)
+   ms << parts[i + 1];
+   }
+   ms << ETag("mrow");
+}
+}
+
+
 void InsetMathBox::mathmlize(MathMLStream & ms) const
 {
// FIXME XHTML
// Need to do something special for tags here.
// Probably will have to involve deferring them, which
// means returning something from this routine.
-   SetMode textmode(ms, true);
-   ms << MTag("mtext", "class='mathbox'")
-  << cell(0)
-  << ETag("mtext");
+   splitAndWrapInMText(ms, cell(0), "class='mathbox'");
 }
 
 
@@ -165,10 +232,7 @@ void InsetMathFBox::normalize(NormalStream & os) const

[LyX/master] MathML test case: fix a typo.

2023-01-07 Thread Thibaut Cuvelier
commit 4412fdf09aa8afe0a53e9380c2bc5a2815d04b03
Author: Thibaut Cuvelier 
Date:   Sun Jan 8 00:50:18 2023 +0100

MathML test case: fix a typo.

It was bugging me when looking at XHTML output: I was wondering if LyX was 
doing anything weird about ligatures! Hopefully not.
---
 autotests/mathmacros/testcases_basic.lyx |   45 --
 1 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/autotests/mathmacros/testcases_basic.lyx 
b/autotests/mathmacros/testcases_basic.lyx
index da70e7e..436cb4a 100644
--- a/autotests/mathmacros/testcases_basic.lyx
+++ b/autotests/mathmacros/testcases_basic.lyx
@@ -1,15 +1,15 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 572
+\lyxformat 614
 \begin_document
 \begin_header
 \save_transient_properties true
 \origin unavailable
 \textclass article
 \use_default_options false
-\maintain_unincluded_children false
+\maintain_unincluded_children no
 \language english
 \language_package default
-\inputencoding auto
+\inputencoding auto-legacy
 \fontencoding auto
 \font_roman "default" "default"
 \font_sans "default" "default"
@@ -18,7 +18,9 @@
 \font_default_family default
 \use_non_tex_fonts false
 \font_sc false
-\font_osf 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
@@ -52,6 +54,7 @@
 \justification true
 \use_refstyle 0
 \use_minted 0
+\use_lineno 0
 \index Index
 \shortcut idx
 \color #008000
@@ -70,9 +73,13 @@
 \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 false
+\docbook_table_output 0
+\docbook_mathml_prefix 1
 \end_header
 
 \begin_body
@@ -82,7 +89,8 @@ Macro Testcases
 \end_layout
 
 \begin_layout Enumerate
-Simple macro definitions with position awareness: 
+Simple macro definitions with position awareness:
+ 
 \begin_inset FormulaMacro
 \newcommand{\bla}{42}
 \end_inset
@@ -95,12 +103,13 @@ Simple macro definitions with position awareness:
 
 \end_inset
 
-now redined as 
+now redefined as 
 \begin_inset FormulaMacro
 \renewcommand{\bla}{21}
 \end_inset
 
-, such that
+,
+ such that
 \begin_inset Formula 
 \[
 \bla\mbox{ should look like }21.
@@ -112,7 +121,8 @@ now redined as
 \end_layout
 
 \begin_layout Enumerate
-Redefinitions of macros appearing in the definition of another macro: 
+Redefinitions of macros appearing in the definition of another macro:
+ 
 \begin_inset FormulaMacro
 \newcommand{\fooa}{x}
 \end_inset
@@ -176,7 +186,8 @@ gives the following:
 \end_layout
 
 \begin_layout Enumerate
-Arity change: 
+Arity change:
+ 
 \begin_inset FormulaMacro
 \newcommand{\foo}{-}
 \end_inset
@@ -198,7 +209,8 @@ Arity change:
 \end_layout
 
 \begin_layout Enumerate
-Arity change with incomplete arguments at line end: 
+Arity change with incomplete arguments at line end:
+ 
 \begin_inset FormulaMacro
 \renewcommand{\foo}{-}
 \end_inset
@@ -220,7 +232,8 @@ Arity change with incomplete arguments at line end:
 \end_layout
 
 \begin_layout Enumerate
-Recursion: 
+Recursion:
+ 
 \begin_inset FormulaMacro
 \renewcommand{\foo}[1]{\foo{#1}{}}
 \end_inset
@@ -231,7 +244,8 @@ Recursion:
 \end_layout
 
 \begin_layout Enumerate
-Recursive usage: 
+Recursive usage:
+ 
 \begin_inset FormulaMacro
 \renewcommand{\foo}[3]{\frac{{\displaystyle #1}\,{\displaystyle 
#2}}{{\displaystyle #3}}}
 \end_inset
@@ -254,8 +268,8 @@ Folding/Unfolding:
 \end_inset
 
 .
- Start using Ctrl-+ and Ctrl– when you are inside of the macro to fold and
- unfold, e.g.
+ Start using Ctrl-+ and Ctrl– when you are inside of the macro to fold and 
unfold,
+ e.g.
  here:
 \begin_inset Formula 
 \[
@@ -268,7 +282,8 @@ Folding/Unfolding:
 \end_layout
 
 \begin_layout Enumerate
-Scripts: 
+Scripts:
+ 
 \begin_inset FormulaMacro
 \renewcommand{\foo}[3][A][B]{(#1,#2)#3}
 \end_inset
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] MathML: convert InsetMathBox as .

2023-01-07 Thread Thibaut Cuvelier
commit edcaad2419b70ef1bd96bb1b117b9818187679ba
Author: Thibaut Cuvelier 
Date:   Sun Jan 8 00:50:06 2023 +0100

MathML: convert InsetMathBox as .

The inset represents text (as opposed to maths in formulae).  is 
used to give style to its children, it is not supposed to have any contents on 
its own.
---
 src/mathed/InsetMathBox.cpp |   24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index 2b237d8..a10ede1 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -64,9 +64,9 @@ void InsetMathBox::mathmlize(MathMLStream & ms) const
// Probably will have to involve deferring them, which
// means returning something from this routine.
SetMode textmode(ms, true);
-   ms << MTag("mstyle", "class='mathbox'")
+   ms << MTag("mtext", "class='mathbox'")
   << cell(0)
-  << ETag("mstyle");
+  << ETag("mtext");
 }
 
 
@@ -105,7 +105,7 @@ void InsetMathBox::validate(LaTeXFeatures & features) const
// It'd be better to be able to get this from an InsetLayout, but at 
present
// InsetLayouts do not seem really to work for things that aren't 
InsetTexts.
if (features.runparams().math_flavor == OutputParams::MathAsMathML)
-   features.addCSSSnippet("mstyle.mathbox { font-style: normal; 
}");
+   features.addCSSSnippet("mtext.mathbox { font-style: normal; }");
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
features.addCSSSnippet("span.mathbox { font-style: normal; }");
 
@@ -166,9 +166,9 @@ void InsetMathFBox::normalize(NormalStream & os) const
 void InsetMathFBox::mathmlize(MathMLStream & ms) const
 {
SetMode textmode(ms, true);
-   ms << MTag("mstyle", "class='fbox'")
+   ms << MTag("mtext", "class='fbox'")
   << cell(0)
-  << ETag("mstyle");
+  << ETag("mtext");
 }
 
 
@@ -194,7 +194,7 @@ void InsetMathFBox::validate(LaTeXFeatures & features) const
// InsetLayouts do not seem really to work for things that aren't 
InsetTexts.
if (features.runparams().math_flavor == OutputParams::MathAsMathML)
features.addCSSSnippet(
-   "mstyle.fbox { border: 1px solid black; font-style: 
normal; padding: 0.5ex; }");
+   "mtext.fbox { border: 1px solid black; font-style: 
normal; padding: 0.5ex; }");
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
features.addCSSSnippet(
"span.fbox { border: 1px solid black; font-style: 
normal; padding: 0.5ex; }");
@@ -312,9 +312,9 @@ void InsetMathMakebox::mathmlize(MathMLStream & ms) const
// FIXME We could do something with the other arguments.
std::string const cssclass = framebox_ ? "framebox" : "makebox";
SetMode textmode(ms, true);
-   ms << MTag("mstyle", "class='" + cssclass + "'")
+   ms << MTag("mtext", "class='" + cssclass + "'")
   << cell(2)
-  << ETag("mstyle");
+  << ETag("mtext");
 }
 
 
@@ -335,7 +335,7 @@ void InsetMathMakebox::validate(LaTeXFeatures & features) 
const
// It'd be better to be able to get this from an InsetLayout, but at 
present
// InsetLayouts do not seem really to work for things that aren't 
InsetTexts.
if (features.runparams().math_flavor == OutputParams::MathAsMathML)
-   features.addCSSSnippet("mstyle.framebox { border: 1px solid 
black; }");
+   features.addCSSSnippet("mtext.framebox { border: 1px solid 
black; }");
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
features.addCSSSnippet("span.framebox { border: 1px solid 
black; }");
InsetMathNest::validate(features);
@@ -393,9 +393,9 @@ void InsetMathBoxed::infoize(odocstream & os) const
 
 void InsetMathBoxed::mathmlize(MathMLStream & ms) const
 {
-   ms << MTag("mstyle", "class='boxed'")
+   ms << MTag("mtext", "class='boxed'")
   << cell(0)
-  << ETag("mstyle");
+  << ETag("mtext");
 }
 
 
@@ -415,7 +415,7 @@ void InsetMathBoxed::validate(LaTeXFeatures & features) 
const
// It'd be better to be able to get this from an InsetLayout, but at 
present
// InsetLayouts do not seem really to work for things that aren't 
InsetTexts.
if (features.runparams().math_flavor == OutputParams::MathAsMathML)
-   features.addCSSSnippet("mstyle.boxed { border: 1px solid black; 
}");
+   features.addCSSSnippet("mtext.boxed { border: 1px solid black; 
}");
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
features.addCSSSnippet("span.boxed { border: 1px solid black; 
}");
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetMathBox: fix strange indentation (mix of spaces and tabs).

2023-01-07 Thread Thibaut Cuvelier
commit d3c81eb2cbdf1c233042c35fe493cc789cc93647
Author: Thibaut Cuvelier 
Date:   Sun Jan 8 00:51:43 2023 +0100

InsetMathBox: fix strange indentation (mix of spaces and tabs).
---
 src/mathed/InsetMathBox.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index a10ede1..f3ba7a7 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -403,7 +403,7 @@ void InsetMathBoxed::htmlize(HtmlStream & ms) const
 {
ms << MTag("span", "class='boxed'")
   << cell(0)
-<< ETag("span");
+  << ETag("span");
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML validation tests: explicitly exit the Python script if it fails

2023-01-07 Thread Thibaut Cuvelier
commit 0f8951e7089013e68e47daa148dccfcca7f692fd
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 21:27:50 2023 +0100

LyXHTML validation tests: explicitly exit the Python script if it fails
---
 .../thorough_export_tests/lyxhtml_validity.py  |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/development/thorough_export_tests/lyxhtml_validity.py 
b/development/thorough_export_tests/lyxhtml_validity.py
index 12c0cbd..3d50500 100644
--- a/development/thorough_export_tests/lyxhtml_validity.py
+++ b/development/thorough_export_tests/lyxhtml_validity.py
@@ -23,10 +23,13 @@ import html5validator
 
 if len(sys.argv) != 2:
 print('Expecting one argument, the path to the LyX binary to test')
+sys.exit(-1)
 if not os.path.exists(sys.argv[1]):
 print('The given path does not point to an existing file')
+sys.exit(-1)
 if not os.access(sys.argv[1], os.X_OK):
 print('The given path does not point to an executable file')
+sys.exit(-1)
 
 
 PATH_SCRIPT = os.path.dirname(os.path.realpath(__file__))
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML: use a lower-case meta for generator, this is the most common convention.

2023-01-07 Thread Thibaut Cuvelier
commit 6a3bd6403277c5a2fd7cc93f88f1ed7e7d492145
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 16:24:57 2023 +0100

LyXHTML: use a lower-case meta for generator, this is the most common 
convention.
---
 src/Buffer.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 32d3e89..2e43a15 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2254,7 +2254,7 @@ Buffer::ExportStatus 
Buffer::writeLyXHTMLSource(odocstream & os,
os << "\n"
   << "http://www.w3.org/1999/xhtml\; lang=\"" << 
from_ascii(htmlCode) << "\">\n"
   << "\n"
-  << "\n"
+  << "\n"
   // FIXME Presumably need to set this right
   << "\n";
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML: add a missing space in the content-type annotation.

2023-01-07 Thread Thibaut Cuvelier
commit a5c6215ebde966f2e33b51706fe4356cd52dde40
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 16:23:56 2023 +0100

LyXHTML: add a missing space in the content-type annotation.
---
 src/Buffer.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 3f66864..32d3e89 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2256,7 +2256,7 @@ Buffer::ExportStatus 
Buffer::writeLyXHTMLSource(odocstream & os,
   << "\n"
   << "\n"
   // FIXME Presumably need to set this right
-  << "\n";
+  << "\n";
 
docstring const & doctitle = features.htmlTitle();
os << ""
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML: remove the double specification of charset.

2023-01-06 Thread Thibaut Cuvelier
commit fd2078f3aa55d61e68c1996c31b7ad3f63fea39a
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 03:34:58 2023 +0100

LyXHTML: remove the double specification of charset.

The choice of content-type is arbitrary.
---
 src/Buffer.cpp |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 8b95a46..1404cd4 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2255,7 +2255,6 @@ Buffer::ExportStatus 
Buffer::writeLyXHTMLSource(odocstream & os,
   << "http://www.w3.org/1999/xhtml\; lang=\"" << 
from_ascii(htmlCode) << "\">\n"
   << "\n"
   << "\n"
-  << "\n"
   // FIXME Presumably need to set this right
   << "\n";
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML: don't explicitly mention that the style is CSS, HTML5 doesn't like it.

2023-01-06 Thread Thibaut Cuvelier
commit fb4a26577e9f1149e78bd500447ce061445bd708
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 03:42:11 2023 +0100

LyXHTML: don't explicitly mention that the style is CSS, HTML5 doesn't like 
it.
---
 src/Buffer.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 1404cd4..3f66864 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2316,7 +2316,7 @@ Buffer::ExportStatus 
Buffer::writeLyXHTMLSource(odocstream & os,
// we are here if the CSS is supposed to be written to 
the header
// or if we failed to write it to an external file.
if (!written) {
-   os << "\n"
+   os << "<style>\n"
 << dstyles
 << "\n\n";
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML and DocBook: encode language codes as BCP47.

2023-01-06 Thread Thibaut Cuvelier
commit 26e6b1c20940fc766c4eadbd64563f0da1880908
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 03:31:40 2023 +0100

LyXHTML and DocBook: encode language codes as BCP47.
---
 src/Buffer.cpp |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 0728722..907026e 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2172,8 +2172,14 @@ Buffer::ExportStatus 
Buffer::writeDocBookSource(odocstream & os,
mathmlNamespace = + " xmlns:" + mathmlPrefix + 
"=\"http://www.w3.org/1998/Math/MathML\";;
}
 
+   // XML-compatible language code: in lib/languages, language 
codes are
+   // given as dictionary file names; HTML5 expects to follow 
BCP47. This
+   // function implements a simple heuristic that does the 
conversion.
+   std::string htmlCode = params().language->code();
+   std::replace(htmlCode.begin(), htmlCode.end(), '_', '-');
+
// Directly output the root tag, based on the current type of 
document.
-   string attributes = "xml:lang=\"" + params().language->code() + 
'"'
+   string attributes = "xml:lang=\"" + htmlCode + '"'
+ " 
xmlns=\"http://docbook.org/ns/docbook\";
+ " 
xmlns:xlink=\"http://www.w3.org/1999/xlink\";
+ mathmlNamespace
@@ -2239,8 +2245,14 @@ Buffer::ExportStatus 
Buffer::writeLyXHTMLSource(odocstream & os,
  output == FullSource || output == OnlyBody || output == IncludedFile;
 
if (output_preamble) {
+   // HTML5-compatible language code: in lib/languages, language 
codes are
+   // given as dictionary file names; HTML5 expects to follow 
BCP47. This
+   // function implements a simple heuristic that does the 
conversion.
+   std::string htmlCode = params().language->code();
+   std::replace(htmlCode.begin(), htmlCode.end(), '_', '-');
+
os << "\n"
-  << "http://www.w3.org/1999/xhtml\; lang=\"" << 
from_ascii(params().language->code()) << "\">\n"
+  << "http://www.w3.org/1999/xhtml\; lang=\"" << 
from_ascii(htmlCode) << "\">\n"
   << "\n"
   << "\n"
   << "\n"
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML: add explicit HTMLTag for titles.

2023-01-06 Thread Thibaut Cuvelier
commit 051c5f27284f00c20e95c5732bcfb04632c7cb18
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 03:59:22 2023 +0100

LyXHTML: add explicit HTMLTag for titles.

This way, LyX can generate semantic  tags instead of a generic .
---
 lib/layouts/beamer.layout|4 
 lib/layouts/egs.layout   |4 +++-
 lib/layouts/europasscv.layout|1 +
 lib/layouts/europecv.layout  |1 +
 lib/layouts/foils.layout |1 +
 lib/layouts/ltugboat.layout  |2 ++
 lib/layouts/memoir.layout|1 +
 lib/layouts/moderncv.layout  |1 +
 lib/layouts/powerdot.layout  |1 +
 lib/layouts/simplecv.layout  |1 +
 lib/layouts/tufte-book.layout|3 +++
 lib/layouts/tufte-handout.layout |1 +
 12 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout
index 95519cc..216b487 100644
--- a/lib/layouts/beamer.layout
+++ b/lib/layouts/beamer.layout
@@ -291,6 +291,7 @@ Style Part
 Color  Latex
   EndFont
   TocLevel -1
+  HTMLTag  h2
 End
 
 Style Section
@@ -335,6 +336,7 @@ Style Section
   EndFont
   LabelStringAppendix "\Alph{section}"
   TocLevel 1
+  HTMLTag  h3
 End
 
 Style Section*
@@ -354,6 +356,7 @@ Style Section*
   EndArgument
   LaTeXParam   *
   HTMLInToc0
+  HTMLTag  h3
 End
 
 Style Subsection
@@ -398,6 +401,7 @@ Style Subsection
   EndFont
   LabelStringAppendix "\arabic{section}.\arabic{subsection}"
   TocLevel 2
+  HTMLTag  h4
 End
 
 Style Subsection*
diff --git a/lib/layouts/egs.layout b/lib/layouts/egs.layout
index ba28ec4..eaad3b5 100644
--- a/lib/layouts/egs.layout
+++ b/lib/layouts/egs.layout
@@ -13,7 +13,7 @@ Format 99
 Columns 2
 Sides   1
 PageStyle   Plain
-Provides natbib  1
+Provides natbib 1
 
 
 Style Standard
@@ -50,6 +50,7 @@ Style Section
  Series  Bold
EndFont
TocLevel 1
+HTMLTag   h2
 End
 
 
@@ -70,6 +71,7 @@ Style Subsection
  Shape   Up
EndFont
TocLevel 2
+HTMLTag   h3
 End
 
 
diff --git a/lib/layouts/europasscv.layout b/lib/layouts/europasscv.layout
index 03f76df..5198243 100644
--- a/lib/layouts/europasscv.layout
+++ b/lib/layouts/europasscv.layout
@@ -284,6 +284,7 @@ Style Section
  SeriesBold
EndFont
TocLevel1
+HTMLTag h2
DocBookTag  title
DocBookTagType paragraph
 End
diff --git a/lib/layouts/europecv.layout b/lib/layouts/europecv.layout
index 0d817d0..e5d7694 100644
--- a/lib/layouts/europecv.layout
+++ b/lib/layouts/europecv.layout
@@ -215,6 +215,7 @@ Style Section
  SeriesBold
EndFont
TocLevel1
+HTMLTag h2
DocBookTag  title
DocBookTagType paragraph
 End
diff --git a/lib/layouts/foils.layout b/lib/layouts/foils.layout
index 77ebe91..257ea39 100644
--- a/lib/layouts/foils.layout
+++ b/lib/layouts/foils.layout
@@ -59,6 +59,7 @@ Style Foilhead
  Series  Bold
  SizeLarge
EndFont
+HTMLTag   h2
 End
 
 
diff --git a/lib/layouts/ltugboat.layout b/lib/layouts/ltugboat.layout
index a1c0aee..3473f46 100644
--- a/lib/layouts/ltugboat.layout
+++ b/lib/layouts/ltugboat.layout
@@ -63,6 +63,7 @@ Style Section
  SizeNormal
EndFont
TocLevel 1
+HTMLTag   h2
 End
 
 
@@ -84,6 +85,7 @@ Style Subsection
  SizeNormal
EndFont
TocLevel 2
+HTMLTag   h3
 End
 
 
diff --git a/lib/layouts/memoir.layout b/lib/layouts/memoir.layout
index 7f85afe..cfbc58b 100644
--- a/lib/layouts/memoir.layout
+++ b/lib/layouts/memoir.layout
@@ -246,6 +246,7 @@ Style Poemtitle
Font
   Series Bold
EndFont
+HTMLTag   h2
 End
 
 
diff --git a/lib/layouts/moderncv.layout b/lib/layouts/moderncv.layout
index 61e763d..e237fb7 100644
--- a/lib/layouts/moderncv.layout
+++ b/lib/layouts/moderncv.layout
@@ -337,6 +337,7 @@ Style Section
  SeriesBold
EndFont
TocLevel1
+HTMLTag h2
DocBookTag  title
DocBookTagType  paragraph
 End
diff --git a/lib/layouts/powerdot.layout b/lib/layouts/powerdot.layout
index fd945da..383f414 100644
--- a/lib/layouts/powerdot.layout
+++ b/lib/layouts/powerdot.layout
@@ -256,6 +256,7 @@ Style Section
 LabelString   "Section Option"
 Tooltip   "Optional arguments to the section command (see powerdot 
manual)"
   EndArgument
+  HTMLTag   h2
 End
 
 ###
diff --git a/lib/layouts/simplecv.layout b/lib/layouts/simplecv.layout
index 41dd2eb..d55b987 100644
--- a/lib/layouts/simplecv.layout
+++ b/lib/layouts/simplecv.layout
@@ -54,6 +54,7 @@ Style 

[LyX/master] LyXHTML: use a value of font-weight that makes sense instead of a nonexistent medium.

2023-01-06 Thread Thibaut Cuvelier
commit 4c1f9d1161d91acfdd982ce16f6ed7b0c6defe63
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 03:40:27 2023 +0100

LyXHTML: use a value of font-weight that makes sense instead of a 
nonexistent medium.
---
 lib/layouts/stdinsets.inc |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc
index cb038c5..7271e7a 100644
--- a/lib/layouts/stdinsets.inc
+++ b/lib/layouts/stdinsets.inc
@@ -36,7 +36,7 @@ InsetLayout Marginal
background-color: #F0F0F0;
float:right;
font-size: small;
-   font-weight: medium;
+   font-weight: normal;
font-family: serif;
font-variant: normal;
font-style: normal;
@@ -73,7 +73,7 @@ InsetLayout Foot
div.foot {
display: inline;
font-size: small;
-   font-weight: medium;
+   font-weight: normal;
font-family: serif;
font-variant: normal;
font-style: normal;
@@ -110,7 +110,7 @@ InsetLayout Foot:InTitle
span.foot_intitle {
display: inline;
font-size: small;
-   font-weight: medium;
+   font-weight: normal;
font-family: serif;
font-variant: normal;
font-style: normal;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] LyXHTML: fix the content-type attribute, it must be lower case (enforced for HTML5).

2023-01-06 Thread Thibaut Cuvelier
commit cabb12ba51de713d5162ed2ef956d71b3974acc0
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 03:33:48 2023 +0100

LyXHTML: fix the content-type attribute, it must be lower case (enforced 
for HTML5).
---
 src/Buffer.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 907026e..8b95a46 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2257,7 +2257,7 @@ Buffer::ExportStatus 
Buffer::writeLyXHTMLSource(odocstream & os,
   << "\n"
   << "\n"
   // FIXME Presumably need to set this right
-  << "\n";
+  << "\n";
 
docstring const & doctitle = features.htmlTitle();
os << ""
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Amend 16a1aa99

2023-01-06 Thread Thibaut Cuvelier
commit 96023697f5efa4d3414bdfeb1dab3200057ba1cb
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 03:05:55 2023 +0100

Amend 16a1aa99

With the current settings, a theorem with several paragraphs will have 
several wrapper tags (i.e. two ``, with one paragraph each, one next 
to the other when it's the same theorem), while there should be only one (one 
`` with two paragraphs).

It makes me wonder whether DocBookWrapperMergeWithPrevious should be the 
default value. I don't see a case where it would be set to `false` with a 
wrapper tag, but the test suite isn't developed enough to make the change with 
peace of mind (i.e. remove the parameter `DocBookWrapperMergeWithPrevious` and 
consider it is always `true` in the code).

For the record, the current code also works with two subsequent theorems 
with two paragraphs each (see new test case).
---
 autotests/export/docbook/font_overlapping.lyx  |  103 +++
 .../export/docbook/theorems-multiparagraph.lyx |  139 
 .../export/docbook/theorems-multiparagraph.xml |  102 ++
 lib/layouts/elsart.layout  |9 ++
 lib/layouts/theorems-ams-bytype.inc|   12 ++
 lib/layouts/theorems-ams-chap-bytype.inc   |   12 ++
 lib/layouts/theorems-ams.inc   |   12 ++
 lib/layouts/theorems-bytype.inc|   12 ++
 lib/layouts/theorems-starred.inc   |   12 ++
 lib/layouts/theorems-without-preamble.inc  |   18 +++
 lib/layouts/theorems.inc   |   12 ++
 11 files changed, 443 insertions(+), 0 deletions(-)

diff --git a/autotests/export/docbook/font_overlapping.lyx 
b/autotests/export/docbook/font_overlapping.lyx
new file mode 100644
index 000..28c895f
--- /dev/null
+++ b/autotests/export/docbook/font_overlapping.lyx
@@ -0,0 +1,103 @@
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 609
+\begin_document
+\begin_header
+\save_transient_properties false
+\origin unavailable
+\textclass article
+\use_default_options true
+\maintain_unincluded_children no
+\language english
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "default" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "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 true
+\use_dash_ligatures true
+\graphics default
+\default_output_format default
+\output_sync 0
+\bibtex_command default
+\index_command default
+\float_placement class
+\float_alignment center
+\paperfontsize default
+\spacing single
+\use_hyperref 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 true
+\justification false
+\use_refstyle 1
+\use_minted 0
+\use_lineno 0
+\index Index
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style english
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tablestyle default
+\tracking_changes false
+\output_changes false
+\change_bars false
+\postpone_fragile_content true
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict false
+\docbook_table_output 0
+\docbook_mathml_prefix 1
+\end_header
+
+\begin_body
+
+\begin_layout Standard
+norm 
+\emph on
+emph 
+\series bold
+emph-bold
+\emph default
+ bold
+\series default
+ norm
+\end_layout
+
+\end_body
+\end_document
\ No newline at end of file
diff --git a/autotests/export/docbook/theorems-multiparagraph.lyx 
b/autotests/export/docbook/theorems-multiparagraph.lyx
new file mode 100644
index 000..ea243a5
--- /dev/null
+++ b/autotests/export/docbook/theorems-multiparagraph.lyx
@@ -0,0 +1,139 @@
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 614
+\begin_document
+\begin_header
+\save_transient_properties true
+\origin unavailable
+\textclass article
+\use_default_options true
+\begin_modules
+theorems-std
+\end_modules
+\maintain_unincluded_children no
+\language italian
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "default" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "default"
+\font_math "auto&q

[LyX/master] Make formatting of DocBook changes more similar to surrounding code.

2023-01-06 Thread Thibaut Cuvelier
commit 3cf8ced72ede681a61918d69ffe2c8d8a1dc4e19
Author: Thibaut Cuvelier 
Date:   Sat Jan 7 02:56:40 2023 +0100

Make formatting of DocBook changes more similar to surrounding code.

Spaces between if and condition.
---
 src/Layout.cpp |   48 
 1 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/Layout.cpp b/src/Layout.cpp
index c54e121..1035c0b 100644
--- a/src/Layout.cpp
+++ b/src/Layout.cpp
@@ -1703,56 +1703,56 @@ void Layout::write(ostream & os) const
   << to_utf8(rtrim(htmlpreamble_, "\n"))
   << "\n\tEndPreamble\n";
os << "\tHTMLTitle " << htmltitle_ << "\n";
-   if(!docbooktag_.empty())
+   if (!docbooktag_.empty())
os << "\tDocBookTag " << docbooktag_ << '\n';
-   if(!docbookattr_.empty())
+   if (!docbookattr_.empty())
os << "\tDocBookAttr \"" << docbookattr_ << "\"\n";
-   if(!docbooktagtype_.empty())
+   if (!docbooktagtype_.empty())
os << "\tDocBookTagType " << docbooktagtype_ << '\n';
-   if(!docbookinnertag_.empty())
+   if (!docbookinnertag_.empty())
os << "\tDocBookInnerTag " << docbookinnertag_ << '\n';
-   if(!docbookinnerattr_.empty())
+   if (!docbookinnerattr_.empty())
os << "\tDocBookInnerAttr \"" << docbookinnerattr_ << "\"\n";
-   if(!docbookinnertagtype_.empty())
+   if (!docbookinnertagtype_.empty())
os << "\tDocBookInnerTagType " << docbookinnertagtype_ << '\n';
-   if(!docbookininfo_.empty())
+   if (!docbookininfo_.empty())
os << "\tDocBookInInfo " << docbookininfo_ << '\n';
os << "\tDocBookAbstract " << docbookabstract_ << '\n';
-   if(!docbookwrappertag_.empty())
+   if (!docbookwrappertag_.empty())
os << "\tDocBookWrapperTag " << docbookwrappertag_ << '\n';
-   if(!docbookwrapperattr_.empty())
+   if (!docbookwrapperattr_.empty())
os << "\tDocBookWrapperAttr " << docbookwrapperattr_ << '\n';
-   if(!docbookwrappertagtype_.empty())
+   if (!docbookwrappertagtype_.empty())
os << "\tDocBookWrapperTagType " << docbookwrappertagtype_ << 
'\n';
os << "\tDocBookSection " << docbooksection_ << '\n';
-   if(!docbooksectiontag_.empty())
+   if (!docbooksectiontag_.empty())
os << "\tDocBookSectionTag " << docbooksectiontag_ << '\n';
-   if(!docbookitemtag_.empty())
+   if (!docbookitemtag_.empty())
os << "\tDocBookItemTag " << docbookitemtag_ << '\n';
-   if(!docbookitemattr_.empty())
+   if (!docbookitemattr_.empty())
os << "\tDocBookItemAttr " << docbookitemattr_ << '\n';
-   if(!docbookitemtagtype_.empty())
+   if (!docbookitemtagtype_.empty())
os << "\tDocBookItemTagType " << docbookitemtagtype_ << '\n';
-   if(!docbookitemwrappertag_.empty())
+   if (!docbookitemwrappertag_.empty())
os << "\tDocBookItemWrapperTag " << docbookitemwrappertag_ << 
'\n';
-   if(!docbookitemwrapperattr_.empty())
+   if (!docbookitemwrapperattr_.empty())
os << "\tDocBookItemWrapperAttr " << docbookitemwrapperattr_ << 
'\n';
-   if(!docbookitemwrappertagtype_.empty())
+   if (!docbookitemwrappertagtype_.empty())
os << "\tDocBookItemWrapperTagType " << 
docbookitemwrappertagtype_ << '\n';
os << "\tDocBookWrapperMergeWithPrevious " << 
docbookwrappermergewithprevious_ << '\n';
-   if(!docbookitemlabeltag_.empty())
+   if (!docbookitemlabeltag_.empty())
os << "\tDocBookItemLabelTag " << docbookitemlabeltag_ << '\n';
-   if(!docbookitemlabelattr_.empty())
+   if (!docbookitemlabelattr_.empty())
os << "\tDocBookItemLabelAttr " << docbookitemlabelattr_ << 
'\n';
-   if(!docbookitemlabeltagtype_.empty())
+   if (!docbookitemlabeltagtype_.empty())
os << "\tDocBookItemLabelTagType " << docbookitemlabeltagtype_ 
<< '\n';
-   if(!docbookiteminnertag_.empty())
+   if (!docbookiteminnertag_.empty())
os << "\tDocBookItemInne

[LyX/master] Revert "New Theorems Module. Contributed by Udicoudco on the mailing list. Rebased on top of master."

2022-12-31 Thread Thibaut Cuvelier
commit 017588973f773fcb9b17262902e73c76de3c8152
Author: Thibaut Cuvelier 
Date:   Sat Dec 31 11:28:56 2022 +0100

Revert "New Theorems Module. Contributed by Udicoudco 
 on the mailing list. Rebased on top of master."

This reverts commit 42c2a25fb873727d87ce753b3a3ac4e913e36fe0.

 autotests/export/docbook/theorems-thmtools.lyx |  624 --
 autotests/export/docbook/theorems-thmtools.xml |  128 ---
 lib/layouts/theorems-ams-bytype.inc|  364 +
 lib/layouts/theorems-ams-bytype.module |   25 +-
 lib/layouts/theorems-ams-chap-bytype.inc   |  459 +++
 lib/layouts/theorems-ams-chap-bytype.module|   26 +-
 lib/layouts/theorems-ams-extended-bytype.module|  453 +++-
 .../theorems-ams-extended-chap-bytype.module   |  536 -
 lib/layouts/theorems-ams-extended.module   |  445 ++-
 lib/layouts/theorems-ams.inc   |  352 
 lib/layouts/theorems-ams.module|   17 +-
 lib/layouts/theorems-bytype.inc|  359 
 lib/layouts/theorems-bytype.module |   67 +--
 lib/layouts/theorems-case.inc  |  134 ++--
 lib/layouts/theorems-chap-bytype.module|  193 --
 lib/layouts/theorems-chap.module   |   49 +-
 lib/layouts/theorems-extended.inc  |  466 ---
 lib/layouts/theorems-labels.inc|  136 
 lib/layouts/theorems-named.module  |   72 +-
 lib/layouts/theorems-order.inc |   83 ++
 lib/layouts/theorems-proof-std.inc |   69 +--
 lib/layouts/theorems-proof.inc |   15 +-
 lib/layouts/theorems-sec-bytype.module |  145 +++--
 lib/layouts/theorems-sec.module|   49 +--
 lib/layouts/theorems-starred-equivalents.inc   |   88 ++
 lib/layouts/theorems-starred.inc   |  345 
 lib/layouts/theorems-starred.module|   16 +
 lib/layouts/theorems-std.module|   47 +-
 lib/layouts/theorems-thmtools.module   |  852 
 lib/layouts/theorems.inc   |  366 +
 30 files changed, 3919 insertions(+), 3061 deletions(-)
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] New Theorems Module. Contributed by Udicoudco on the mailing list. Rebased on top of master.

2022-12-30 Thread Thibaut Cuvelier
commit 42c2a25fb873727d87ce753b3a3ac4e913e36fe0
Author: Thibaut Cuvelier 
Date:   Sat Dec 31 01:47:37 2022 +0100

New Theorems Module. Contributed by Udicoudco  
on the mailing list. Rebased on top of master.

I've modified all the non-AMS theorem modules so they would be 
independent of packages. currently
the code support \theoremstyle, but only with definition, plain and 
remark.

I'v added a new theorem module that support the thmtools 
\listoftheorems.

I've modified the syntax of all theorem modules, such that it would be 
easier to
create a new one, or maintaining the ones that exists. Instead of using 
\newtheorem
in the preamble of a lyaout, I wrote \lyx@newtheorem, and in each 
module I've defiened
\lyx@newtheorem as fitted. This way, there is only need in the files 
thorems-base, and theorems-extended,
instead of an .inc file for each module.

I've added theorems-labels.inc, a file that suppose to be included in a 
"Numbered by type" module,
to change the Label and the LabelCounter of the layouts in 
theorems-base.inc.

Note that in this configuration, all non-AMS modules will clash with 
the AMS ones, and so as the
proof versions. theorems-proof-std.inc suppose to be in the non-AMS 
while theorems-proof.inc
should be included only in AMS variants.

 autotests/export/docbook/theorems-thmtools.lyx |  624 ++
 autotests/export/docbook/theorems-thmtools.xml |  128 +++
 lib/layouts/theorems-ams-bytype.inc|  364 -
 lib/layouts/theorems-ams-bytype.module |   25 +-
 lib/layouts/theorems-ams-chap-bytype.inc   |  459 ---
 lib/layouts/theorems-ams-chap-bytype.module|   26 +-
 lib/layouts/theorems-ams-extended-bytype.module|  453 +---
 .../theorems-ams-extended-chap-bytype.module   |  536 +
 lib/layouts/theorems-ams-extended.module   |  445 +--
 lib/layouts/theorems-ams.inc   |  352 
 lib/layouts/theorems-ams.module|   17 +-
 lib/layouts/theorems-bytype.inc|  359 
 lib/layouts/theorems-bytype.module |   67 ++-
 lib/layouts/theorems-case.inc  |  134 ++--
 lib/layouts/theorems-chap-bytype.module|  193 ++
 lib/layouts/theorems-chap.module   |   49 +-
 lib/layouts/theorems-extended.inc  |  466 +++
 lib/layouts/theorems-labels.inc|  136 
 lib/layouts/theorems-named.module  |   72 +-
 lib/layouts/theorems-order.inc |   83 --
 lib/layouts/theorems-proof-std.inc |   69 ++-
 lib/layouts/theorems-proof.inc |   15 +-
 lib/layouts/theorems-sec-bytype.module |  145 ++---
 lib/layouts/theorems-sec.module|   49 ++-
 lib/layouts/theorems-starred-equivalents.inc   |   88 --
 lib/layouts/theorems-starred.inc   |  345 
 lib/layouts/theorems-starred.module|   16 -
 lib/layouts/theorems-std.module|   47 +-
 lib/layouts/theorems-thmtools.module   |  852 
 lib/layouts/theorems.inc   |  366 -
 30 files changed, 3061 insertions(+), 3919 deletions(-)
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Amend febd1855eb: fix compilability

2022-12-28 Thread Thibaut Cuvelier
commit 7a67302c01c9c8a08def90038cfbea1474c06151
Author: Thibaut Cuvelier 
Date:   Wed Dec 28 12:57:25 2022 +0100

Amend febd1855eb: fix compilability
---
 src/tests/dummy_functions.cpp |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/tests/dummy_functions.cpp b/src/tests/dummy_functions.cpp
index 2698351..190a44f 100644
--- a/src/tests/dummy_functions.cpp
+++ b/src/tests/dummy_functions.cpp
@@ -53,8 +53,6 @@ string alignmentToCSS(LyXAlignment)
 namespace xml {
 docstring StartTag::writeTag() const { return docstring(); }
 docstring StartTag::writeEndTag() const { return docstring(); }
-bool StartTag::operator==(FontTag const & rhs) const { return rhs == *this; }
-  bool FontTag::operator==(StartTag const & tag) const { FontTag const * const 
ftag = tag.asFontTag();   if (!ftag) return false; return (font_type_ == 
ftag->font_type_); }
 }
 
 } // namespace lyx
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix a typo in a comment

2022-12-27 Thread Thibaut Cuvelier
commit 4aeba17895cac6fa2e563f315eb7292eb508271f
Author: Thibaut Cuvelier 
Date:   Wed Dec 28 02:32:05 2022 +0100

Fix a typo in a comment
---
 src/tex2lyx/dummy_impl.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/tex2lyx/dummy_impl.cpp b/src/tex2lyx/dummy_impl.cpp
index 62436af..30eb847 100644
--- a/src/tex2lyx/dummy_impl.cpp
+++ b/src/tex2lyx/dummy_impl.cpp
@@ -10,7 +10,7 @@
 
 /**
  * This file contains dummy implementation of some methods that are
- * needed byclasses used by tex2lyx. This allows to reduce the number
+ * needed by classes used by tex2lyx. This allows to reduce the number
  * of classes we have to link against.
 */
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Amend febd1855eb: fix compilability of tex2lyx

2022-12-27 Thread Thibaut Cuvelier
commit 8b5bfa971bc9b3f2e49b48f25a2a2fee03004016
Author: Thibaut Cuvelier 
Date:   Wed Dec 28 02:33:11 2022 +0100

Amend febd1855eb: fix compilability of tex2lyx
---
 src/tex2lyx/dummy_impl.cpp |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/tex2lyx/dummy_impl.cpp b/src/tex2lyx/dummy_impl.cpp
index 30eb847..17e97ed 100644
--- a/src/tex2lyx/dummy_impl.cpp
+++ b/src/tex2lyx/dummy_impl.cpp
@@ -99,8 +99,6 @@ void lyx_exit(int)
 namespace xml {
 docstring StartTag::writeTag() const { return docstring(); }
 docstring StartTag::writeEndTag() const { return docstring(); }
-bool StartTag::operator==(FontTag const & rhs) const { return rhs == *this; }
-bool FontTag::operator==(StartTag const & tag) const { FontTag const * const 
ftag = tag.asFontTag(); if (!ftag) return false; return (font_type_ == 
ftag->font_type_); }
 }
 
 } // namespace lyx
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] XML: overhaul the tag-comparison operators.

2022-12-27 Thread Thibaut Cuvelier
commit febd1855eba8cd73f7e37790ead78a66378326ab
Author: Thibaut Cuvelier 
Date:   Tue Dec 27 16:52:51 2022 +0100

XML: overhaul the tag-comparison operators.

First and foremost, this patch implements the latest best practices in C++ 
(i.e. comparison operators are not member functions).

The main objective of this rewrite is to have these operators callable in 
slightly more general contexts (*this->asFontTag() == *rhs.asFontTag() yielded 
an error because no member function could be called). This feature is no more 
required.

The rewrite took place in the context of 
https://www.lyx.org/trac/ticket/12585. The first iteration was using more 
complex code to circumvent XMLStream in DocBook (see details in the bug above 
and in the mailing list), while this one uses XMLStream fully. The bug was due 
to font tags being considered equal when they were not, due to the comparison 
done only on the XML tag and not on the actual font change (XML attributes can 
complement the tag for various font changes).
---
 src/xml.cpp |   57 -
 src/xml.h   |   25 +
 2 files changed, 49 insertions(+), 33 deletions(-)

diff --git a/src/xml.cpp b/src/xml.cpp
index f466f61..53ccb8a 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -123,12 +123,6 @@ docstring StartTag::writeEndTag() const
 }
 
 
-bool StartTag::operator==(FontTag const ) const
-{
-   return rhs == *this;
-}
-
-
 docstring EndTag::writeEndTag() const
 {
return from_utf8("");
@@ -152,15 +146,6 @@ docstring CompTag::writeTag() const
return output;
 }
 
-
-bool FontTag::operator==(StartTag const & tag) const
-{
-   FontTag const * const ftag = tag.asFontTag();
-   if (!ftag)
-   return false;
-   return (font_type_ == ftag->font_type_);
-}
-
 } // namespace xml
 
 
@@ -679,6 +664,44 @@ docstring xml::cleanID(docstring const & orig)
 }
 
 
+bool operator==(xml::StartTag const & lhs, xml::StartTag const & rhs)
+{
+   xml::FontTag const * const lhs_ft = lhs.asFontTag();
+   xml::FontTag const * const rhs_ft = rhs.asFontTag();
+
+   if ((!lhs_ft && rhs_ft) || (lhs_ft && !rhs_ft))
+   return false;
+   if (!lhs_ft && !rhs_ft)
+   return lhs.tag_ == rhs.tag_;
+   return lhs_ft->tag_ == rhs_ft->tag_ && lhs_ft->font_type_ == 
rhs_ft->font_type_;
+}
+
+
+bool operator==(xml::EndTag const & lhs, xml::StartTag const & rhs)
+{
+   xml::EndFontTag const * const lhs_ft = lhs.asFontTag();
+   xml::FontTag const * const rhs_ft = rhs.asFontTag();
+
+   if ((!lhs_ft && rhs_ft) || (lhs_ft && !rhs_ft))
+   return false;
+   if (!lhs_ft && !rhs_ft)
+   return lhs.tag_ == rhs.tag_;
+   return lhs_ft->tag_ == rhs_ft->tag_ && lhs_ft->font_type_ == 
rhs_ft->font_type_;
+}
+
+
+bool operator!=(xml::EndTag const & lhs, xml::StartTag const & rhs)
+{
+   return !(lhs == rhs);
+}
+
+
+bool operator!=(xml::StartTag const & lhs, xml::StartTag const & rhs)
+{
+   return !(lhs == rhs);
+}
+
+
 void xml::openTag(odocstream & os, string const & name, string const & 
attribute)
 {
 // FIXME UNICODE
@@ -800,10 +823,10 @@ void closeBlockTag(XMLStream & xs, const docstring & tag)
 
 void xml::openTag(XMLStream & xs, const docstring & tag, const docstring & 
attr, const std::string & tagtype)
 {
-   if (tag.empty() || tag == "NONE") // Common check to be performed 
elsewhere, if it was not here.
+   if (tag.empty() || tag == from_ascii("NONE")) // Common check to be 
performed elsewhere, if it was not here.
return;
 
-   if (tag == "para" || tagtype == "paragraph") // Special case for 
: always considered as a paragraph.
+   if (tag == from_ascii("para") || tagtype == "paragraph") // Special 
case for : always considered as a paragraph.
openParTag(xs, tag, attr);
else if (tagtype == "block")
openBlockTag(xs, tag, attr);
diff --git a/src/xml.h b/src/xml.h
index bf72fac..03710c1 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -196,14 +196,6 @@ struct StartTag
///
virtual FontTag const * asFontTag() const { return nullptr; }
///
-   virtual bool operator==(StartTag const & rhs) const
-   { return tag_ == rhs.tag_; }
-   ///
-   virtual bool operator!=(StartTag const & rhs) const
-   { return !(*this == rhs); }
-   ///
-   virtual bool operator==(FontTag const & rhs) const;
-   ///
docstring tag_;
///
docstring attr_;
@@ -229,12 +221,6 @@ struct EndTag
/// 
virtual docstring writeEndTag() const;
///
-   bool operator==(StartTag const &a

[LyX/master] DocBookGenerateTitle: update all layouts.

2022-12-27 Thread Thibaut Cuvelier
commit 0af5fbcc0e47d1e4ea9a2ec87465c152e4a9d819
Author: Thibaut Cuvelier 
Date:   Fri Dec 23 02:26:52 2022 +0100

DocBookGenerateTitle: update all layouts.

 lib/citeengines/basic.citeengine   |2 +-
 lib/citeengines/biblatex-natbib.citeengine |2 +-
 lib/citeengines/biblatex.citeengine|2 +-
 lib/citeengines/jurabib.citeengine |2 +-
 lib/citeengines/natbib.citeengine  |2 +-
 lib/layouts/AEA.layout |2 +-
 lib/layouts/IEEEtran-CompSoc.layout|2 +-
 lib/layouts/IEEEtran-TransMag.layout   |2 +-
 lib/layouts/IEEEtran.layout|2 +-
 lib/layouts/InStar.module  |2 +-
 lib/layouts/RJournal.layout|2 +-
 lib/layouts/a0poster.layout|2 +-
 lib/layouts/aa.layout  |5 -
 lib/layouts/aapaper.inc|2 +-
 lib/layouts/aapaper.layout |2 +-
 lib/layouts/aastex.layout  |2 +-
 lib/layouts/aastex6.layout |2 +-
 lib/layouts/aastex62.layout|2 +-
 lib/layouts/achemso.layout |2 +-
 lib/layouts/acm-sigs-alt.layout|2 +-
 lib/layouts/acm-sigs.inc   |2 +-
 lib/layouts/acm-sigs.layout|2 +-
 lib/layouts/acmart.layout  |2 +-
 lib/layouts/acmsiggraph-0-92.layout|2 +-
 lib/layouts/acmsiggraph.layout |2 +-
 lib/layouts/agums.layout   |2 +-
 lib/layouts/aguplus.inc|2 +-
 lib/layouts/agutex.layout  |2 +-
 lib/layouts/algorithm2e.module |2 +-
 lib/layouts/amsart.layout  |2 +-
 lib/layouts/amsbook.layout |4 ++--
 lib/layouts/amsdefs.inc|2 +-
 lib/layouts/apa.layout |4 ++--
 lib/layouts/apa6.layout|2 +-
 lib/layouts/apa7.layout|2 +-
 lib/layouts/apax.inc   |4 ++--
 lib/layouts/arab-article.layout|2 +-
 lib/layouts/article-beamer.layout  |2 +-
 lib/layouts/article.layout |2 +-
 lib/layouts/beamer.layout  |4 ++--
 lib/layouts/beamerposter.layout|2 +-
 lib/layouts/bicaption.module   |2 +-
 lib/layouts/book.layout|2 +-
 lib/layouts/braille.module |2 +-
 lib/layouts/broadway.layout|2 +-
 lib/layouts/bxjsarticle.layout |2 +-
 lib/layouts/bxjsbook.layout|2 +-
 lib/layouts/bxjsreport.layout  |2 +-
 lib/layouts/bxjsslide.layout   |2 +-
 lib/layouts/chess.layout   |2 +-
 lib/layouts/chessboard.module  |2 +-
 lib/layouts/cl2emult.layout|2 +-
 lib/layouts/copernicus.layout  |2 +-
 lib/layouts/ctex-article.layout|2 +-
 lib/layouts/ctex-book.layout   |2 +-
 lib/layouts/ctex-report.layout |2 +-
 lib/layouts/customHeadersFooters.module|2 +-
 lib/layouts/db_stdcharstyles.inc   |2 +-
 lib/layouts/db_stdclass.inc|2 +-
 lib/layouts/db_stdstarsections.inc |2 +-
 lib/layouts/db_stdstruct.inc   |2 +-
 lib/layouts/db_stdtitle.inc|2 +-
 lib/layouts/dinbrief.layout|2 +-
 lib/layouts/docbook-book.layout|2 +-
 lib/layouts/docbook-chapter.layout |2 +-
 lib/layouts/docbook-section.layout |2 +-
 lib/layouts/docbook.layout |2 +-
 lib/layouts/doublecol-new.layout   |2 +-
 lib/layouts/dtk.layout |2 +-
 lib/layouts/ectaart.layout |2 +-
 lib/layouts/egs.layout |2 +-
 lib/layouts/elsart.layout  |2 +-
 lib/layouts/elsarticle.layout  |2 +-
 lib/layouts/endnotes.module|2 +-
 lib/layouts/enotez.module  |2 +-
 lib/layouts/entcs.layout   |2 +-
 lib/layouts/enumitem.module|2 +-
 lib/layouts/eqs-within-sections.module

[LyX/master] DocBook: add support for DocBookGenerateTitle.

2022-12-27 Thread Thibaut Cuvelier
commit 16a1aa9901adc1f91671499b39565f9bccc2e644
Author: Thibaut Cuvelier 
Date:   Thu Dec 22 04:38:36 2022 +0100

DocBook: add support for DocBookGenerateTitle.

The new parameter allows more flexibility when encoding some elements that 
have a poor mapping in DocBook, like theorems. The major use is to wrap the 
environment in a generic container, figure, which requires a title (but none is 
available).

 autotests/export/docbook/theorems-mathml.lyx |  148 ++
 autotests/export/docbook/theorems-mathml.xml |   85 +++
 lib/layouts/elsart.layout|   62 ---
 lib/layouts/theorems-ams-bytype.inc  |   53 +++---
 lib/layouts/theorems-ams-chap-bytype.inc |   53 +++---
 lib/layouts/theorems-ams.inc |   51 +++---
 lib/layouts/theorems-bytype.inc  |   53 +++---
 lib/layouts/theorems-starred.inc |   56 +++---
 lib/layouts/theorems-without-preamble.inc|   83 +++
 lib/layouts/theorems.inc |   51 +++---
 lib/scripts/layout2layout.py |7 +-
 src/Layout.cpp   |6 +
 src/Layout.h |8 ++-
 src/TextClass.cpp|2 +-
 src/output_docbook.cpp   |   15 +++-
 15 files changed, 600 insertions(+), 133 deletions(-)
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] layout2layout: remove unused regex.

2022-12-27 Thread Thibaut Cuvelier
commit 7f5c917c71b97c880d333c6de5ed0af86ff6
Author: Thibaut Cuvelier 
Date:   Tue Dec 27 03:21:29 2022 +0100

layout2layout: remove unused regex.
---
 lib/scripts/layout2layout.py |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 4f5cb04..a8c0ded 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -454,7 +454,6 @@ def convert(lines, end_format):
 re_CopyStyle2 = re.compile(b'(\\s*CopyStyle\\s+)"?([^"]+)"?\\s*$')
 re_Separator = 
re.compile(b'^(?:(-*)|(\\s*))(Separator|EndOfSlide)(?:(-*)|(\\s*))$', 
re.IGNORECASE)
 # for categories
-re_Declaration = re.compile(b'^#\\s*\\Declare\\w+Class.*$')
 re_ExtractCategory = 
re.compile(b'^(#\\s*\\Declare\\w+Class(?:\\[[^]]*?\\])?){([^(]+?)\\s+\\(([^)]+?)\\)\\s*}\\s*$')
 ConvDict = {b"article": b"Articles", b"book": b"Books", b"letter": 
b"Letters", b"report": b"Reports",
 b"presentation": b"Presentations", b"curriculum vitae": 
b"Curricula Vitae", b"handout": b"Handouts"}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] DocBook: for computing font changes, simplify code by removing state evolution from iteration to iteration. This surely makes the code slightly slower (although the compiler should be sma

2022-12-26 Thread Thibaut Cuvelier
commit ed7072985e6a76a8013ea670728fc40e6359c723
Author: Thibaut Cuvelier 
Date:   Mon Dec 26 02:45:03 2022 +0100

DocBook: for computing font changes, simplify code by removing state 
evolution from iteration to iteration. This surely makes the code slightly 
slower (although the compiler should be smart enough), but (much) easier to 
reason about.
---
 src/Paragraph.cpp |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 9c3b0dc..8650826 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3568,8 +3568,6 @@ std::tuple, 
std::vector, std::vectorlayout_;
-FontInfo font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : 
style.font;
-string const default_family = 
buf.masterBuffer()->params().fonts_default_family;
 
// Conversion of the font opening/closing into DocBook tags.
 vector tagsToOpen;
@@ -3602,14 +3600,17 @@ std::tuple, 
std::vector, std::vectorparams(), i - 1, 
outerfont).fontInfo());
Font const font = getFont(buf.masterBuffer()->params(), i, 
outerfont);
-tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(font_old, 
font, default_family, fs);
+tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(
+   font_old, font, 
buf.masterBuffer()->params().fonts_default_family, fs);
 
if (!ignore_fonts_i) {
 vector::const_iterator cit = tagsToClose.begin();
@@ -3665,7 +3666,6 @@ std::tuple, 
std::vector, std::vectorhttp://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] DocBook: add some TODOs for the future.

2022-12-26 Thread Thibaut Cuvelier
commit 2b03f0a2c1d9becc3261a97fecd3aab8f6e518c6
Author: Thibaut Cuvelier 
Date:   Tue Dec 27 00:02:30 2022 +0100

DocBook: add some TODOs for the future.
---
 src/output_docbook.h |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/output_docbook.h b/src/output_docbook.h
index a65e0c8..1fd8d5e 100644
--- a/src/output_docbook.h
+++ b/src/output_docbook.h
@@ -12,6 +12,15 @@
  * Full author contact details are available in file CREDITS.
  */
 
+// TODO: respect languages when opening tags: par.getParLanguage(bparams) in 
output_latex.cpp
+// TODO: if the user specifically asks, output change-tracking information 
(choice between revisionflag attribute and
+//  Oxygen's formatting)
+// 
+//...
+//XXX
+// 
+
 #ifndef OUTPUT_DOCBOOK_H
 #define OUTPUT_DOCBOOK_H
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] layout2layout: improve coding style.

2022-12-26 Thread Thibaut Cuvelier
commit 55ccae72d4c93e95caf9c2424eb85e5be5dd7650
Author: Thibaut Cuvelier 
Date:   Mon Dec 26 21:21:52 2022 +0100

layout2layout: improve coding style.

Useless parentheses (not helping with readability either) and semicolon. 
Redo indentation to be consistent throughout the file. Also, fix typos along 
the way.
---
 lib/scripts/layout2layout.py |  338 -
 1 files changed, 165 insertions(+), 173 deletions(-)

diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index d923d65..cc60992 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -504,7 +504,6 @@ def convert(lines, end_format):
 toclevel = b""
 label = b""
 labelstring = b""
-labelstringappendix = b""
 space1 = b""
 labelstring_line = -1
 labelstringappendix_line = -1
@@ -520,30 +519,28 @@ def convert(lines, end_format):
 opts = 0
 reqs = 0
 inchapter = False
-isflexlayout = False # only used for 48 -> 49
 # Whether a style is inherited (works only for CopyStyle currently,
 # not for true inherited styles, see bug 8920
 inherited = False# only used for 48 -> 49
-resetsfont_found = False # only used for 48 -> 49
 
 while i < len(lines):
 # Skip comments and empty lines
 if (re_Comment.match(lines[i]) or re_Empty.match(lines[i])):
-  # We need to deal with this conversion here, because it happens
-  # inside the initial comment block.
-  if only_comment and format == 39:
-  match = re_ExtractCategory.match(lines[i])
-  if match:
-  lpre = match.group(1)
-  lcat = match.group(2)
-  lnam = match.group(3)
-  if lcat in ConvDict:
-  lcat = ConvDict[lcat]
-  lines[i] = lpre + b"{" + lnam + b"}"
-  lines.insert(i+1, b"#  \\DeclareCategory{" + lcat + b"}")
-  i += 1
-  i += 1
-  continue
+# We need to deal with this conversion here, because it happens
+# inside the initial comment block.
+if only_comment and format == 39:
+match = re_ExtractCategory.match(lines[i])
+if match:
+lpre = match.group(1)
+lcat = match.group(2)
+lnam = match.group(3)
+if lcat in ConvDict:
+lcat = ConvDict[lcat]
+lines[i] = lpre + b"{" + lnam + b"}"
+lines.insert(i+1, b"#  \\DeclareCategory{" + lcat + b"}")
+i += 1
+i += 1
+continue
 
 # insert file format if not already there
 if only_comment:
@@ -735,8 +732,8 @@ def convert(lines, end_format):
 if format == 48:
 # The default of ResetsFont in LyX changed from true to false,
 # because it is now used for all InsetLayouts, not only flex ones.
-# Therefore we need to set it to true for all flex insets which do
-# do not already have a ResetsFont.
+# Therefore, we need to set it to true for all flex insets which do
+# not already have a ResetsFont.
 match = re_InsetLayout2.match(lines[i])
 if not match:
 i += 1
@@ -749,22 +746,21 @@ def convert(lines, end_format):
 
 resetsfont_found = False
 inherited = False
-notdone = True
 while i < len(lines):
-  match = re_ResetsFont.match(lines[i])
-  if match:
-  resetsfont_found = True
-  else:
-match = re_CopyStyle.match(lines[i])
+match = re_ResetsFont.match(lines[i])
 if match:
-  inherited = True
+resetsfont_found = True
 else:
-  match = re_End.match(lines[i])
-  if match:
-break
-  i += 1
+match = re_CopyStyle.match(lines[i])
+if match:
+inherited = True
+else:
+match = re_End.match(lines[i])
+if match:
+break
+i += 1
 if not resetsfont_found and not inherited:
-  lines.insert(i, b"\tResetsFont true")
+lines.insert(i, b"\tResetsFont true")
 
 continue
 
@@ -774,38 +770,38 @@ def convert(lines, end_format):
 continue
 
 if format == 43:
-  match = re_LabelTypeIsCounter.match(lines[i])
-  if match:
-if inchapter:
- l

[LyX/master] Add comments about variable usage.

2022-12-26 Thread Thibaut Cuvelier
commit e3eddd4cf9f63b365846ceba162a6f2b7505051b
Author: Thibaut Cuvelier 
Date:   Mon Dec 26 02:44:57 2022 +0100

Add comments about variable usage.
---
 src/Paragraph.cpp |   13 +
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 6baac81..9c3b0dc 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3528,9 +3528,12 @@ std::tuple, 
std::vector, std::vector prependedParagraphs;
-   std::vector generatedParagraphs;
-   std::vector appendedParagraphs;
+   // Return values: segregation of the content of this paragraph.
+   std::vector prependedParagraphs; // Anything that must be 
output before the main tag of this paragraph.
+   std::vector generatedParagraphs; // The main content of the 
paragraph.
+   std::vector appendedParagraphs;  // Anything that must be 
output after the main tag of this paragraph.
+
+   // Internal string stream to store the output before being added to one 
of the previous lists.
odocstringstream os;
 
// If there is an argument that must be output before the main tag, do 
it before handling the rest of the paragraph.
@@ -3560,13 +3563,15 @@ std::tuple, 
std::vector, std::vector delayedChars; // When a font tag ends with a space, 
output it after the closing font tag.
 // This requires to store delayed characters at some point.
 
-DocBookFontState fs; // Track whether we have opened font tags
+   // Track whether we have opened font tags
+DocBookFontState fs;
 DocBookFontState old_fs = fs;
 
 Layout const & style = *d->layout_;
 FontInfo font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : 
style.font;
 string const default_family = 
buf.masterBuffer()->params().fonts_default_family;
 
+   // Conversion of the font opening/closing into DocBook tags.
 vector tagsToOpen;
 vector tagsToClose;
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix a typo in a comment.

2022-12-26 Thread Thibaut Cuvelier
commit 8b6ec979ff26f36062f4cad07cce0c11a4583c6b
Author: Thibaut Cuvelier 
Date:   Mon Dec 26 02:44:29 2022 +0100

Fix a typo in a comment.
---
 src/Paragraph.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index e2338ba..6baac81 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3589,7 +3589,7 @@ std::tuple, 
std::vector, std::vectorhttp://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetIPAMacro: implement the XHTML conversion, refactor plaintext and DocBook to share more code.

2022-12-26 Thread Thibaut Cuvelier
commit b2fdc04f9638c7def8f74f0af1c3e480431b28a6
Author: Thibaut Cuvelier 
Date:   Mon Dec 26 20:50:48 2022 +0100

InsetIPAMacro: implement the XHTML conversion, refactor plaintext and 
DocBook to share more code.
---
 src/insets/InsetIPAMacro.cpp |   37 -
 1 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp
index 5aeaf84..2d4b1fb 100644
--- a/src/insets/InsetIPAMacro.cpp
+++ b/src/insets/InsetIPAMacro.cpp
@@ -283,14 +283,27 @@ void InsetIPADeco::latex(otexstream & os, OutputParams 
const & runparams) const
 }
 
 
-int InsetIPADeco::plaintext(odocstringstream & os,
-   OutputParams const & runparams, size_t max_length) 
const
+namespace {
+std::pair splitPlainTextInHalves(
+   const InsetIPADeco * inset, OutputParams const & runparams,
+   size_t max_length = INT_MAX)
 {
odocstringstream ods;
-   int h = InsetCollapsible::plaintext(ods, runparams, max_length) / 2;
+   int h = inset->InsetCollapsible::plaintext(ods, runparams, max_length) 
/ 2;
docstring result = ods.str();
docstring const before = result.substr(0, h);
docstring const after = result.substr(h, result.size());
+   return {before, after};
+}
+}
+
+
+int InsetIPADeco::plaintext(odocstringstream & os,
+   OutputParams const & runparams, size_t max_length) 
const
+{
+   docstring before;
+   docstring after;
+   tie(before, after) = splitPlainTextInHalves(this, runparams, 
max_length);
 
if (params_.type == InsetIPADecoParams::Toptiebar) {
os << before;
@@ -302,7 +315,7 @@ int InsetIPADeco::plaintext(odocstringstream & os,
os.put(0x035c);
os << after;
}
-   return result.size();
+   return before.size() + after.size();
 }
 
 
@@ -310,11 +323,9 @@ void InsetIPADeco::docbook(XMLStream & xs, OutputParams 
const & runparams) const
 {
// The special combining character must be put in the middle, between 
the two other characters.
// It will not work if there is anything else than two pure characters, 
so going back to plaintext.
-   odocstringstream ods;
-   int h = InsetText::plaintext(ods, runparams) / 2;
-   docstring result = ods.str();
-   docstring const before = result.substr(0, h);
-   docstring const after = result.substr(h, result.size());
+   docstring before;
+   docstring after;
+   tie(before, after) = splitPlainTextInHalves(this, runparams);
 
xs << XMLStream::ESCAPE_NONE << before;
if (params_.type == InsetIPADecoParams::Toptiebar)
@@ -327,10 +338,10 @@ void InsetIPADeco::docbook(XMLStream & xs, OutputParams 
const & runparams) const
 
 docstring InsetIPADeco::xhtml(XMLStream & xs, OutputParams const & runparams) 
const
 {
-   // FIXME: Like in plaintext, the combining characters "" 
(toptiebar)
-   // or "" (bottomtiebar) would need to be inserted just in the mid
-   // of the text string. (How) can this be done with the xhtml stream?
-   return InsetCollapsible::xhtml(xs, runparams);
+   // The DocBook encoding for this inset has no DocBook tag, but sheer 
XML (relying on a plaintext
+   // transformation of the inset).
+   docbook(xs, runparams);
+   return docstring();
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetMathExFunc: use XML entities instead of HTML in MathML.

2022-12-26 Thread Thibaut Cuvelier
commit 3839897c0fcaa5b2275d05d901a517610331f304
Author: Thibaut Cuvelier 
Date:   Mon Dec 26 20:38:06 2022 +0100

InsetMathExFunc: use XML entities instead of HTML in MathML.

This part should have been committed with bc73a857 in the first place.
---
 src/mathed/InsetMathExFunc.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mathed/InsetMathExFunc.cpp b/src/mathed/InsetMathExFunc.cpp
index c450cce..ea557b1 100644
--- a/src/mathed/InsetMathExFunc.cpp
+++ b/src/mathed/InsetMathExFunc.cpp
@@ -128,7 +128,7 @@ void InsetMathExFunc::mathmlize(MathMLStream & ms) const
   << name_
<< ETagInline("mi")
   << MTagInline("mo")
-  << ""
+  << ""
   << ETagInline("mo")
   << cell(0);
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetMathSpace: use XML entities instead of HTML in MathML.

2022-12-26 Thread Thibaut Cuvelier
commit 9b80a5ba9e1d072daa9ec3fd3e6470e5460db1f4
Author: Thibaut Cuvelier 
Date:   Mon Dec 26 20:35:26 2022 +0100

InsetMathSpace: use XML entities instead of HTML in MathML.

This part should have been committed with bc73a857 in the first place.
---
 src/mathed/InsetMathSpace.cpp |   17 +++--
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/mathed/InsetMathSpace.cpp b/src/mathed/InsetMathSpace.cpp
index 874012d..f507592 100644
--- a/src/mathed/InsetMathSpace.cpp
+++ b/src/mathed/InsetMathSpace.cpp
@@ -203,11 +203,8 @@ void InsetMathSpace::mathmlize(MathMLStream & ms) const
string l;
if (si.custom)
l = length_.asHTMLString();
-   else if (si.kind != InsetSpaceParams::MEDIUM) {
-   stringstream ss;
-   ss << si.width;
-   l = ss.str() + "px";
-   }
+   else if (si.kind != InsetSpaceParams::MEDIUM)
+   l = to_string(si.width) + "px";
 
std::string attr;
if (!l.empty())
@@ -222,23 +219,23 @@ void InsetMathSpace::htmlize(HtmlStream & ms) const
SpaceInfo const & si = space_info[space_];
switch (si.kind) {
case InsetSpaceParams::THIN:
-   ms << from_ascii("");
+   ms << from_ascii(""); // HTML: 
break;
case InsetSpaceParams::MEDIUM:
ms << from_ascii("");
break;
case InsetSpaceParams::THICK:
-   ms << from_ascii("");
+   ms << from_ascii(""); // HTML: 
break;
case InsetSpaceParams::ENSKIP:
case InsetSpaceParams::ENSPACE:
-   ms << from_ascii("");
+   ms << from_ascii(""); // HTML: 
break;
case InsetSpaceParams::QUAD:
-   ms << from_ascii("");
+   ms << from_ascii(""); // HTML: 
break;
case InsetSpaceParams::QQUAD:
-   ms << from_ascii("");
+   ms << from_ascii(""); // HTML: 
break;
case InsetSpaceParams::HFILL:
case InsetSpaceParams::HFILL_PROTECTED:
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] InsetIPAMacro: refactor code between DocBook and XHTML.

2022-12-26 Thread Thibaut Cuvelier
commit df025d15df89dac100a368eed7c86a5b754e9f7c
Author: Thibaut Cuvelier 
Date:   Mon Dec 26 20:23:05 2022 +0100

InsetIPAMacro: refactor code between DocBook and XHTML.
---
 src/insets/InsetIPAMacro.cpp |   67 +
 1 files changed, 21 insertions(+), 46 deletions(-)

diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp
index a529d04..5aeaf84 100644
--- a/src/insets/InsetIPAMacro.cpp
+++ b/src/insets/InsetIPAMacro.cpp
@@ -553,59 +553,34 @@ int InsetIPAChar::plaintext(odocstringstream & os, 
OutputParams const &, size_t)
 }
 
 
+namespace {
+std::string ipaCharToXMLEntity(InsetIPAChar::Kind kind) {
+   switch (kind) {
+   case InsetIPAChar::Kind::TONE_FALLING:
+   return "";
+   case InsetIPAChar::Kind::TONE_RISING:
+   return "";
+   case InsetIPAChar::Kind::TONE_HIGH_RISING:
+   return "";
+   case InsetIPAChar::Kind::TONE_LOW_RISING:
+   return "";
+   case InsetIPAChar::Kind::TONE_HIGH_RISING_FALLING:
+   return "";
+   }
+   return "";
+}
+}
+
+
 void InsetIPAChar::docbook(XMLStream & xs, OutputParams const &) const
 {
-   switch (kind_) {
-   case TONE_FALLING:
-   xs << XMLStream::ESCAPE_NONE << "";
-   xs << XMLStream::ESCAPE_NONE << "";
-   break;
-   case TONE_RISING:
-   xs << XMLStream::ESCAPE_NONE << "";
-   xs << XMLStream::ESCAPE_NONE << "";
-   break;
-   case TONE_HIGH_RISING:
-   xs << XMLStream::ESCAPE_NONE << "";
-   xs << XMLStream::ESCAPE_NONE << "";
-   break;
-   case TONE_LOW_RISING:
-   xs << XMLStream::ESCAPE_NONE << "";
-   xs << XMLStream::ESCAPE_NONE << "";
-   break;
-   case TONE_HIGH_RISING_FALLING:
-   xs << XMLStream::ESCAPE_NONE << "";
-   xs << XMLStream::ESCAPE_NONE << "";
-   xs << XMLStream::ESCAPE_NONE << "";
-   break;
-   }
+   xs << XMLStream::ESCAPE_NONE << from_ascii(ipaCharToXMLEntity(kind()));
 }
 
 
 docstring InsetIPAChar::xhtml(XMLStream & xs, OutputParams const &) const
 {
-   switch (kind_) {
-   case TONE_FALLING:
-   xs << XMLStream::ESCAPE_NONE << ""
-  << XMLStream::ESCAPE_NONE << "";
-   break;
-   case TONE_RISING:
-   xs << XMLStream::ESCAPE_NONE << ""
-  << XMLStream::ESCAPE_NONE << "";
-   break;
-   case TONE_HIGH_RISING:
-   xs << XMLStream::ESCAPE_NONE << ""
-  << XMLStream::ESCAPE_NONE << "";
-   break;
-   case TONE_LOW_RISING:
-   xs << XMLStream::ESCAPE_NONE << ""
-  << XMLStream::ESCAPE_NONE << "";
-   break;
-   case TONE_HIGH_RISING_FALLING:
-   xs << XMLStream::ESCAPE_NONE << ""
-  << XMLStream::ESCAPE_NONE << ""
-  << XMLStream::ESCAPE_NONE << "";
-   break;
-   }
+   xs << XMLStream::ESCAPE_NONE << from_ascii(ipaCharToXMLEntity(kind()));
return docstring();
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] DocBook/HTML: use XML entities for spaces.

2022-12-26 Thread Thibaut Cuvelier
commit 21d1d917ba0b3da902a1c4648a5fbf3a6d287d75
Author: Thibaut Cuvelier 
Date:   Mon Dec 26 19:11:41 2022 +0100

DocBook/HTML: use XML entities for spaces.

This part should have been committed with bc73a857 in the first place.
---
 src/insets/InsetSpace.cpp |  118 +++-
 1 files changed, 30 insertions(+), 88 deletions(-)

diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp
index 71c7395..6541a30 100644
--- a/src/insets/InsetSpace.cpp
+++ b/src/insets/InsetSpace.cpp
@@ -774,44 +774,36 @@ int InsetSpace::plaintext(odocstringstream & os,
 }
 
 
-void InsetSpace::docbook(XMLStream & xs, OutputParams const &) const
-{
-   switch (params_.kind) {
+namespace {
+std::string spaceToXMLEntity(InsetSpaceParams::Kind kind) {
+   switch (kind) {
case InsetSpaceParams::NORMAL:
-   xs << XMLStream::ESCAPE_NONE << " ";
-   break;
+   return " ";
case InsetSpaceParams::QUAD:
-   xs << XMLStream::ESCAPE_NONE << ""; // HTML: 
-   break;
+   return ""; // HTML: 
case InsetSpaceParams::QQUAD:
-   xs << XMLStream::ESCAPE_NONE << ""; // HTML: 

-   break;
+   return ""; // HTML: 
case InsetSpaceParams::ENSKIP:
-   xs << XMLStream::ESCAPE_NONE << ""; // HTML: 
-   break;
-   case InsetSpaceParams::PROTECTED:
-   xs << XMLStream::ESCAPE_NONE << ""; // HTML: 
-   break;
+   return ""; // HTML: 
case InsetSpaceParams::VISIBLE:
-   xs << XMLStream::ESCAPE_NONE << "";
-   break;
+   return "";
case InsetSpaceParams::ENSPACE: // HTML:  (word 
joiners)
-   xs << XMLStream::ESCAPE_NONE << "";
-   break;
+   return "";
case InsetSpaceParams::THIN:
-   xs << XMLStream::ESCAPE_NONE << ""; // HTML: 
-   break;
+   return ""; // HTML: 
case InsetSpaceParams::MEDIUM:
-   xs << XMLStream::ESCAPE_NONE << ""; // HTML: 
-   break;
+   return ""; // HTML: 
case InsetSpaceParams::THICK:
-   xs << XMLStream::ESCAPE_NONE << ""; // HTML: 
-   break;
+   return ""; // HTML: 
+   case InsetSpaceParams::PROTECTED:
case InsetSpaceParams::NEGTHIN:
case InsetSpaceParams::NEGMEDIUM:
case InsetSpaceParams::NEGTHICK:
-   xs << XMLStream::ESCAPE_NONE << ""; // HTML: 
-   break;
+   return ""; // HTML: 
+   case InsetSpaceParams::CUSTOM_PROTECTED:
+   // FIXME XHTML/DocBook
+   // Probably we could do some sort of blank span?
+   return "";
case InsetSpaceParams::HFILL:
case InsetSpaceParams::HFILL_PROTECTED:
case InsetSpaceParams::DOTFILL:
@@ -821,74 +813,24 @@ void InsetSpace::docbook(XMLStream & xs, OutputParams 
const &) const
case InsetSpaceParams::UPBRACEFILL:
case InsetSpaceParams::DOWNBRACEFILL:
case InsetSpaceParams::CUSTOM:
-   case InsetSpaceParams::CUSTOM_PROTECTED:
-   xs << '\n';
-   break;
+   // FIXME XHTML/DocBook
+   // Can we do anything with those?
+   return "\n";
}
+   return "";
+}
+}
+
+
+void InsetSpace::docbook(XMLStream & xs, OutputParams const &) const
+{
+   xs << XMLStream::ESCAPE_NONE << 
from_ascii(spaceToXMLEntity(params_.kind));
 }
 
 
 docstring InsetSpace::xhtml(XMLStream & xs, OutputParams const &) const
 {
-   string output;
-   switch (params_.kind) {
-   case InsetSpaceParams::NORMAL:
-   output = " ";
-   break;
-   case InsetSpaceParams::ENSKIP:
-   output ="";
-   break;
-   case InsetSpaceParams::ENSPACE:
-   output ="";
-   break;
-   case InsetSpaceParams::QQUAD:
-   output ="";
-   break;
-   case InsetSpaceParams::THICK:
-   output ="";
-   break;
-   case InsetSpaceParams::QUAD:
-   output ="";
-   break;
-   case InsetSpaceParams::MEDIUM:
-   output ="";
-   break;
-   case InsetSpaceParams::THIN:
-   output ="";
-   break;
-   case InsetSpaceParams::PROTECT

  1   2   3   4   5   6   7   >