From fc20672bb9e23b5136f10b3260a655336db28fdf Mon Sep 17 00:00:00 2001 From: William Lupton Date: Thu, 12 Aug 2021 18:16:34 +0100 Subject: 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). --- data/sample.lua | 20 ++++++++++++-------- 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 "" .. s .. "" + escape(tit,true) .. "'" .. attributes(attr) .. ">" .. s .. "" end function Image(s, src, tit, attr) @@ -284,9 +284,15 @@ local function html_align(align) end function CaptionedImage(src, tit, caption, attr) - return '
\n\n' .. - '

' .. escape(caption) .. '

\n
' + if #caption == 0 then + return '

' + else + local ecaption = escape(caption) + return '
\n' .. ecaption  .. '' .. + '
' .. ecaption .. '
\n
' + 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("") if caption ~= "" then - add("") + add("") 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,'') empty_header = empty_header and h == "" end - if empty_header then - head = "" - else + if not empty_header then add('') 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.’

-

With an ampersand: http://example.com/?foo=1&bar=2

+

With an ampersand: http://example.com/?foo=1&bar=2

-

An e-mail address: nobody@nowhere.net

+

An e-mail address:

-

Blockquoted: http://example.com/

+

Blockquoted: http://example.com/

Auto-links should not occur here: <http://example.com/>

@@ -736,10 +736,9 @@ So is ‘pine.’

From “Voyage dans la Lune” by Georges Melies (1902):

-
- -

lalune

-
+
+lalune
lalune
+

Here is a movie icon.

-- cgit v1.2.3
" .. caption .. "" .. escape(caption) .. "
' .. h .. '