mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Prettify Render of Markdown Results in Web Interface
This commit is contained in:
8476
src/interface/web/assets/markdown-it.js
Normal file
8476
src/interface/web/assets/markdown-it.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user