Skip to content

Commit

Permalink
Merge pull request #7545 from quarto-dev/bugfix/7905
Browse files Browse the repository at this point in the history
parse_html_tables(): use `html+raw_html`
  • Loading branch information
cscheid authored Nov 10, 2023
2 parents 7a4d948 + 3cbc0c0 commit fe68580
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@
- ([#6620](https://github.com/quarto-dev/quarto-cli/issues/6620)): Introduce `FloatRefTarget` AST nodes that generalize crossref targets to include figures, tables, and custom floating elements.
- ([#7200](https://github.com/quarto-dev/quarto-cli/issues/7200)): Support Unicode in subref labels.

## Input format

- ([#7905](https://github.com/quarto-dev/quarto-cli/issues/7905)): Use `html+raw_html` as input format when processing HTML rawblocks for tables to avoid Pandoc converting SVG elements to images.

## Other Fixes and Improvements

- Exit if project pre or post render script fails
Expand Down
11 changes: 10 additions & 1 deletion src/resources/filters/normalize/parsehtml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ function parse_html_tables()
return nil
end

-- we're already at a state of sin here, cf https://stackoverflow.com/a/1732454
-- but this is important enough to do a little more work anyway
--
-- specifically, we should do our best not to break good HTML when it's there



local tableBegin,tableBody,tableEnd = el.text:match(pat)
if tableBegin then
local before_table = string.sub(el.text, 1, i - 1)
Expand All @@ -75,7 +82,9 @@ function parse_html_tables()
-- annotated td elements with th elements.

tableHtml = preprocess_table_text(tableHtml)
local tableDoc = pandoc.read(tableHtml, "html")
-- process html with raw_html so that contents that are not parseable
-- by Pandoc end up as rawblock elements
local tableDoc = pandoc.read(tableHtml, "html+raw_html")
local skip = false
local found = false
_quarto.ast.walk(tableDoc, {
Expand Down
17 changes: 17 additions & 0 deletions tests/docs/smoke-all/2023/11/10/7905.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "7905"
_quarto:
tests:
html:
ensureFileRegexMatches:
- []
-
- "svg\\+xml" # can't use ensureHtmlElements because svg is not part of the HTML DOM
# so we instead ensure that pandoc didn't transform svg into data-uri-encoded image
---

```{=html}
<table>
<tr><td><svg width="300" height="300"></svg></td></tr>
</table>
```

0 comments on commit fe68580

Please sign in to comment.