From a6dab9a623efc416d51caad7a6d2306e2383e2a3 Mon Sep 17 00:00:00 2001 From: Charles Teague Date: Wed, 4 May 2022 09:04:47 -0400 Subject: [PATCH 1/3] =?UTF-8?q?Only=20force=20number=20sections=20on=20if?= =?UTF-8?q?=20it=20isn=E2=80=99t=20explicitly=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/command/render/crossref.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/command/render/crossref.ts b/src/command/render/crossref.ts index 38836a5607..35bc319c13 100644 --- a/src/command/render/crossref.ts +++ b/src/command/render/crossref.ts @@ -57,9 +57,10 @@ export function crossrefFilterParams( ); } // implies number-sections - params[kNumberSections] = true; + if (defaults?.[kNumberSections] === undefined) { + params[kNumberSections] = true; + } } - params[option] = value; } }); From 764fa7c53e7679b6c7c20e628a48ab973773ead2 Mon Sep 17 00:00:00 2001 From: Charles Teague Date: Wed, 4 May 2022 09:18:24 -0400 Subject: [PATCH 2/3] =?UTF-8?q?if=20the=20left=20sidebar=20is=20empty=20an?= =?UTF-8?q?d=20we=E2=80=99re=20in=20full=20layout,=20just=20remove=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to reproduce, make a page like ``` --- title: The Tech Blog of Charles Teague listing: contents: "blog/**/*.qmd" feed: true categories: true sort: - "date desc" max-description-length: 250 filter-ui: false sort-ui: false type: grid page-layout: full title-block-banner: true margin-header: signup.html toc-location: left --- ``` --- src/format/html/format-html-bootstrap.ts | 45 ++++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/format/html/format-html-bootstrap.ts b/src/format/html/format-html-bootstrap.ts index b57426afb8..0c0821bb73 100644 --- a/src/format/html/format-html-bootstrap.ts +++ b/src/format/html/format-html-bootstrap.ts @@ -391,6 +391,13 @@ function bootstrapHtmlFinalizer(format: Format, flags: PandocFlags) { const fullLayout = formatHasFullLayout(format); if (fullLayout) { + // If we're in a full layout, get rid of empty sidebar elements + const leftSidebar = hasContents(kSidebarId, doc); + if (!leftSidebar) { + const sidebarEl = doc.getElementById(kSidebarId); + sidebarEl?.remove(); + } + const column = suggestColumn(doc); setMainColumn(doc, column); } @@ -918,28 +925,28 @@ const findOutermostParentElOfType = ( } }; -// Suggests a default column by inspecting sidebars -// if there are none or some, take up the extra space! -function suggestColumn(doc: Document) { - const hasContents = (id: string) => { - const el = doc.getElementById(id); - // Does the element exist - if (el === null) { - return false; - } +const hasContents = (id: string, doc: Document) => { + const el = doc.getElementById(id); + // Does the element exist + if (el === null) { + return false; + } - // Does it have any element children? - if (el.children.length > 0) { - return true; - } + // Does it have any element children? + if (el.children.length > 0) { + return true; + } - // If it doesn't have any element children - // see if there is any text - return !!el.innerText.trim(); - }; + // If it doesn't have any element children + // see if there is any text + return !!el.innerText.trim(); +}; - const leftSidebar = hasContents(kSidebarId); - const rightSidebar = hasContents(kMarginSidebarId); +// Suggests a default column by inspecting sidebars +// if there are none or some, take up the extra space! +function suggestColumn(doc: Document) { + const leftSidebar = hasContents(kSidebarId, doc); + const rightSidebar = hasContents(kMarginSidebarId, doc); const columnClasses = getColumnClasses(doc); const leftContent = [...fullOccludeClz, ...leftOccludeClz].some((clz) => { From 6082c8adfd28d5238e7788bea284610b511191e8 Mon Sep 17 00:00:00 2001 From: Charles Teague Date: Wed, 4 May 2022 10:32:35 -0400 Subject: [PATCH 3/3] Improve linux path detection and usage --- src/command/tools/tools/tinytex.ts | 65 ++++++++++++------------------ 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/src/command/tools/tools/tinytex.ts b/src/command/tools/tools/tinytex.ts index d7b2a8aed5..d996605cf1 100644 --- a/src/command/tools/tools/tinytex.ts +++ b/src/command/tools/tools/tinytex.ts @@ -301,21 +301,6 @@ async function afterInstall(context: InstallContext) { tlmgrPath, ["-q", "option", "repository", defaultRepo], ); - - if (Deno.build.os === "linux") { - const binPath = expandPath("~/bin"); - if (!existsSync(binPath)) { - // Make the directory - Deno.mkdirSync(binPath); - restartRequired = true; - } - - // Notify tlmgr of it - await exec( - tlmgrPath, - ["option", "sys_bin", binPath], - ); - } }, ); @@ -328,24 +313,19 @@ ${tlmgrPath} path add This will instruct TeX Live to create symlinks that it needs in .`; - const configureBinPath = async () => { + const configureBinPath = async (path: string) => { if (Deno.build.os !== "windows") { // Find bin paths on this machine - const paths = suggestUserBinPaths(); - if (paths.length > 0) { - // Ensure the directory exists - const path = expandPath(paths[0]); - ensureDirSync(path); + // Ensure the directory exists + const expandedPath = expandPath(path); + ensureDirSync(expandedPath); - // Set the sys_bin for texlive - await exec( - tlmgrPath, - ["option", "sys_bin", path], - ); - return true; - } else { - return false; - } + // Set the sys_bin for texlive + await exec( + tlmgrPath, + ["option", "sys_bin", expandedPath], + ); + return true; } else { return true; } @@ -355,16 +335,21 @@ This will instruct TeX Live to create symlinks that it needs in { - const pathConfigured = await configureBinPath(); - if (pathConfigured) { - const result = await exec( - tlmgrPath, - ["path", "add"], - ); - if (!result.success) { - warning(message); + let result; + const paths = suggestUserBinPaths(); + for (const path of paths) { + const pathConfigured = await configureBinPath(path); + if (pathConfigured) { + result = await exec( + tlmgrPath, + ["path", "add"], + ); + if (result.success) { + break; + } } - } else { + } + if (!result?.success) { warning(message); } }, @@ -419,7 +404,7 @@ async function uninstall(context: InstallContext) { } function exec(path: string, cmd: string[]) { - return execProcess({ cmd: [path, ...cmd], stdout: "piped" }); + return execProcess({ cmd: [path, ...cmd], stdout: "piped", stderr: "piped" }); } const kTlMgrKey = "tlmgr";