Published
Edited
Jan 31, 2022
Insert cell
Insert cell
Insert cell
html`That TOML as JSON:<br>
<pre>${escapeHtml(jsonified)}</pre>`
Insert cell
jsonified = JSON.stringify(
parsed,
// The TOML library returns big integers - convert those to regular integers
// Note this will break with integers larger than 2^53 - 1
(key, value) =>
typeof value === "bigint" ? parseInt(value.toString(), 10) : value,
4
)
Insert cell
parsed = toml.parse(text)
Insert cell
Insert cell
toml = require("@ltd/j-toml")
Insert cell
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more