Skip to content

Commit

Permalink
handle null case, as well
Browse files Browse the repository at this point in the history
  • Loading branch information
brool committed Apr 23, 2014
1 parent b141a3d commit b840e69
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions locco.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function generate_html(source, path, filename, sections, jump_to)
f:write(h)
for i=1, #sections do
local t = template.table_entry:gsub('%%index%%', i..'')
t = t:gsub('%%docs_html%%', sections[i]['docs_html']:gsub('%%', '%%%%'))
t = t:gsub('%%code_html%%', sections[i]['code_html']:gsub('%%', '%%%%'))
t = t:gsub('%%docs_html%%', replace_percent(sections[i]['docs_html']))
t = t:gsub('%%code_html%%', replace_percent(sections[i]['code_html']))
f:write(t)
end
f:write(template.footer)
Expand Down Expand Up @@ -162,6 +162,11 @@ function escape(s)
return s
end

function replace_percent(s)
s = s:gsub('%%', '%%%%')
return s
end

-- Define the Lua keywords, built-in functions and operators that should
-- be highlighted.
local keywords = { 'break', 'do', 'else', 'elseif', 'end', 'false', 'for',
Expand Down

0 comments on commit b840e69

Please sign in to comment.