Skip to content

Commit

Permalink
Merge branch 'main' of github.com:quarto-dev/quarto-cli into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed May 4, 2022
2 parents 6eda39e + 6082c8a commit bfccb67
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 61 deletions.
5 changes: 3 additions & 2 deletions src/command/render/crossref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ export function crossrefFilterParams(
);
}
// implies number-sections
params[kNumberSections] = true;
if (defaults?.[kNumberSections] === undefined) {
params[kNumberSections] = true;
}
}

params[option] = value;
}
});
Expand Down
65 changes: 25 additions & 40 deletions src/command/tools/tools/tinytex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
}
},
);

Expand All @@ -328,24 +313,19 @@ ${tlmgrPath} path add
This will instruct TeX Live to create symlinks that it needs in <bin_dir_on_path>.`;

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;
}
Expand All @@ -355,16 +335,21 @@ This will instruct TeX Live to create symlinks that it needs in <bin_dir_on_path
await context.withSpinner(
{ message: "Updating paths" },
async () => {
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);
}
},
Expand Down Expand Up @@ -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";
Expand Down
45 changes: 26 additions & 19 deletions src/format/html/format-html-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit bfccb67

Please sign in to comment.