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

Thibaut Cuvelier tcuvelier at lyx.org
Mon Jan 9 02:09:08 UTC 2023


commit 9ae793c6070cf31acd2e8f531b184fd6fc4a9279
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
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<std::string> 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 += "; ";
 			}


More information about the lyx-cvs mailing list