diff options
author | William Lupton <wlupton@users.noreply.github.com> | 2021-08-12 18:16:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 10:16:34 -0700 |
commit | fc20672bb9e23b5136f10b3260a655336db28fdf (patch) | |
tree | 847fabcc4cde457bd9a7ef4b0835bb6d347f1cc5 | |
parent | ebef4fb41dd9a18dc45e096f3d760b74d7669d03 (diff) | |
download | pandoc-fc20672bb9e23b5136f10b3260a655336db28fdf.tar.gz |
Various sample.lua editorial fixes. (#7493)
These address most of the items mentioned in #7487.
There's also a table caption fix (the caption wasn't escaped).
-rw-r--r-- | data/sample.lua | 20 | ||||
-rw-r--r-- | test/writer.custom | 15 |
2 files changed, 19 insertions, 16 deletions
diff --git a/data/sample.lua b/data/sample.lua index b87848378..ea20add2e 100644 --- a/data/sample.lua +++ b/data/sample.lua @@ -143,7 +143,7 @@ end function Link(s, tgt, tit, attr) return "<a href='" .. escape(tgt,true) .. "' title='" .. - escape(tit,true) .. "'>" .. s .. "</a>" + escape(tit,true) .. "'" .. attributes(attr) .. ">" .. s .. "</a>" end function Image(s, src, tit, attr) @@ -284,9 +284,15 @@ local function html_align(align) end function CaptionedImage(src, tit, caption, attr) - return '<div class="figure">\n<img src="' .. escape(src,true) .. - '" title="' .. escape(tit,true) .. '"/>\n' .. - '<p class="caption">' .. escape(caption) .. '</p>\n</div>' + if #caption == 0 then + return '<p><img src="' .. escape(src,true) .. '" id="' .. attr.id .. + '"/></p>' + else + local ecaption = escape(caption) + return '<figure>\n<img src="' .. escape(src,true) .. + '" id="' .. attr.id .. '" alt="' .. ecaption .. '"/>' .. + '<figcaption>' .. ecaption .. '</figcaption>\n</figure>' + end end -- Caption is a string, aligns is an array of strings, @@ -299,7 +305,7 @@ function Table(caption, aligns, widths, headers, rows) end add("<table>") if caption ~= "" then - add("<caption>" .. caption .. "</caption>") + add("<caption>" .. escape(caption) .. "</caption>") end if widths and widths[1] ~= 0 then for _, w in pairs(widths) do @@ -313,9 +319,7 @@ function Table(caption, aligns, widths, headers, rows) table.insert(header_row,'<th align="' .. align .. '">' .. h .. '</th>') empty_header = empty_header and h == "" end - if empty_header then - head = "" - else + if not empty_header then add('<tr class="header">') for _,h in pairs(header_row) do add(h) diff --git a/test/writer.custom b/test/writer.custom index 2cb398eb1..ce490f426 100644 --- a/test/writer.custom +++ b/test/writer.custom @@ -712,18 +712,18 @@ So is ‘pine.’</p> <h2 id="autolinks">Autolinks</h2> -<p>With an ampersand: <a href='http://example.com/?foo=1&bar=2' title=''>http://example.com/?foo=1&bar=2</a></p> +<p>With an ampersand: <a href='http://example.com/?foo=1&bar=2' title='' class="uri">http://example.com/?foo=1&bar=2</a></p> <ul> <li>In a list?</li> -<li><a href='http://example.com/' title=''>http://example.com/</a></li> +<li><a href='http://example.com/' title='' class="uri">http://example.com/</a></li> <li>It should.</li> </ul> -<p>An e-mail address: <a href='mailto:nobody@nowhere.net' title=''>nobody@nowhere.net</a></p> +<p>An e-mail address: <a href='mailto:nobody@nowhere.net' title='' class="email">nobody@nowhere.net</a></p> <blockquote> -<p>Blockquoted: <a href='http://example.com/' title=''>http://example.com/</a></p> +<p>Blockquoted: <a href='http://example.com/' title='' class="uri">http://example.com/</a></p> </blockquote> <p>Auto-links should not occur here: <code><http://example.com/></code></p> @@ -736,10 +736,9 @@ So is ‘pine.’</p> <p>From “Voyage dans la Lune” by Georges Melies (1902):</p> -<div class="figure"> -<img src="lalune.jpg" title="fig:Voyage dans la Lune"/> -<p class="caption">lalune</p> -</div> +<figure> +<img src="lalune.jpg" id="" alt="lalune"/><figcaption>lalune</figcaption> +</figure> <p>Here is a movie <img src='movie.jpg' title=''/> icon.</p> |