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
2 changes: 2 additions & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@
- ([#6211](https://github.com/quarto-dev/quarto-cli/pull/6211)): Improve error message when a JSON filter (or a potentially misspelled Lua filter from an extension) is not found.
- ([#6215](https://github.com/quarto-dev/quarto-cli/issues/6215)): Add `quarto.utils.string_to_inlines` and `quarto.utils.string_to_blocks` to Lua API to convert a string to a list of inlines or blocks taking into account quarto's AST structure.
- ([#6289](https://github.com/quarto-dev/quarto-cli/issues/6289)): allow `markdownToInlines` to take empty string.
- ([#6935](https://github.com/quarto-dev/quarto-cli/issues/6935)): render callouts to `gfm` using GitHub's syntax.
- ([#6935](https://github.com/quarto-dev/quarto-cli/issues/6935)): Add isGithubMarkdownOutput() to quarto.format API.

## Debian Installer

Expand Down
2 changes: 2 additions & 0 deletions src/command/render/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
kFigEnv,
kFigPos,
kFigResponsive,
kFormatIdentifier,
kHeaderIncludes,
kHtmlMathMethod,
kIncludeAfter,
Expand Down Expand Up @@ -156,6 +157,7 @@ export async function filterParamsJson(
crossref: crossrefFilterActive(options),
jats_subarticle: options.format.metadata[kJatsSubarticle],
},
[kFormatIdentifier]: options.format.identifier,
};
return JSON.stringify(params);
}
Expand Down
2 changes: 2 additions & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,3 +737,5 @@ export const kSourceMappingRegexes = [
/^\/\/#\s*sourceMappingURL\=.*\.map$/gm,
/\/\*\# sourceMappingURL=.* \*\//g,
];

export const kFormatIdentifier = "format-identifier";
21 changes: 21 additions & 0 deletions src/resources/filters/customnodes/callout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -574,3 +574,24 @@ end, calloutDiv)
_quarto.ast.add_renderer("Callout", function(_)
return _quarto.format.isEpubOutput() or _quarto.format.isRevealJsOutput()
end, epubCallout)

_quarto.ast.add_renderer("Callout", function(_)
return _quarto.format.isGithubMarkdownOutput()
end, function(callout)
local result = pandoc.Blocks({})
local header = "[!" .. callout.type:upper() .. "]"
result:insert(pandoc.RawBlock("markdown", header))
local tt = pandoc.utils.type(callout.title)
if tt ~= "nil" then
result:insert(pandoc.Header(3, quarto.utils.as_inlines(callout.title)))
end
local ct = pandoc.utils.type(callout.content)
if ct == "Block" then
result:insert(callout.content)
elseif ct == "Blocks" then
result:extend(callout.content)
else
internal_error()
end
return pandoc.BlockQuote(result)
end)
6 changes: 5 additions & 1 deletion src/resources/pandoc/datadir/_format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ local function isMarkdownOutput()
return tcontains(formats, FORMAT) or is_docusaurus_output()
end

local function isGithubMarkdownOutput()
return param("format-identifier", {})["base-format"] == "gfm"
end

-- check for markdown with raw_html enabled
local function isMarkdownWithHtmlOutput()
return (isMarkdownOutput() and tcontains(PANDOC_WRITER_OPTIONS.extensions, "raw_html")) or is_docusaurus_output()
Expand Down Expand Up @@ -240,7 +244,6 @@ local function isTypstOutput()
return FORMAT == "typst"
end


return {
isAsciiDocOutput = isAsciiDocOutput,
isRawHtml = isRawHtml,
Expand All @@ -256,6 +259,7 @@ return {
isRevealJsOutput = isRevealJsOutput,
isSlideOutput = isSlideOutput,
isEpubOutput = isEpubOutput,
isGithubMarkdownOutput = isGithubMarkdownOutput,
isMarkdownOutput = isMarkdownOutput,
isMarkdownWithHtmlOutput = isMarkdownWithHtmlOutput,
isIpynbOutput = isIpynbOutput,
Expand Down
28 changes: 28 additions & 0 deletions tests/docs/smoke-all/2023/09/21/issue-6935.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: issue-6935
_quarto:
tests:
gfm:
ensureFileRegexMatches:
-
- "[>] ### With title" # Note that all headers are re-rendered to level 3
- "[>] This is a callout"
- "[>] \\[[!]NOTE\\]"
- "[>] \\[[!]IMPORTANT\\]"
- ["<div>"]
---

::: {.callout-note}

## With title

This is a callout

:::


::: {.callout-important}

This is a callout without a title.

:::