diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-05-20 12:58:36 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-06-01 21:13:58 +0200 |
commit | 237fa21feef63884043bd6cf32682b2b08c78454 (patch) | |
tree | dabbd1a0ece334bfb37bce76042621d7ae94b907 /src/gui/text/qtexthtmlparser.cpp | |
parent | ca0c9f82cbf7c8c37acdcbdfdc3fa0c5fc138059 (diff) |
Markdown and HTML: support image alt text and title
It's a required CommonMark feature:
https://spec.commonmark.org/0.29/#images
and alt text is also required in HTML:
https://www.w3.org/wiki/Html/Elements/img#Requirements_for_providing_text_to_act_as_an_alternative_for_images
Now we are able to read these attributes from either html or markdown
and rewrite either an html or markdown document that preserves them.
This patch does not add viewing or editing support in QTextEdit etc.
Change-Id: I51307389f8f9fc00809808390e583a83111a7b33
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/gui/text/qtexthtmlparser.cpp')
-rw-r--r-- | src/gui/text/qtexthtmlparser.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 37051502fa..49ee6394ee 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1556,6 +1556,10 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) } else if (key == QLatin1String("height")) { node->imageHeight = -2; // register that there is a value for it. setFloatAttribute(&node->imageHeight, value); + } else if (key == QLatin1String("alt")) { + node->imageAlt = value; + } else if (key == QLatin1String("title")) { + node->text = value; } break; case Html_tr: |