Skip to content

Feature: download button for code blocks#32

Open
joapuiib wants to merge 1 commit intojaywhj:mainfrom
joapuiib:feat/download-code-blocks
Open

Feature: download button for code blocks#32
joapuiib wants to merge 1 commit intojaywhj:mainfrom
joapuiib:feat/download-code-blocks

Conversation

@joapuiib
Copy link
Copy Markdown
Contributor

@joapuiib joapuiib commented Apr 6, 2026

This PR adds a download button to the code blocks following this syntax:

```lang {data-download="1" title="custom-title.txt"}
Content
```
  • Blob downloads data-download="1": Download the code block content. The filename suggested to the browser is resolved in the following order of priority:
    • data-download-filename attribute on the code block
    • title option on the code block
    • Fallback: download.txt
```lang {data-download="https://github.com/user/project/blob/main/project/file.ext"}
Content
```
  • URL downloads data-download=url: Create a link button with a download attribute. The filename suggested to the browser is resolved in the following order of priority:
    • data-download-filename attribute on the code block
    • title option on the code block
    • Last path segment of the URL
    • Fallback: download.txt


Code block buttons now handle translations properly (code.select translation was missing).
English and Catalan translations are updated with this changes.

@joapuiib
Copy link
Copy Markdown
Contributor Author

joapuiib commented Apr 6, 2026

I've set version 10.1.4 version in the docs since I don't think this will merged soon.
Nevertherless, I can change it to any version.

@joapuiib joapuiib marked this pull request as ready for review April 6, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant