mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 21:29:13 +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>
|
<title>Khoj</title>
|
||||||
</head>
|
</head>
|
||||||
<script type="text/javascript" src="static/assets/org.js"></script>
|
<script type="text/javascript" src="static/assets/org.js"></script>
|
||||||
|
<script type="text/javascript" src="static/assets/markdown-it.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function render_image(item) {
|
function render_image(item) {
|
||||||
@@ -25,8 +26,17 @@
|
|||||||
return orgHTMLDocument.toString();
|
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) {
|
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);
|
return render_org(query, data);
|
||||||
} else if (type === "image") {
|
} else if (type === "image") {
|
||||||
return data.map(render_image).join('');
|
return data.map(render_image).join('');
|
||||||
@@ -160,6 +170,11 @@
|
|||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#results-markdown {
|
||||||
|
text-align: left;
|
||||||
|
white-space: pre-line;
|
||||||
|
}
|
||||||
|
|
||||||
#results-org {
|
#results-org {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
white-space: pre-line;
|
white-space: pre-line;
|
||||||
|
|||||||
Reference in New Issue
Block a user