From: Daniel Kolesa Date: Tue, 12 Apr 2016 14:23:47 +0000 (+0100) Subject: docgen: add support for monospace markup highlights X-Git-Tag: upstream/1.20.0~6364^2~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7eac3275e41339fadd118a0968bd890436a40db4;p=platform%2Fupstream%2Fefl.git docgen: add support for monospace markup highlights --- diff --git a/gendoc.lua b/gendoc.lua index c7fa5fd..d9a31db 100644 --- a/gendoc.lua +++ b/gendoc.lua @@ -212,6 +212,39 @@ local notetypes = { ["TODO: "] = "\n**TODO:** " } +local gen_doc_markup = function(str) + local f = str:gmatch(".") + local c = f() + local buf = {} + while c do + if c == "\\" then + c = f() + if c ~= "@" and c ~= "$" then + buf[#buf + 1] = "\\" + end + buf[#buf + 1] = c + c = f() + elseif c == "$" then + c = f() + if c and c:match("[a-zA-Z_]") then + local wbuf = { c } + c = f() + while c and c:match("[a-zA-Z0-9_]") do + wbuf[#wbuf + 1] = c + c = f() + end + buf[#buf + 1] = "''" .. table.concat(wbuf) .. "''" + else + buf[#buf + 1] = "$" + end + else + buf[#buf + 1] = c + c = f() + end + end + return table.concat(buf) +end + local gen_doc_par = function(str) local tag for k, v in pairs(notetypes) do @@ -222,9 +255,9 @@ local gen_doc_par = function(str) end end if tag then - return tag .. str .. "\n" + return tag .. gen_doc_markup(str) .. "\n" end - return str + return gen_doc_markup(str) end local gen_doc_refd = function(str)