fix imports

This commit is contained in:
Philipinho
2026-03-03 13:57:10 +00:00
parent 5d2aad3668
commit b6478fee84
2 changed files with 64 additions and 5 deletions

View File

@@ -99,6 +99,15 @@ export function defaultHtmlFormatter($: CheerioAPI, $root: Cheerio<any>) {
});
}
const COLUMN_LAYOUTS = [
'',
'',
'two_equal',
'three_equal',
'four_equal',
'five_equal',
] as const;
export function notionFormatter($: CheerioAPI, $root: Cheerio<any>) {
// remove page header icon and cover image
$root.find('.page-header-icon').remove();
@@ -109,6 +118,31 @@ export function notionFormatter($: CheerioAPI, $root: Cheerio<any>) {
if (!$(el).text().trim()) $(el).remove();
});
// columns
$root.find('div.column-list').each((_, el) => {
const $list = $(el);
const $cols = $list.find('div.column');
if ($cols.length <= 1) {
$list.replaceWith($cols.html() || '');
return;
}
const layout = COLUMN_LAYOUTS[$cols.length] ?? 'two_equal';
let cells = '';
$cols.each((_, col) => {
const $col = $(col);
$col.children('div[style*="display:contents"]').each((_, wrapper) => {
$(wrapper).replaceWith($(wrapper).html() || '');
});
cells += `<div data-type="column">${$col.html()}</div>`;
});
$list.replaceWith(
`<div data-type="columns" data-layout="${layout}">${cells}</div>`,
);
});
// block math → mathBlock
$root.find('figure.equation').each((_: any, fig: any) => {
const $fig = $(fig);