mirror of
https://github.com/Hilbis/Hilbish
synced 2025-04-27 16:03:23 +00:00
feat(commands/doc): strip html elements, style markdown properly
This commit is contained in:
parent
2cac53d6e7
commit
5fb8c88b5e
@ -8,7 +8,7 @@ local docfuncs = require 'nature.doc'
|
|||||||
|
|
||||||
local function strip(text, ...)
|
local function strip(text, ...)
|
||||||
for _, pat in ipairs {...} do
|
for _, pat in ipairs {...} do
|
||||||
text = text:gsub(pat, '\b')
|
text = text:gsub(pat, '\n')
|
||||||
end
|
end
|
||||||
|
|
||||||
return text
|
return text
|
||||||
@ -19,7 +19,16 @@ local function transformHTMLandMD(text)
|
|||||||
:gsub('|(.-)|(.-)|', function(entry1, entry2)
|
:gsub('|(.-)|(.-)|', function(entry1, entry2)
|
||||||
return string.format('%s - %s', entry1, entry2)
|
return string.format('%s - %s', entry1, entry2)
|
||||||
end)
|
end)
|
||||||
|
:gsub('^\n\n', '\n')
|
||||||
:gsub('<hr>', '{separator}')
|
:gsub('<hr>', '{separator}')
|
||||||
|
:gsub('<.->', '')
|
||||||
|
:gsub('\n%s+\n', '\n\n')
|
||||||
|
:gsub('#+ (.-\n)', function(heading) return lunacolors.blue(lunacolors.bold('→ ' .. heading)) end)
|
||||||
|
:gsub('```(%w+)\n(.-)```', function(lang, text)
|
||||||
|
return docfuncs.renderCodeBlock(text)
|
||||||
|
end)
|
||||||
|
:gsub('`(.-)`', lunacolors.cyan)
|
||||||
|
:gsub('%*%*(.-)%*%*', lunacolors.bold)
|
||||||
end
|
end
|
||||||
|
|
||||||
commander.register('doc', function(args, sinks)
|
commander.register('doc', function(args, sinks)
|
||||||
@ -133,9 +142,7 @@ Available sections: ]] .. table.concat(modules, ', ')
|
|||||||
end
|
end
|
||||||
local backtickOccurence = 0
|
local backtickOccurence = 0
|
||||||
local function formatDocText(d)
|
local function formatDocText(d)
|
||||||
return transformHTMLandMD(d):gsub('```(%w+)\n(.-)```', function(lang, text)
|
return transformHTMLandMD(d)
|
||||||
return docfuncs.renderCodeBlock(text)
|
|
||||||
end)
|
|
||||||
--[[
|
--[[
|
||||||
return lunacolors.format(d:gsub('`(.-)`', function(t)
|
return lunacolors.format(d:gsub('`(.-)`', function(t)
|
||||||
return docfuncs.renderCodeBlock(t)
|
return docfuncs.renderCodeBlock(t)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user