Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/format/markdown/format-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* Copyright (C) 2020-2022 Posit Software, PBC
*/

import { kOutputDivs, kVariant } from "../../config/constants.ts";
import { kFrom, kOutputDivs, kToc, kVariant } from "../../config/constants.ts";
import { Format } from "../../config/types.ts";
import { pandocFormat } from "../../core/pandoc/pandoc-formats.ts";
import { createFormat, plaintextFormat } from "../formats-shared.ts";
import { kGfmCommonmarkVariant } from "./format-markdown-consts.ts";

Expand Down Expand Up @@ -36,6 +37,18 @@ export function gfmFormat(): Format {
render: {
[kVariant]: kGfmCommonmarkVariant,
},
resolveFormat: (format: Format) => {
if (format.pandoc[kToc] === true) {
// we need to add gfm_auto_identifiers to reader otherwise ids for toc are not valid
// see https://github.com/quarto-dev/quarto-cli/issues/4917 and
// https://github.com/jgm/pandoc/issues/8709
format.pandoc[kFrom] = pandocFormat(
format.pandoc[kFrom] || "markdown",
["gfm_auto_identifiers"],
[],
);
}
},
});
}

Expand Down
17 changes: 17 additions & 0 deletions tests/docs/smoke-all/2023/03/22/gha-toc-4917.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
format:
gfm:
toc: true
_quarto:
tests:
gfm:
ensureFileRegexMatches:
- ["\\(#with-ending-dot\\)", "\\(#with-adot-in-the-middle\\)"]
- ["\\(#with-ending-dot\\.\\)","\\(#with-a\\.dot-in-the-middle\\)"]
---

# A header

# With ending dot.

# With a.dot in the middle