Code-copy button above the code block in sections using the column grid (`page-columns`)

Đang mở
#15,137 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@cderv đang làm issue này rồi.

Từ ngày 21/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug code-blocks

Split from #13446, reported by mcanouil in https://github.com/quarto-dev/quarto-cli/issues/13446#issuecomment-6315320408.

When a section holds an element placed on the column grid, like a .column-margin div or a footnote with reference-location: margin, the copy button of a code block in that section sits above the code frame, half outside it.

---
title: "Copy button in a page-columns section"
format: html
reference-location: margin
---

## Section

```r
x <- 1
```

Text.[^1]

[^1]: Footnote.

The post-processor adds page-columns to the parent of any column element, so the section becomes a grid:

https://github.com/quarto-dev/quarto-cli/blob/360bb7245a549c03d9de3508f8af9f54acd42f18/src/format/html/format-html-bootstrap.ts#L1216-L1226

div.code-copy-outer-scaffold is then a grid item. A grid item does not let the margins of its children collapse through it, so the 1em top margin of div.sourceCode stays inside the scaffold, while the button is positioned at top: 0 of the scaffold.

Measured from the section top, same in Chromium, Firefox and WebKit:

Section Scaffold top div.sourceCode top Button top
Plain section 60.2 60.2 65.2
With a margin footnote or .column-margin div 94.2 111.2 99.2

A .cell in the same section is not affected, as the cell is the grid item and the margin collapses through the scaffold inside it.

Moving the 1em margin from div.sourceCode to the scaffold for every code block fixes the grid case, but adds 17px in tabsets and between a filename header and its code, as .tab-pane div.sourceCode and .code-with-filename div.sourceCode reset this margin on div.sourceCode. We could limit the change to scaffolds placed directly in a page-columns element.

Ngôn ngữ chính
JavaScript
Star
6.2k
Fork
492
Merge trung bình
15 giờ 15 phút
Pull request đã merge (30 ngày)
94

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của quarto-dev/quarto-cli

Tất cả issue của quarto-dev/quarto-cli

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.