Skip to content

Commit

Permalink
let markdownToInlines take empty string as argument. (#6290)
Browse files Browse the repository at this point in the history
* markdownToInlines: return empty list on empty string

* changelog
  • Loading branch information
cscheid authored Jul 20, 2023
1 parent ad97bc4 commit 940f952
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
- Add support `quarto.doc.add_resource` and `quarto.doc.add_supporting`. `add_resource` will add a resource file to the current render, copying that file to the same relative location in the output directory. `add_supporting` will add a supporting file to the current render, moving that file file to the same relative location in the output directory.
- ([#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.

## Books

Expand Down
6 changes: 5 additions & 1 deletion src/resources/filters/common/pandoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ end
function markdownToInlines(str)
if str then
local doc = pandoc.read(str)
return doc.blocks[1].content
if #doc.blocks == 0 then
return pandoc.List({})
else
return doc.blocks[1].content
end
else
return pandoc.List()
end
Expand Down
12 changes: 12 additions & 0 deletions tests/docs/smoke-all/2023/07/20/issue-6289.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "Untitled"
format: html
---

This is @tbl-t1.

```{r}
#| label: tbl-t1
#| tbl-cap: ''
gt::gt(mtcars)
```

0 comments on commit 940f952

Please sign in to comment.