mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-11-20 02:18:20 +01:00
use backend markdown renderer
This commit is contained in:
parent
c757bd253b
commit
02c291bd65
@ -105,7 +105,12 @@ function DocController:index(...)
|
||||
end
|
||||
if path and ulib.exists(path) then
|
||||
local file = io.open(path, "r")
|
||||
local content = file:read("*a")
|
||||
local content = = ""
|
||||
local md = require("md")
|
||||
local callback = function(s)
|
||||
content = content..s
|
||||
end
|
||||
md.to_html(file:read("*a"), callback)
|
||||
file.close()
|
||||
self.template:setView("index", "index")
|
||||
self.template:set("data", content)
|
||||
|
@ -88,7 +88,9 @@
|
||||
?>
|
||||
</div>
|
||||
<div class = "md-content" id = "renderer">
|
||||
|
||||
<?lua
|
||||
echo(data)
|
||||
?>
|
||||
</div>
|
||||
<div class = "pagenav">
|
||||
<?lua
|
||||
@ -103,18 +105,4 @@
|
||||
echo("</a>")
|
||||
end
|
||||
?>
|
||||
</div>
|
||||
<script>
|
||||
window.addEventListener('load', (event) => {
|
||||
var markdown = `<?=std.b64encode(data)?>`;
|
||||
var converter = new showdown.Converter();
|
||||
var html = converter.makeHtml(atob(markdown));
|
||||
document.getElementById("renderer").innerHTML = html;
|
||||
// highlight and math display
|
||||
renderMathInElement(document.getElementById("renderer"));
|
||||
document.querySelectorAll("pre code").forEach(element => {
|
||||
hljs.highlightBlock(element);
|
||||
hljs.lineNumbersBlock(element);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
@ -13,10 +13,10 @@ local elinks = __main__:get("elinks")
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href="<?=HTTP_ROOT?>/rst/katex/katex.min.css" />
|
||||
<script
|
||||
<!--script
|
||||
type="text/javascript"
|
||||
src="<?=HTTP_ROOT?>/rst/gscripts/showdown.min.js"
|
||||
></script>
|
||||
></script-->
|
||||
<script
|
||||
src="<?=HTTP_ROOT?>/rst/hljs/highlight.pack.js"
|
||||
></script>
|
||||
|
Loading…
Reference in New Issue
Block a user