From 85144006a18b482a9b861c1b67468d4b0694ddb6 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 1 Jun 2023 17:47:45 +0530 Subject: [PATCH] Render PDF search results in khoj web interface --- src/khoj/interface/web/index.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/khoj/interface/web/index.html b/src/khoj/interface/web/index.html index 42831f5d..bb3725e9 100644 --- a/src/khoj/interface/web/index.html +++ b/src/khoj/interface/web/index.html @@ -44,6 +44,15 @@ }).join("\n") + ``; } + function render_pdf(query, data) { + return `
` + 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 `

${filename}

\n

${text_match}

` + }).join("\n") + `
`; + } + function render_json(data, query, type) { if (type === "markdown") { return render_markdown(query, data); @@ -55,6 +64,8 @@ return data.map(render_image).join(''); } else if (type === "ledger") { return render_ledger(query, data); + } else if (type === "pdf") { + return render_pdf(query, data); } else { return `
` + data.map((item) => `

${item.entry}

`).join("\n") @@ -279,6 +290,7 @@ #json { white-space: pre-wrap; } + #results-pdf, #results-plugin, #results-ledger { text-align: left;