summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2019-01-03 13:54:06 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2019-01-03 13:54:06 (GMT)
commit5d66d2ea14a173edb3d6b7ffaabd0196392fcb0f (patch)
treefd6e41e51f43ecacf4df1aaf7aeba984323dd782
parentd2944ce350bd0fb687227eb4e98b942beab9591d (diff)
downloadDoxygen-5d66d2ea14a173edb3d6b7ffaabd0196392fcb0f.zip
Doxygen-5d66d2ea14a173edb3d6b7ffaabd0196392fcb0f.tar.gz
Doxygen-5d66d2ea14a173edb3d6b7ffaabd0196392fcb0f.tar.bz2
Issue #6039: Links on image in Markdown (Origin: bugzilla #769223)
-rw-r--r--src/docparser.cpp5
-rw-r--r--src/docparser.h1
-rw-r--r--src/doctokenizer.l1
-rw-r--r--src/htmldocvisitor.cpp89
-rw-r--r--src/xmldocvisitor.cpp5
-rw-r--r--templates/xml/compound.xsd2
-rw-r--r--testing/031/indexpage.xml34
-rw-r--r--testing/031_image.dox55
8 files changed, 159 insertions, 33 deletions
diff --git a/src/docparser.cpp b/src/docparser.cpp
index 424bfdc..c91dcde 100644
--- a/src/docparser.cpp
+++ b/src/docparser.cpp
@@ -2981,6 +2981,11 @@ DocImage::DocImage(DocNode *parent,const HtmlAttribList &attribs,const QCString
m_parent = parent;
}
+bool DocImage::isSVG() const
+{
+ return m_url.isEmpty() ? m_name.right(4)==".svg" : m_url.right(4)==".svg";
+}
+
void DocImage::parse()
{
defaultHandleTitleAndSize(CMD_IMAGE,this,m_children,m_width,m_height);
diff --git a/src/docparser.h b/src/docparser.h
index ca32b20..5d2cc89 100644
--- a/src/docparser.h
+++ b/src/docparser.h
@@ -768,6 +768,7 @@ class DocImage : public CompAccept<DocImage>
QCString relPath() const { return m_relPath; }
QCString url() const { return m_url; }
bool isInlineImage() const { return m_inlineImage; }
+ bool isSVG() const;
const HtmlAttribList &attribs() const { return m_attribs; }
void parse();
diff --git a/src/doctokenizer.l b/src/doctokenizer.l
index eb14470..90f9846 100644
--- a/src/doctokenizer.l
+++ b/src/doctokenizer.l
@@ -1008,6 +1008,7 @@ REFWORD_NOCV {FILEMASK}|{LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV}
return 0;
}
<St_TitleV,St_TitleA>\n {
+ unput(*yytext);
return 0;
}
diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp
index 6386cb8..f89f79e 100644
--- a/src/htmldocvisitor.cpp
+++ b/src/htmldocvisitor.cpp
@@ -1610,17 +1610,9 @@ void HtmlDocVisitor::visitPre(DocImage *img)
if (img->type()==DocImage::Html)
{
bool inlineImage = img->isInlineImage();
- bool typeSVG = FALSE;
-
+ bool typeSVG = img->isSVG();
QCString url = img->url();
- if (url.isEmpty())
- {
- typeSVG = (img->name().right(4)==".svg");
- }
- else
- {
- typeSVG = (url.right(4)==".svg");
- }
+
if (!inlineImage)
{
forceEndParagraph(img);
@@ -1642,41 +1634,70 @@ void HtmlDocVisitor::visitPre(DocImage *img)
{
sizeAttribs+=" height=\""+img->height()+"\"";
}
+ // 16 cases: url.isEmpty() | typeSVG | inlineImage | img->hasCaption()
if (url.isEmpty())
{
if (typeSVG)
{
- m_t << "<object type=\"image/svg+xml\" data=\"" << img->relPath() << img->name()
- << "\"" << sizeAttribs << htmlAttribsToString(img->attribs()) << ">" << baseName
- << "</object>" << endl;
+ m_t << "<object type=\"image/svg+xml\" style=\"pointer-events: none;\" data=\"" << img->relPath() << img->name()
+ << "\"" << sizeAttribs << htmlAttribsToString(img->attribs());
+ if (inlineImage)
+ {
+ // skip closing tag
+ }
+ else
+ {
+ m_t << "></object>" << endl;
+ }
}
else
{
m_t << "<img src=\"" << img->relPath() << img->name() << "\" alt=\""
- << baseName << "\"" << sizeAttribs << htmlAttribsToString(img->attribs())
- << (inlineImage ? " class=\"inline\"" : "/>\n");
+ << baseName << "\"" << sizeAttribs << htmlAttribsToString(img->attribs());
+ if (inlineImage)
+ {
+ m_t << " class=\"inline\"";
+ }
+ else
+ {
+ m_t << "/>\n";
+ }
}
}
else // link to URL
{
if (typeSVG)
{
- m_t << "<object type=\"image/svg+xml\" data=\"" << correctURL(url,img->relPath())
- << "\"" << sizeAttribs << htmlAttribsToString(img->attribs())
- << "></object>" << endl;
+ m_t << "<object type=\"image/svg+xml\" style=\"pointer-events: none;\" data=\"" << correctURL(url,img->relPath())
+ << "\"" << sizeAttribs << htmlAttribsToString(img->attribs());
+ if (inlineImage)
+ {
+ // skip closing >
+ }
+ else
+ {
+ m_t << "></object>" << endl;
+ }
}
else
{
m_t << "<img src=\"" << correctURL(url,img->relPath()) << "\""
- << sizeAttribs << htmlAttribsToString(img->attribs(), TRUE)
- << (inlineImage ? " class=\"inline\"" : "/>\n");
+ << sizeAttribs << htmlAttribsToString(img->attribs(), TRUE);
+ if (inlineImage)
+ {
+ m_t << " class=\"inline\""; // skip closing >
+ }
+ else
+ {
+ m_t << "/>\n";
+ }
}
}
if (img->hasCaption())
{
if (inlineImage)
{
- m_t << " title=\"";
+ m_t << " title=\"";
}
else
{
@@ -1686,7 +1707,14 @@ void HtmlDocVisitor::visitPre(DocImage *img)
}
else if (inlineImage)
{
- m_t << "/>" << endl;
+ if (typeSVG)
+ {
+ m_t << "></object>";
+ }
+ else
+ {
+ m_t << "/>";
+ }
}
}
else // other format -> skip
@@ -1705,11 +1733,22 @@ void HtmlDocVisitor::visitPost(DocImage *img)
if (img->hasCaption())
{
if (inlineImage)
- m_t << "\"/>\n ";
- else
+ {
+ if (img->isSVG())
+ {
+ m_t << "\"></object>";
+ }
+ else
+ {
+ m_t << "\"/>";
+ }
+ }
+ else // end <div class="caption">
+ {
m_t << "</div>";
+ }
}
- if (!inlineImage)
+ if (!inlineImage) // end <div class="image">
{
m_t << "</div>" << endl;
forceStartParagraph(img);
diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp
index a65695c..e464088 100644
--- a/src/xmldocvisitor.cpp
+++ b/src/xmldocvisitor.cpp
@@ -70,7 +70,10 @@ static void visitPreStart(FTextStream &t, const char *cmd, bool doCaption,
{
t << " height=\"" << convertToXML(height) << "\"";
}
- if (inlineImage) t << " inline=\"yes\">";
+ if (inlineImage)
+ {
+ t << " inline=\"yes\"";
+ }
if (doCaption)
{
t << " caption=\"";
diff --git a/templates/xml/compound.xsd b/templates/xml/compound.xsd
index cf48e03..2d72d41 100644
--- a/templates/xml/compound.xsd
+++ b/templates/xml/compound.xsd
@@ -397,6 +397,7 @@
<xsd:element name="xmlonly" type="xsd:string" />
<xsd:element name="rtfonly" type="xsd:string" />
<xsd:element name="latexonly" type="xsd:string" />
+ <xsd:element name="image" type="docImageType" />
<xsd:element name="dot" type="xsd:string" />
<xsd:element name="plantuml" type="xsd:string" />
<xsd:element name="anchor" type="docAnchorType" />
@@ -554,6 +555,7 @@
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="width" type="xsd:string" />
<xsd:attribute name="height" type="xsd:string" />
+ <xsd:attribute name="inline" type="DoxBool" />
</xsd:complexType>
<xsd:complexType name="docFileType" mixed="true">
diff --git a/testing/031/indexpage.xml b/testing/031/indexpage.xml
index 2c1dfd7..b6a7ed0 100644
--- a/testing/031/indexpage.xml
+++ b/testing/031/indexpage.xml
@@ -9,7 +9,39 @@
<para>Some text. <image type="html" name="sample.png"/>
<image type="latex" name="sample.png" width="5cm">Doxygen logo</image>
<image type="docbook" name="sample.png"/>
- More text. </para>
+ More text.</para>
+ <para>SVG image with caption:<linebreak/>
+<image type="html" name="license-MIT-brightgreen.svg">A caption</image>
+</para>
+ <para>PNG image with caption:<linebreak/>
+<image type="html" name="license-MIT-brightgreen.png">A caption</image>
+</para>
+ <para>SVG image without caption:<linebreak/>
+<image type="html" name="license-MIT-brightgreen.svg"/>
+</para>
+ <para>PNG image without caption:<linebreak/>
+<image type="html" name="license-MIT-brightgreen.png"/>
+</para>
+ <para>Inline SVG image with caption:<linebreak/>
+This image is inline <image type="html" name="license-MIT-brightgreen.svg" inline="yes">MIT license</image>
+ within the text.</para>
+ <para>Inline PNG image with caption:<linebreak/>
+This image is inline <image type="html" name="license-MIT-brightgreen.png" inline="yes">MIT license</image>
+ within the text.</para>
+ <para>Markdown style linked SVG image:<linebreak/>
+<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="license-MIT-brightgreen.svg" inline="yes"/></ulink></para>
+ <para>Markdown style linked PNG image:<linebreak/>
+<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="license-MIT-brightgreen.png" inline="yes"/></ulink></para>
+ <para>HTML style linked SVG image:<linebreak/>
+<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="license-MIT-brightgreen.svg" inline="yes"/></ulink></para>
+ <para>HTML style linked PNG image:<linebreak/>
+<ulink url="http://opensource.org/licenses/MIT"><image type="html" name="license-MIT-brightgreen.png" inline="yes"/></ulink></para>
+ <para>HTML style unlinked SVG image:<linebreak/>
+<image type="html" name="license-MIT-brightgreen.svg" inline="yes"/>
+</para>
+ <para>HTML style unlined PNG image:<linebreak/>
+<image type="html" name="license-MIT-brightgreen.png" inline="yes"/>
+ </para>
</detaileddescription>
</compounddef>
</doxygen>
diff --git a/testing/031_image.dox b/testing/031_image.dox
index 8ba47b7..61f5bba 100644
--- a/testing/031_image.dox
+++ b/testing/031_image.dox
@@ -2,9 +2,52 @@
// check: indexpage.xml
// config: IMAGE_PATH = $INPUTDIR
/** \mainpage
- * Some text.
- * \image html sample.png
- * \image latex sample.png "Doxygen logo" width=5cm
- * \image docbook sample.png
- * More text.
- */
+Some text.
+\image html sample.png
+\image latex sample.png "Doxygen logo" width=5cm
+\image docbook sample.png
+More text.
+
+SVG image with caption:\n
+\image html http://img.shields.io/badge/license-MIT-brightgreen.svg "A caption"
+
+PNG image with caption:\n
+\image html http://img.shields.io/badge/license-MIT-brightgreen.png "A caption"
+
+SVG image without caption:\n
+\image html http://img.shields.io/badge/license-MIT-brightgreen.svg
+
+PNG image without caption:\n
+\image html http://img.shields.io/badge/license-MIT-brightgreen.png
+
+Inline SVG image with caption:\n
+This image is inline \image{inline} html http://img.shields.io/badge/license-MIT-brightgreen.svg "MIT license" within the text.
+
+Inline PNG image with caption:\n
+This image is inline
+\image{inline} html http://img.shields.io/badge/license-MIT-brightgreen.png "MIT license"
+within the text.
+
+Markdown style linked SVG image:\n
+[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
+
+Markdown style linked PNG image:\n
+[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.png)](http://opensource.org/licenses/MIT)
+
+HTML style linked SVG image:\n
+<a href="http://opensource.org/licenses/MIT">
+<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT license">
+</a>
+
+HTML style linked PNG image:\n
+<a href="http://opensource.org/licenses/MIT">
+<img src="http://img.shields.io/badge/license-MIT-brightgreen.png" alt="MIT license">
+</a>
+
+HTML style unlinked SVG image:\n
+<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT license"/>
+
+HTML style unlined PNG image:\n
+<img src="http://img.shields.io/badge/license-MIT-brightgreen.png" alt="MIT license"/>
+
+*/