Skip to content

Commit a430903

Browse files
committed
fixup columns html to use flex (work around pandoc 2.19 regression)
1 parent 6d11954 commit a430903

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/format/html/format-html-shared.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import {
2727

2828
import { formatResourcePath } from "../../core/resources.ts";
2929
import { Document, Element } from "../../core/deno-dom.ts";
30+
import { HtmlPostProcessResult } from "../../command/render/types.ts";
31+
import { kHtmlEmptyPostProcessResult } from "../../command/render/constants.ts";
3032

3133
// features that are enabled by default for 'html'. setting
3234
// all of these to false will yield the minimal html output
@@ -320,6 +322,25 @@ export function insertTitle(
320322
prependHeading(doc, el, title, level, headingClasses);
321323
}
322324

325+
export function columnsPostprocessor(
326+
doc: Document,
327+
): Promise<HtmlPostProcessResult> {
328+
const columns = doc.querySelectorAll("div.columns div.column");
329+
for (const column of columns) {
330+
const columnEl = column as Element;
331+
const style = columnEl.getAttribute("style");
332+
if (style) {
333+
columnEl.setAttribute(
334+
"style",
335+
style.replace(/width:(\d+)%/, (_m: string, pct: string) => {
336+
return `flex:0.${pct}`;
337+
}),
338+
);
339+
}
340+
}
341+
return Promise.resolve(kHtmlEmptyPostProcessResult);
342+
}
343+
323344
function prependHeading(
324345
doc: Document,
325346
el: Element,

src/format/html/format-html.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { boostrapExtras } from "./format-html-bootstrap.ts";
5656

5757
import {
5858
clipboardDependency,
59+
columnsPostprocessor,
5960
createCodeCopyButton,
6061
kAnchorSections,
6162
kBootstrapDependencyName,
@@ -525,6 +526,7 @@ export async function htmlFormatExtras(
525526
[kHtmlPostprocessors]: [
526527
htmlFormatPostprocessor(format, featureDefaults),
527528
metadataPostProcessor(input, format, offset),
529+
columnsPostprocessor,
528530
],
529531
},
530532
};

0 commit comments

Comments
 (0)