elif 'height' in i.attrib:
sizespec = ' style="height: {};"'.format(i.attrib['height'])
+ # The alt text can apparently be specified only with the HTML
+ # <img> tag, not with @image. It's also present only since
+ # 1.9.1(?).
+ alt = i.attrib.get('alt', 'Image')
+
caption = i.text
if caption:
- out.parsed += '<figure class="m-figure{}"><img src="{}" alt="Image"{} /><figcaption>{}</figcaption></figure>'.format(
+ out.parsed += '<figure class="m-figure{}"><img src="{}" alt="{}"{} /><figcaption>{}</figcaption></figure>'.format(
' ' + add_css_class if add_css_class else '',
- name, sizespec, html.escape(caption))
+ name, alt, sizespec, html.escape(caption))
else:
- out.parsed += '<img class="m-image{}" src="{}" alt="Image"{} />'.format(
- ' ' + add_css_class if add_css_class else '', name, sizespec)
+ out.parsed += '<img class="m-image{}" src="{}" alt="{}"{} />'.format(
+ ' ' + add_css_class if add_css_class else '', name, alt, sizespec)
elif i.tag in ['dot', 'dotfile']:
assert element.tag in ['para', '{http://mcss.mosra.cz/doxygen/}div']
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <title>My Project</title>
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+ <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+ <div class="m-container">
+ <div class="m-row">
+ <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Project</a>
+ </div>
+ </div>
+</nav></header>
+<main><article>
+ <div class="m-container m-container-inflatable">
+ <div class="m-row">
+ <div class="m-col-l-10 m-push-l-1">
+ <h1>
+ My Project
+ </h1>
+<p>Image:</p><img class="m-image" src="tiny.png" alt="Image" /><p>Figure:</p><figure class="m-figure"><img src="tiny.png" alt="Image" /><figcaption>Caption</figcaption></figure><p>Explicit width:</p><img class="m-image" src="tiny.png" alt="Image" style="width: 128px;" /><p>Explicit height and a caption:</p><figure class="m-figure"><img src="tiny.png" alt="Image" style="height: 64px;" /><figcaption>This is 64 pixels high.</figcaption></figure><p>Alt text. Can be only specified with the HTML tag, not with <code>@image</code>.</p><img class="m-image" src="tiny.png" alt="Image" />
+ </div>
+ </div>
+ </div>
+</article></main>
+</body>
+</html>
<h1>
My Project
</h1>
-<p>Image:</p><img class="m-image" src="tiny.png" alt="Image" /><p>Figure:</p><figure class="m-figure"><img src="tiny.png" alt="Image" /><figcaption>Caption</figcaption></figure><p>Explicit width:</p><img class="m-image" src="tiny.png" alt="Image" style="width: 128px;" /><p>Explicit height and a caption:</p><figure class="m-figure"><img src="tiny.png" alt="Image" style="height: 64px;" /><figcaption>This is 64 pixels high.</figcaption></figure>
+<p>Image:</p><img class="m-image" src="tiny.png" alt="Image" /><p>Figure:</p><figure class="m-figure"><img src="tiny.png" alt="Image" /><figcaption>Caption</figcaption></figure><p>Explicit width:</p><img class="m-image" src="tiny.png" alt="Image" style="width: 128px;" /><p>Explicit height and a caption:</p><figure class="m-figure"><img src="tiny.png" alt="Image" style="height: 64px;" /><figcaption>This is 64 pixels high.</figcaption></figure><p>Alt text. Can be only specified with the HTML tag, not with <code>@image</code>.</p><img class="m-image" src="tiny.png" alt="This is an alt text." />
</div>
</div>
</div>
@image html tiny.png "This is 64 pixels high." height=64px
+Alt text. Can be only specified with the HTML tag, not with `@image`.
+
+<img src="tiny.png" alt="This is an alt text." />
+
*/
/** @page warnings Images that produce warnings
class Image(IntegrationTestCase):
def test(self):
self.run_doxygen(wildcard='indexpage.xml')
- self.assertEqual(*self.actual_expected_contents('index.html'))
+
+ # Versions before 1.9.1(?) don't have the alt attribute preserved for
+ # <img>
+ if parse_version(doxygen_version()) >= parse_version("1.9.1"):
+ self.assertEqual(*self.actual_expected_contents('index.html'))
+ else:
+ self.assertEqual(*self.actual_expected_contents('index.html', 'index-1820.html'))
+
self.assertTrue(os.path.exists(os.path.join(self.path, 'html', 'tiny.png')))
def test_warnings(self):