Skip to content

Commit

Permalink
Merge pull request #9428 from quarto-dev/bugfix/9426
Browse files Browse the repository at this point in the history
update crossref.lua to use quarto_ast_pipeline
  • Loading branch information
cscheid authored Apr 20, 2024
2 parents cbc7b70 + df9f510 commit 2d0188b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
1 change: 1 addition & 0 deletions news/changelog-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ All changes included in 1.5:
- ([#9059](https://github.com/quarto-dev/quarto-cli/issues/9059)): `quarto run` now properly works on Windows with Lua scripts.
- ([#9282](https://github.com/quarto-dev/quarto-cli/issues/9282)): Fix name clash in Lua local declarations for `mediabag` in bundled releases.
- ([#9394](https://github.com/quarto-dev/quarto-cli/issues/9394)): Make `template` a required field in the `about` schema.
- ([#9426](https://github.com/quarto-dev/quarto-cli/issues/9426)): Update `crossref.lua` filter to avoid crashes and hangs in documents with custom AST nodes.
- Add support for `{{< lipsum >}}` shortcode, which is useful for emitting placeholder text. Provide a specific number of paragraphs (`{{< lipsum 3 >}}`).
- Resolve data URIs in Pandoc's mediabag when rendering documents.
- Increase v8's max heap size by default, to avoid out-of-memory errors when rendering large documents (also cf. https://github.com/denoland/deno/issues/18935).
Expand Down
4 changes: 4 additions & 0 deletions src/command/editor-support/crossref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ const makeCrossrefCommand = () => {
stdout: "piped",
},
input,
undefined, // mergeOutput?: "stderr>stdout" | "stdout>stderr",
undefined, // stderrFilter?: (output: string) => string,
undefined, // respectStreams?: boolean,
5000,
);

// check for error
Expand Down
15 changes: 13 additions & 2 deletions src/core/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@ export async function execProcess(
mergeOutput?: "stderr>stdout" | "stdout>stderr",
stderrFilter?: (output: string) => string,
respectStreams?: boolean,
timeout?: number,
): Promise<ProcessResult> {
const withTimeout = <T>(promise: Promise<T>): Promise<T> => {
return timeout
? Promise.race([
promise,
new Promise((_, reject) =>
setTimeout(() => reject(new Error("Process timed out")), timeout)
),
]) as Promise<T>
: promise;
};
ensureCleanup();
// define process
try {
Expand Down Expand Up @@ -150,11 +161,11 @@ export async function execProcess(
}),
);
}
await Promise.all(promises);
await withTimeout(Promise.all(promises));
}

// await result
const status = await process.status();
const status = await withTimeout(process.status());

// close the process
process.close();
Expand Down
28 changes: 1 addition & 27 deletions src/resources/filters/crossref/crossref.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,34 +156,8 @@ local quarto_normalize_filters = {
end, normalize_filter()) },

{ name = "normalize-capture-reader-state", filter = normalize_capture_reader_state() },

{ name = "pre-table-merge-raw-html",
filter = table_merge_raw_html()
},

-- { name = "pre-content-hidden-meta",
-- filter = content_hidden_meta() },

-- 2023-04-11: We want to combine combine-1 and combine-2, but parse_md_in_html_rawblocks
-- can't be combined with parse_html_tables. combineFilters
-- doesn't inspect the contents of the results in the inner loop in case
-- the result is "spread" into a Blocks or Inlines.

{ name = "normalize-combined-1", filter = combineFilters({
parse_html_tables(),
parse_extended_nodes(),
code_filename(),
})
},
{
name = "normalize-combine-2",
filter = combineFilters({
parse_md_in_html_rawblocks(),
parse_floatreftargets(),
parse_blockreftargets(),
}),
},
}
tappend(quarto_normalize_filters, quarto_ast_pipeline())

local quarto_pre_filters = {
-- quarto-pre
Expand Down

0 comments on commit 2d0188b

Please sign in to comment.