Skip to content

Commit 26a18fe

Browse files
committed
Merge branch 'main' into chore/1.6-pandoc-update
2 parents 44e0f48 + 1bc1695 commit 26a18fe

File tree

11 files changed

+1863
-1634
lines changed

11 files changed

+1863
-1634
lines changed

news/changelog-1.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All changes included in 1.6:
1111
- ([#10196](https://github.com/quarto-dev/quarto-cli/issues/10196)): Protect against nil values in `float.caption_long`.
1212
- ([#10328](https://github.com/quarto-dev/quarto-cli/issues/10328)): Interpret subcells as subfloats when subcap count matches subcell count.
1313
- ([#10624](https://github.com/quarto-dev/quarto-cli/issues/10624)): Don't crash when proof environments are empty in `pdf`.
14+
- ([#10858](https://github.com/quarto-dev/quarto-cli/issues/10858)): Don't crash in `gfm` when `content` of a `FloatRefTarget` is of type `Blocks`.
1415

1516
## `dashboard` Format
1617

src/command/render/pandoc.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,7 @@ async function resolveExtras(
13831383
const sourcelist = line.match(/^ *src: (.*); *$/);
13841384
if (sourcelist) {
13851385
const sources = sourcelist[1].split(",").map((s) => s.trim());
1386+
let found = false;
13861387
const failed_formats = [];
13871388
for (const source of sources) {
13881389
const match = source.match(
@@ -1392,6 +1393,7 @@ async function resolveExtras(
13921393
const [_, url, format] = match;
13931394
if (["truetype", "opentype"].includes(format)) {
13941395
ttf_urls.push(url);
1396+
found = true;
13951397
break;
13961398
}
13971399
// else if (["woff", "woff2"].includes(format)) {
@@ -1401,12 +1403,14 @@ async function resolveExtras(
14011403
failed_formats.push(format);
14021404
}
14031405
}
1404-
console.log(
1405-
"skipping",
1406-
family,
1407-
"\nnot currently able to use formats",
1408-
failed_formats.join(", "),
1409-
);
1406+
if (!found) {
1407+
console.log(
1408+
"skipping",
1409+
family,
1410+
"\nnot currently able to use formats",
1411+
failed_formats.join(", "),
1412+
);
1413+
}
14101414
}
14111415
}
14121416
}

src/core/sass.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,14 @@ export async function compileSass(
139139
...userRules,
140140
'// quarto-scss-analysis-annotation { "origin": null }',
141141
].join("\n\n");
142+
let failed = false;
143+
// deno-lint-ignore no-explicit-any
144+
let e: any = null;
142145
try {
143146
scssInput += "\n" + cssVarsBlock(scssInput);
144-
} catch (e) {
145-
console.error("Error adding css vars block", e);
146-
Deno.writeTextFileSync("scss-error.scss", scssInput);
147-
console.error(
148-
"This is a Quarto bug.\nPlease consider reporting it at https://github.com/quarto-dev/quarto-cli,\nalong with the scss-error.scss file that can be found in the current working directory.",
149-
);
150-
throw e;
147+
} catch (_e) {
148+
e = _e;
149+
failed = true;
151150
}
152151

153152
// Compile the scss
@@ -158,6 +157,18 @@ export async function compileSass(
158157
minified,
159158
md5HashBytes(new TextEncoder().encode(scssInput)),
160159
);
160+
161+
if (failed) {
162+
console.warn("Error adding css vars block", e);
163+
console.warn(
164+
"The resulting CSS file will not have SCSS color variables exported as CSS.",
165+
);
166+
Deno.writeTextFileSync("_quarto_internal_scss_error.scss", scssInput);
167+
console.warn(
168+
"This is likely a Quarto bug.\nPlease consider reporting it at https://github.com/quarto-dev/quarto-cli,\nalong with the _quarto_internal_scss_error.scss file that can be found in the current working directory.",
169+
);
170+
}
171+
161172
if (!Deno.env.get("QUARTO_SAVE_SCSS")) {
162173
return result;
163174
}

src/core/sass/analyzer/parse.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,20 @@ export const makeParserModule = (
1414
// it also doesn't like some valid ways to do '@import url'
1515
contents = contents.replaceAll("@import url", "//@import url");
1616

17-
// it also really doesn't like statemnts that don't end in a semicolon
17+
// it also really doesn't like statements that don't end in a semicolon
1818
// so, in case you are reading this code to understand why the parser is failing,
1919
// ensure that your SCSS has semicolons at the end of every statement.
20-
//
20+
// we try to work around this by adding semicolons at the end of declarations that don't have them
21+
contents = contents.replaceAll(
22+
/^(?!\/\/)(.*[^}/\s\n;])([\s\n]*)}(\n|$)/mg,
23+
"$1;$2}$3",
24+
);
25+
// It also doesn't like values that follow a colon directly without a space
26+
contents = contents.replaceAll(
27+
/(^\s*[A-Za-z0-9-]+):([^ \n])/mg,
28+
"$1: $2",
29+
);
30+
2131
// This is relatively painful, because unfortunately the error message of scss-parser
2232
// is not helpful.
2333

src/core/sass/brand.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,10 @@ const brandTypographyBundle = (
384384
const family = resolvedFontOptions.family;
385385
const font = getFontFamilies(family);
386386
const result: HTMLFontInformation = {};
387-
result.family = "";
388-
// FIXME
389-
// resolveGoogleFontFamily(font) ??
390-
// resolveBunnyFontFamily(font) ??
391-
// resolveFilesFontFamily(font) ?? family;
387+
result.family = resolveGoogleFontFamily(font) ??
388+
// resolveBunnyFontFamily(font) ??
389+
// resolveFilesFontFamily(font) ??
390+
family;
392391
for (
393392
const entry of [
394393
"line-height",

src/resources/filters/customnodes/floatreftarget.lua

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,23 +1045,33 @@ end, function(float)
10451045

10461046
local open_block = pandoc.RawBlock("markdown", "<div id=\"" .. float.identifier .. "\">\n")
10471047
local close_block = pandoc.RawBlock("markdown", "\n</div>")
1048+
local result = pandoc.Blocks({open_block})
1049+
local insert_content = function()
1050+
if pandoc.utils.type(float.content) == "Block" then
1051+
result:insert(float.content)
1052+
else
1053+
result:extend(quarto.utils.as_blocks(float.content))
1054+
end
1055+
end
1056+
local insert_caption = function()
1057+
if pandoc.utils.type(float.caption_long) == "Block" then
1058+
result:insert(float.caption_long)
1059+
else
1060+
result:insert(pandoc.Plain(quarto.utils.as_inlines(float.caption_long)))
1061+
end
1062+
end
10481063

10491064
if caption_location == "top" then
1050-
return pandoc.Blocks({
1051-
open_block,
1052-
float.caption_long,
1053-
float.content,
1054-
close_block
1055-
})
1065+
insert_caption()
1066+
insert_content()
1067+
result:insert(close_block)
10561068
else
1057-
return pandoc.Blocks({
1058-
open_block,
1059-
float.content,
1060-
pandoc.RawBlock("markdown", "\n"),
1061-
float.caption_long,
1062-
close_block
1063-
})
1069+
insert_content()
1070+
result:insert(pandoc.RawBlock("markdown", "\n"))
1071+
insert_caption()
1072+
result:insert(close_block)
10641073
end
1074+
return result
10651075
end)
10661076

10671077
_quarto.ast.add_renderer("FloatRefTarget", function(_)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "Test"
3+
format: gfm
4+
---
5+
6+
::: {#fig-line-plot}
7+
8+
```python
9+
import matplotlib.pyplot as plt
10+
plt.plot([1,23,2,4])
11+
plt.show()
12+
```
13+
14+
Some output
15+
16+
A line plot
17+
:::
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
format:
3+
revealjs:
4+
theme: theme.scss
5+
---
6+
7+
## Hello.
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
2+
3+
/*--scss:defaults --*/
4+
$yellow: #ffc627 !default;
5+
$gold: #ffc627 !default;
6+
$red: #8c1d40 !default;
7+
$maroon: #8c1d40 !default;
8+
$orange: #ff7f32 !default;
9+
$blue: #00a3e0 !default;
10+
$green: #78be20 !default;
11+
$grey: #747474 !default;
12+
13+
// fonts
14+
// $font-family-sans-serif: "Arial" !default;
15+
16+
// main colors
17+
$link-color: $maroon !default;
18+
19+
// font sizes and margins
20+
$presentation-font-size-root: 46px !default;
21+
$presentation-h1-font-size: 2.3em !default;
22+
$presentation-h2-font-size: 1.5em !default;
23+
$presentation-h3-font-size: 1.2em !default;
24+
$presentation-h4-font-size: 1.1em !default;
25+
$presentation-heading-color: $maroon !default;
26+
27+
// inline code
28+
$code-color: $blue !default;
29+
30+
/*-- scss:mixins --*/
31+
32+
// Generates the presentation background, can be overridden
33+
// to return a background image or gradient
34+
@mixin bodyBackground() {
35+
background: $backgroundColor;
36+
}
37+
38+
/*-- scss:rules --*/
39+
40+
// Change text colors against dark slide backgrounds
41+
42+
.reveal .title {
43+
line-height: 100px;
44+
margin-top: 0.5em;
45+
}
46+
47+
.reveal .subtitle {
48+
background: $gold;
49+
font-size: $presentation-h2-font-size;
50+
font-weight: bold;
51+
margin-bottom: 1.5em;
52+
}
53+
54+
.reveal .author {
55+
font-size: $presentation-h3-font-size;
56+
font-weight: bold;
57+
color: $maroon;
58+
}
59+
60+
.reveal .institute {
61+
font-size: $presentation-h4-font-size;
62+
}
63+
64+
.reveal .date {
65+
font-family: $font-family-monospace;
66+
font-size: 0.8em;
67+
}
68+
69+
// This is a sentinel value that renderers can use to determine
70+
// whether the theme is dark or light
71+
// @if (color.blackness($backgroundColor) > $code-block-theme-dark-threshhold) {
72+
// /*! dark */
73+
// } @else {
74+
// /*! light */
75+
// }
76+
77+
/*--Custom classes --*/
78+
.alert {
79+
background: #FFC627;
80+
}
81+
82+
.center {
83+
text-align: center;
84+
display: block;
85+
}
86+
87+
.large {font-size: 150%}
88+
89+
.small {font-size: 80%}
90+
91+
.gold {color: #FFC627}
92+
.maroon {color: #8C1D40}
93+
.green {color: #78BE20}
94+
.blue {color: #00A3E0}
95+
.orange {color: #FF7F32}
96+
.grey {color: #747474}
97+
.fade {
98+
opacity: 0.5;
99+
}
100+
101+
/* Two-column layout */
102+
.left-column {
103+
width: 20%;
104+
height: 93%;
105+
float: left;
106+
}
107+
.left-column h2, .left-column h3 {
108+
color: var(--inverse-link-color);
109+
}
110+
.left-column h2:last-of-type, .left-column h3:last-child {
111+
color: var(--inverse-text-color);
112+
}
113+
.right-column {
114+
width: 75%;
115+
float: right;
116+
}
117+
.pull-left {
118+
float: left;
119+
width: 48%;
120+
}
121+
.pull-right {
122+
float: right;
123+
width: 48%;
124+
}
125+
.pull-right + * {
126+
clear: both;
127+
}
128+
129+
hr {
130+
content: none;
131+
display: block;
132+
border: none;
133+
background-color: $gold;
134+
height: 0.1em;
135+
}
136+
137+
blockquote {
138+
border-left: solid 5px $gold;
139+
padding-left: 1em;
140+
}
141+
142+
.container{
143+
display: flex;
144+
}
145+
.col{
146+
flex:1;
147+
}
148+
149+
.reveal.reveal img
150+
{
151+
border: none;
152+
box-shadow: none;
153+
max-height: calc(75vh);
154+
margin: auto;
155+
display: flex;
156+
}
157+
158+
.rotated {
159+
transform: rotate(270deg)
160+
}
161+
162+
.reveal .slide figure>figcaption, .reveal .slide img.stretch+p.caption, .reveal .slide img.r-stretch+p.caption {
163+
font-size: 0.7em;
164+
text-align: center;
165+
color: $grey;
166+
}

0 commit comments

Comments
 (0)