Skip to content

Commit f511d04

Browse files
authored
Merge pull request #7189 from quarto-dev/bugfix/7187
`html-table-processing` options in document, project and attributes
2 parents 52678db + f430a8a commit f511d04

File tree

13 files changed

+116
-18
lines changed

13 files changed

+116
-18
lines changed

news/changelog-1.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- ([#6714](https://github.com/quarto-dev/quarto-cli/issues/6714)): Display title block for HTML when other (non-title/author/subtitle) metadata is present.
3838
- ([#6833](https://github.com/quarto-dev/quarto-cli/issues/6833)): Handle partially-specified aspect ratio, width, and height attributes in `video` shortcode.
3939
- ([#7137](https://github.com/quarto-dev/quarto-cli/discussions/7137)): Automatically set `rel="noopener"` when setting a target on external links
40+
- ([#7187](https://github.com/quarto-dev/quarto-cli/issues/7187)): Add `html-table-processing: none` to document- and project-level metadata to disable HTML table processing. Add `{html-table-processing="none"}` to a fenced div to disable HTML table processing for the elements in that div.
4041

4142
## Appendix
4243

src/command/render/filters.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
kFormatIdentifier,
2424
kHeaderIncludes,
2525
kHtmlMathMethod,
26+
kHtmlTableProcessing,
2627
kIncludeAfter,
2728
kIncludeAfterBody,
2829
kIncludeBefore,
@@ -553,6 +554,10 @@ async function quartoFilterParams(
553554
if (foldCode) {
554555
params[kCodeFold] = foldCode;
555556
}
557+
const htmlTableProcessing = format.render[kHtmlTableProcessing];
558+
if (htmlTableProcessing) {
559+
params[kHtmlTableProcessing] = htmlTableProcessing;
560+
}
556561
const tblColwidths = format.render[kTblColwidths];
557562
if (tblColwidths !== undefined) {
558563
params[kTblColwidths] = tblColwidths;

src/config/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ export const kQuartoRequired = "quarto-required";
130130
export const kPreviewMode = "preview-mode";
131131
export const kPreviewModeRaw = "raw";
132132

133+
export const kHtmlTableProcessing = "html-table-processing";
134+
133135
export const kIdentifierDefaultsKeys = [
134136
kTargetFormat,
135137
kDisplayName,
@@ -214,6 +216,7 @@ export const kRenderDefaultsKeys = [
214216
kNotebookViewStyle,
215217
kNotebookPreserveCells,
216218
kClearCellOptions,
219+
kHtmlTableProcessing,
217220
];
218221

219222
// language fields

src/config/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import {
8787
kGladtex,
8888
kHighlightStyle,
8989
kHtmlMathMethod,
90+
kHtmlTableProcessing,
9091
kInclude,
9192
kIncludeAfterBody,
9293
kIncludeBeforeBody,
@@ -471,6 +472,7 @@ export interface FormatRender {
471472
[kNotebookPreserveCells]?: boolean;
472473
[kClearCellOptions]?: boolean;
473474
[kIpynbProduceSourceNotebook]?: boolean;
475+
[kHtmlTableProcessing]?: "none";
474476
}
475477

476478
export interface FormatExecute {

src/resources/editor/tools/vs-code.mjs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16200,6 +16200,15 @@ var require_yaml_intelligence_resources = __commonJS({
1620016200
short: "Specify the default dpi (dots per inch) value for conversion from pixels to inch/\ncentimeters and vice versa.\n",
1620116201
long: "Specify the default dpi (dots per inch) value for conversion from pixels to inch/\ncentimeters and vice versa. (Technically, the correct term would be ppi: pixels per\ninch.) The default is `96`. When images contain information about dpi internally, the\nencoded value is used instead of the default specified by this option.\n"
1620216202
}
16203+
},
16204+
{
16205+
name: "html-table-processing",
16206+
schema: {
16207+
enum: [
16208+
"none"
16209+
]
16210+
},
16211+
description: "If `none`, do not process tables in HTML input."
1620316212
}
1620416213
],
1620516214
"schema/document-reveal-content.yml": [
@@ -21019,7 +21028,7 @@ var require_yaml_intelligence_resources = __commonJS({
2101921028
"Keep the markdown file generated by executing code",
2102021029
"Keep the notebook file generated from executing code.",
2102121030
"Filters to pre-process ipynb files before rendering to markdown",
21022-
"Speicfy which nodes should be run interactively (displaying output\nfrom expressions)",
21031+
"Specify which nodes should be run interactively (displaying output\nfrom expressions)",
2102321032
"Keep the intermediate typst file used during render.",
2102421033
"Keep the intermediate tex file used during render.",
2102521034
{
@@ -21908,7 +21917,8 @@ var require_yaml_intelligence_resources = __commonJS({
2190821917
},
2190921918
"Disambiguating year suffix in author-date styles (e.g. \u201Ca\u201D in \u201CDoe,\n1999a\u201D).",
2191021919
"Manuscript configuration",
21911-
"internal-schema-hack"
21920+
"internal-schema-hack",
21921+
"If <code>none</code>, do not process tables in HTML input."
2191221922
],
2191321923
"schema/external-schemas.yml": [
2191421924
{
@@ -22132,12 +22142,12 @@ var require_yaml_intelligence_resources = __commonJS({
2213222142
mermaid: "%%"
2213322143
},
2213422144
"handlers/mermaid/schema.yml": {
22135-
_internalId: 168151,
22145+
_internalId: 168154,
2213622146
type: "object",
2213722147
description: "be an object",
2213822148
properties: {
2213922149
"mermaid-format": {
22140-
_internalId: 168143,
22150+
_internalId: 168146,
2214122151
type: "enum",
2214222152
enum: [
2214322153
"png",
@@ -22153,7 +22163,7 @@ var require_yaml_intelligence_resources = __commonJS({
2215322163
exhaustiveCompletions: true
2215422164
},
2215522165
theme: {
22156-
_internalId: 168150,
22166+
_internalId: 168153,
2215722167
type: "anyOf",
2215822168
anyOf: [
2215922169
{

src/resources/editor/tools/yaml/web-worker.js

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/resources/editor/tools/yaml/yaml-intelligence-resources.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9172,6 +9172,15 @@
91729172
"short": "Specify the default dpi (dots per inch) value for conversion from pixels to inch/\ncentimeters and vice versa.\n",
91739173
"long": "Specify the default dpi (dots per inch) value for conversion from pixels to inch/\ncentimeters and vice versa. (Technically, the correct term would be ppi: pixels per\ninch.) The default is `96`. When images contain information about dpi internally, the\nencoded value is used instead of the default specified by this option.\n"
91749174
}
9175+
},
9176+
{
9177+
"name": "html-table-processing",
9178+
"schema": {
9179+
"enum": [
9180+
"none"
9181+
]
9182+
},
9183+
"description": "If `none`, do not process tables in HTML input."
91759184
}
91769185
],
91779186
"schema/document-reveal-content.yml": [
@@ -13991,7 +14000,7 @@
1399114000
"Keep the markdown file generated by executing code",
1399214001
"Keep the notebook file generated from executing code.",
1399314002
"Filters to pre-process ipynb files before rendering to markdown",
13994-
"Speicfy which nodes should be run interactively (displaying output\nfrom expressions)",
14003+
"Specify which nodes should be run interactively (displaying output\nfrom expressions)",
1399514004
"Keep the intermediate typst file used during render.",
1399614005
"Keep the intermediate tex file used during render.",
1399714006
{
@@ -14880,7 +14889,8 @@
1488014889
},
1488114890
"Disambiguating year suffix in author-date styles (e.g.&nbsp;“a” in “Doe,\n1999a”).",
1488214891
"Manuscript configuration",
14883-
"internal-schema-hack"
14892+
"internal-schema-hack",
14893+
"If <code>none</code>, do not process tables in HTML input."
1488414894
],
1488514895
"schema/external-schemas.yml": [
1488614896
{
@@ -15104,12 +15114,12 @@
1510415114
"mermaid": "%%"
1510515115
},
1510615116
"handlers/mermaid/schema.yml": {
15107-
"_internalId": 168151,
15117+
"_internalId": 168154,
1510815118
"type": "object",
1510915119
"description": "be an object",
1511015120
"properties": {
1511115121
"mermaid-format": {
15112-
"_internalId": 168143,
15122+
"_internalId": 168146,
1511315123
"type": "enum",
1511415124
"enum": [
1511515125
"png",
@@ -15125,7 +15135,7 @@
1512515135
"exhaustiveCompletions": true
1512615136
},
1512715137
"theme": {
15128-
"_internalId": 168150,
15138+
"_internalId": 168153,
1512915139
"type": "anyOf",
1513015140
"anyOf": [
1513115141
{

src/resources/filters/modules/constants.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ local kIncludeInHeader = "include-in-header"
6565

6666
local kCopyright = "copyright"
6767
local kLicense = "license"
68+
local kHtmlTableProcessing = "html-table-processing"
6869

6970
-- for a given language, the comment character(s)
7071
local kLangCommentChars = {
@@ -187,5 +188,6 @@ return {
187188
kCopyright = kCopyright,
188189
kLicense = kLicense,
189190

190-
kLangCommentChars = kLangCommentChars
191+
kLangCommentChars = kLangCommentChars,
192+
kHtmlTableProcessing = kHtmlTableProcessing
191193
}

src/resources/filters/normalize/astpipeline.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
function quarto_ast_pipeline()
55
return {
66
{ name = "normalize-table-merge-raw-html", filter = table_merge_raw_html() },
7-
7+
8+
-- this can't be combined because it's top-down processing.
9+
-- unfortunate.
10+
{ name = "normalize-html-table-processing", filter = parse_html_tables() },
11+
812
{ name = "normalize-combined-1", filter = combineFilters({
9-
parse_html_tables(),
1013
parse_extended_nodes(),
1114
code_filename(),
1215
normalize_fixup_data_uri_image_extension(),

src/resources/filters/normalize/parsehtml.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ end
2121

2222
function parse_html_tables()
2323
local filter
24+
if param(constants.kHtmlTableProcessing) == "none" then
25+
return {}
26+
end
2427
filter = {
28+
traverse = "topdown",
29+
Div = function(div)
30+
if div.attributes[constants.kHtmlTableProcessing] == "none" then
31+
return div.contents, false
32+
end
33+
end,
2534
RawBlock = function(el)
2635
if _quarto.format.isRawHtml(el) then
2736
-- if we have a raw html table in a format that doesn't handle raw_html

0 commit comments

Comments
 (0)