Prettify Render of Markdown Results in Web Interface

This commit is contained in:
Debanjum Singh Solanky
2022-07-28 20:56:37 +04:00
parent a6ae74f52e
commit a9bc17a6b0
2 changed files with 8493 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,7 @@
<title>Khoj</title>
</head>
<script type="text/javascript" src="static/assets/org.js"></script>
<script type="text/javascript" src="static/assets/markdown-it.js"></script>
<script>
function render_image(item) {
@@ -25,8 +26,17 @@
return orgHTMLDocument.toString();
}
function render_markdown(query, data) {
var md = window.markdownit();
return md.render(`# Query: ${query}\n` + data.map(function (item) {
return `${item.entry}`
}).join("\n"));
}
function render_json(data, query, type) {
if (type === "org") {
if (type === "markdown") {
return render_markdown(query, data);
} else if (type === "org") {
return render_org(query, data);
} else if (type === "image") {
return data.map(render_image).join('');
@@ -160,7 +170,12 @@
white-space: pre-wrap;
}
#results-org {
#results-markdown {
text-align: left;
white-space: pre-line;
}
#results-org {
text-align: left;
white-space: pre-line;
}