mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 19:03:01 +01:00
Render PDF search results in khoj web interface
This commit is contained in:
parent
acd14a5e41
commit
85144006a1
1 changed files with 12 additions and 0 deletions
|
@ -44,6 +44,15 @@
|
||||||
}).join("\n") + `</div>`;
|
}).join("\n") + `</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function render_pdf(query, data) {
|
||||||
|
return `<div id="results-pdf">` + data.map(function (item) {
|
||||||
|
let compiled_lines = item.additional.compiled.split("\n");
|
||||||
|
let filename = compiled_lines.shift();
|
||||||
|
let text_match = compiled_lines.join("\n")
|
||||||
|
return `<h2>${filename}</h2>\n<p>${text_match}</p>`
|
||||||
|
}).join("\n") + `</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
function render_json(data, query, type) {
|
function render_json(data, query, type) {
|
||||||
if (type === "markdown") {
|
if (type === "markdown") {
|
||||||
return render_markdown(query, data);
|
return render_markdown(query, data);
|
||||||
|
@ -55,6 +64,8 @@
|
||||||
return data.map(render_image).join('');
|
return data.map(render_image).join('');
|
||||||
} else if (type === "ledger") {
|
} else if (type === "ledger") {
|
||||||
return render_ledger(query, data);
|
return render_ledger(query, data);
|
||||||
|
} else if (type === "pdf") {
|
||||||
|
return render_pdf(query, data);
|
||||||
} else {
|
} else {
|
||||||
return `<div id="results-plugin">`
|
return `<div id="results-plugin">`
|
||||||
+ data.map((item) => `<p>${item.entry}</p>`).join("\n")
|
+ data.map((item) => `<p>${item.entry}</p>`).join("\n")
|
||||||
|
@ -279,6 +290,7 @@
|
||||||
#json {
|
#json {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
#results-pdf,
|
||||||
#results-plugin,
|
#results-plugin,
|
||||||
#results-ledger {
|
#results-ledger {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
Loading…
Reference in a new issue