@@ -29,7 +29,7 @@ local function escape(s, in_attribute)
2929 return s
3030end
3131
32- function indent (s , fl , ol )
32+ local function indent (s , fl , ol )
3333 local ret = {}
3434 local i = 1
3535 for l in s :gmatch (" [^\r\n ]+" ) do
@@ -58,7 +58,7 @@ local function blocks(bs, sep)
5858 local dbuff = {}
5959 for i = 1 , # bs do
6060 local el = bs [i ]
61- dbuff [# dbuff + 1 ] = Writer . Block [el .tag ](el )
61+ dbuff [# dbuff + 1 ] = Writer [ pandoc . utils . type ( el )] [el .tag ](el )
6262 end
6363 return table.concat (dbuff , sep )
6464end
@@ -77,7 +77,6 @@ local CURRENT_HEADER = nil
7777local HEADER_COUNT = 1
7878local toc = {}
7979local links = {}
80- local notes = {}
8180
8281local function osExecute (cmd )
8382 local fileHandle = assert (io.popen (cmd , " r" ))
@@ -171,10 +170,10 @@ local function renderNotes()
171170 add (string.rep (" =" , 78 ) .. " \n " .. string.format (" %s%s%s" , left , padding , right ))
172171 add (" " )
173172 for i , v in ipairs (links ) do
174- add (i .. " . *" .. v [ 1 ] .. " *" .. " : " .. v [ 2 ] )
173+ add (i .. " . *" .. v . caption .. " *" .. " : " .. v . src )
175174 end
176175 end
177- return table.concat (t , " \n " )
176+ return table.concat (t , " \n " ) .. " \n "
178177end
179178
180179function renderFooter ()
@@ -385,7 +384,7 @@ Writer.Inline.Link = function(el)
385384end
386385
387386Writer .Inline .Image = function (el )
388- return " <img src=' " .. escape ( src , true ) .. " ' title=' " .. escape ( tit , true ) .. " '/> "
387+ links [ # links + 1 ] = { caption = inlines ( el . caption ), src = el . src }
389388end
390389
391390Writer .Inline .Code = function (el )
@@ -446,8 +445,8 @@ Writer.Inline.Cite = function(el)
446445 end
447446end
448447
449- Writer .Block .Plain = function (s )
450- return inlines (s .content )
448+ Writer .Block .Plain = function (el )
449+ return inlines (el .content )
451450end
452451
453452Writer .Block .RawBlock = function (el )
@@ -482,3 +481,27 @@ Writer.Block.Div = function(el)
482481 -- TODO: Add more special features here
483482 return blocks (el .content )
484483end
484+
485+ Writer .Block .Figure = function (el )
486+ return blocks (el .content )
487+ end
488+
489+ Writer .Block .BlockQuote = function (el )
490+ local lines = {}
491+ for line in blocks (el .content ):gmatch (" [^\r\n ]+" ) do
492+ table.insert (lines , line )
493+ end
494+ return " \n " .. table.concat (lines , " \n " ) .. " \n "
495+ end
496+
497+ Writer .Block .HorizontalRule = function ()
498+ return string.rep (" -" , 78 )
499+ end
500+
501+ Writer .Block .LineBlock = function (el )
502+ local buffer = {}
503+ el .content :map (function (item )
504+ table.insert (buffer , table.concat ({ " | " , inlines (item ) }))
505+ end )
506+ return " \n " .. table.concat (buffer , " \n " ) .. " \n "
507+ end
0 commit comments