Skip to content

Commit d004909

Browse files
authored
Merge pull request #9725 from quarto-dev/bugfix/9724
lua,float - force-align Listing floats to left
2 parents cb352af + 97cfefd commit d004909

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

news/changelog-1.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ All changes included in 1.5:
196196
- ([#9550](https://github.com/quarto-dev/quarto-cli/issues/9550)): Don't crash when subcaptions are incorrectly specified with `fig-subcap: true` but no embedded subcaptions.
197197
- ([#9652](https://github.com/quarto-dev/quarto-cli/pull/9652)): Allow `--output-dir` to refer to absolute paths in `quarto render`.
198198
- ([#9701](https://github.com/quarto-dev/quarto-cli/issues/9701)): Fix issue with callouts with non-empty titles that have no string content.
199+
- ([#9724](https://github.com/quarto-dev/quarto-cli/issues/9724)): Force-align text in floats of type `Listing` to the left.
199200
- Add support for `{{< lipsum >}}` shortcode, which is useful for emitting placeholder text. Provide a specific number of paragraphs (`{{< lipsum 3 >}}`).
200201
- Resolve data URIs in Pandoc's mediabag when rendering documents.
201202
- Increase v8's max heap size by default, to avoid out-of-memory errors when rendering large documents (also cf. https://github.com/denoland/deno/issues/18935).

src/resources/filters/customnodes/floatreftarget.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,11 @@ function float_reftarget_render_html_figure(float)
783783
pandoc.Attr("", {}, figure_attrs.figureAttr))
784784
if float.type == "Listing" then
785785
div.attr.classes:insert("listing")
786+
-- in the special case of listings, we likely have text content
787+
-- including annotations, which require left alignment
788+
-- we hard-code this here.
789+
-- https://github.com/quarto-dev/quarto-cli/issues/9724
790+
figure_attrs.align = "left"
786791
end
787792
div.attr.classes:insert("quarto-float")
788793

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
_quarto:
3+
tests:
4+
html:
5+
ensureHtmlElements:
6+
- ["div.quarto-figure-left"]
7+
- []
8+
---
9+
10+
```{.python filename="run_experiments.py" #lst-1 lst-cap="Corpus Loading/Generation Logic"}
11+
line 1
12+
line 2
13+
```

0 commit comments

Comments
 (0)