Table wrapper for markdown tables (#114)

* table wrapper for markdown tables

* minimal formatting

* minimal formatting

* Only show scroll when neccessary

---------

Co-authored-by: Ole Eskild Steensen <oleeskild@users.noreply.github.com>
This commit is contained in:
Utsob Roy 2023-04-18 11:50:49 +06:00 committed by GitHub
parent b44de6e0f8
commit 23d2d7c7ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 8 deletions

View File

@ -254,7 +254,7 @@ module.exports = function (eleventyConfig) {
let calloutType = "";
let isCollapsable;
let isCollapsed;
const calloutMeta = /\[!([\w-]*)\](\+|\-){0,1}(\s?.*)/;;
const calloutMeta = /\[!([\w-]*)\](\+|\-){0,1}(\s?.*)/;
if (!content.match(calloutMeta)) {
continue;
}
@ -293,6 +293,17 @@ module.exports = function (eleventyConfig) {
return str && parsed.innerHTML;
});
eleventyConfig.addTransform("table", function (str) {
const parsed = parse(str);
for (const t of parsed.querySelectorAll(".cm-s-obsidian > table")) {
let inner = t.innerHTML;
t.tagName = "div";
t.classList.add("table-wrapper");
t.innerHTML = `<table>${inner}</table>`;
}
return str && parsed.innerHTML;
});
eleventyConfig.addTransform("htmlMinifier", (content, outputPath) => {
if (
process.env.NODE_ENV === "production" &&
@ -322,12 +333,12 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(pluginRss, {
posthtmlRenderOptions: {
closingSingleTag: "slash",
singleTags: ["link"]
}
singleTags: ["link"],
},
});
eleventyConfig.addFilter("dateToZulu", function(date){
if(!date) return "";
eleventyConfig.addFilter("dateToZulu", function (date) {
if (!date) return "";
return new Date(date).toISOString("dd-MM-yyyyTHH:mm:ssZ");
});
eleventyConfig.addFilter("jsonify", function (variable) {

View File

@ -517,7 +517,7 @@ ul.task-list {
display: flex;
align-items: center;
min-width: 150px;
margin: 10px 40px;
margin: 10px 40px;
border: 1px solid var(--text-normal);
cursor: pointer;
@ -740,9 +740,14 @@ body.backlinks-note-icon .backlink[data-note-icon="3"]::before {
}
}
.align-icon {
display: inline-flex;
align-items: center;
justify-content: space-evenly;
}
}
.cm-s-obsidian {
.table-wrapper {
overflow-x: auto;
}
}