Skip to content

Commit

Permalink
Merge pull request #9603 from quarto-dev/bugfix/9547
Browse files Browse the repository at this point in the history
Trim `#` and `?` from filenames in `quarto preview` watchers
  • Loading branch information
cscheid authored May 7, 2024
2 parents c2fe9e1 + 16b6b1d commit 0e17814
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/changelog-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ All changes included in 1.5:
- ([#9492](https://github.com/quarto-dev/quarto-cli/issues/9492)): Improve performance of `quarto preview` when serving resource files of the following formats: HTML, PDF, DOCX, and plaintext.
- ([#9496](https://github.com/quarto-dev/quarto-cli/issues/9496)): Improve parsing error message from `js-yaml` when `key:value` is used together with `key: value` in the same YAML block.
- ([#9527](https://github.com/quarto-dev/quarto-cli/pull/9527)): Add `quarto.format` and `quarto.format.typst` to Quarto's public Lua filter API.
- ([#9547](https://github.com/quarto-dev/quarto-cli/issues/9547)): Fix issue with `quarto preview` and resources found in URLs with hash and search fragments.
- ([#9550](https://github.com/quarto-dev/quarto-cli/issues/9550)): Don't crash when subcaptions are incorrectly specified with `fig-subcap: true` but no embedded subcaptions.
- 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.
Expand Down
15 changes: 13 additions & 2 deletions src/command/preview/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
*/

import { info, warning } from "../../deno_ral/log.ts";
import { basename, dirname, isAbsolute, join, relative } from "../../deno_ral/path.ts";
import {
basename,
dirname,
isAbsolute,
join,
relative,
} from "../../deno_ral/path.ts";
import { existsSync } from "fs/mod.ts";

import * as ld from "../../core/lodash.ts";
Expand Down Expand Up @@ -571,8 +577,13 @@ export function createChangeHandler(
? "/" + kPdfJsInitialPath
: "";

// https://github.com/quarto-dev/quarto-cli/issues/9547
// ... this fix means we'll never be able to support files
// fix question marks or octothorpes in their names
const removeUrlFragment = (file: string) =>
file.replace(/#.*$/, "").replace(/\?.*$/, "");
watches.push({
files: reloadFiles.filter(reloadFileFilter),
files: reloadFiles.filter(reloadFileFilter).map(removeUrlFragment),
handler: ld.debounce(async () => {
await renderQueue.enqueue(async () => {
await reloader.reloadClients(reloadTarget);
Expand Down

0 comments on commit 0e17814

Please sign in to comment.