1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00
This commit is contained in:
lxsang 2020-09-13 15:41:42 +02:00
commit cc7ae835ad
3 changed files with 13 additions and 19 deletions

View File

@ -123,7 +123,12 @@ function DocController:index(...)
end end
if path and ulib.exists(path) then if path and ulib.exists(path) then
local file = io.open(path, "r") 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() file.close()
-- replace some display plugins -- replace some display plugins
content = pre_process_md(content, self) content = pre_process_md(content, self)

View File

@ -88,7 +88,9 @@
?> ?>
</div> </div>
<div class = "md-content" id = "renderer"> <div class = "md-content" id = "renderer">
<?lua
echo(data)
?>
</div> </div>
<div class = "pagenav"> <div class = "pagenav">
<?lua <?lua
@ -104,17 +106,3 @@
end end
?> ?>
</div> </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>

View File

@ -13,16 +13,17 @@ local elinks = __main__:get("elinks")
rel="stylesheet" rel="stylesheet"
type="text/css" type="text/css"
href="<?=HTTP_ROOT?>/rst/katex/katex.min.css" /> href="<?=HTTP_ROOT?>/rst/katex/katex.min.css" />
<script <!--script
type="text/javascript" type="text/javascript"
src="<?=HTTP_ROOT?>/rst/gscripts/showdown.min.js" src="<?=HTTP_ROOT?>/rst/gscripts/showdown.min.js"
></script> ></script-->
<script <script
src="<?=HTTP_ROOT?>/rst/hljs/highlight.pack.js" src="<?=HTTP_ROOT?>/rst/hljs/highlight.pack.js"
></script> ></script>
<script <script
src="<?=HTTP_ROOT?>/rst/hljs/highlightjs-line-numbers.min.js" src="<?=HTTP_ROOT?>/rst/hljs/highlightjs-line-numbers.min.js"
></script> ></script>
<script>hljs.initHighlightingOnLoad();</script>
<script <script
src="<?=HTTP_ROOT?>/rst/katex/katex.min.js" src="<?=HTTP_ROOT?>/rst/katex/katex.min.js"
></script> ></script>