summaryrefslogtreecommitdiff
path: root/src/qdoc/xmlgenerator.cpp
diff options
context:
space:
mode:
authorThibaut Cuvelier <cuvelier.thibaut@gmail.com>2022-07-23 03:44:34 +0200
committerThibaut Cuvelier <cuvelier.thibaut@gmail.com>2022-08-11 16:19:30 +0200
commit201c9908fa10adc25877069f9ccc4bd7dfecf9e3 (patch)
tree3d747834542e79b81b5b941758196ef385813fc3 /src/qdoc/xmlgenerator.cpp
parent8cbe0deec9da1025514c0cab380b772ae5bccaa4 (diff)
downloadqttools-201c9908fa10adc25877069f9ccc4bd7dfecf9e3.tar.gz
Fix a common mistake when setting table size
Wrong: \table 100 % Right: \table 100% Parse the first one as if it was the second, with some defense. Change-Id: I418c13c633ec474b5fc689aa9826bc1406a04c6b Pick-to: 6.4 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/xmlgenerator.cpp')
-rw-r--r--src/qdoc/xmlgenerator.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/qdoc/xmlgenerator.cpp b/src/qdoc/xmlgenerator.cpp
index d16a217d4..58efe1cea 100644
--- a/src/qdoc/xmlgenerator.cpp
+++ b/src/qdoc/xmlgenerator.cpp
@@ -183,7 +183,21 @@ std::pair<QString, QString> XmlGenerator::getTableWidthAttr(const Atom *atom)
else if (p1.contains(QLatin1Char('%')))
width = p1;
}
- return std::pair<QString, QString>(width, attr);
+
+ // Many times, in the documentation, there is a space before the % sign:
+ // this breaks the parsing logic above.
+ if (width == QLatin1String("%")) {
+ // The percentage is typically stored in p0, parse it as an int.
+ bool ok = false;
+ int widthPercentage = p0.toInt(&ok);
+ if (ok) {
+ width = QString::number(widthPercentage) + "%";
+ } else {
+ width = {};
+ }
+ }
+
+ return {width, attr};
}
/*!