Minimal formatting to render beancount results legibly on web interface

This commit is contained in:
Debanjum Singh Solanky
2022-08-13 04:46:03 +03:00
parent a0759dd923
commit 3300378804

View File

@@ -38,6 +38,12 @@
}).join("\n")); }).join("\n"));
} }
function render_ledger(query, data) {
return `<div id="results-ledger">` + data.map(function (item) {
return `<p>${item.entry}</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);
@@ -47,6 +53,8 @@
return render_org(query, data, "music-"); return render_org(query, data, "music-");
} else if (type === "image") { } else if (type === "image") {
return data.map(render_image).join(''); return data.map(render_image).join('');
} else if (type === "ledger") {
return render_ledger(query, data);
} else { } else {
return `<pre id="json">${JSON.stringify(data, null, 2)}</pre>`; return `<pre id="json">${JSON.stringify(data, null, 2)}</pre>`;
} }
@@ -223,7 +231,11 @@
#json { #json {
white-space: pre-wrap; white-space: pre-wrap;
} }
#results-markdown { #results-ledger {
white-space: pre-line;
text-align: left;
}
#results-markdown {
text-align: left; text-align: left;
} }
#results-music, #results-music,