Button to copy codeblock content

Use case or problem

Obsidian code blocks have a very handy “Copy” button in their top-right corner.

Unfortunately, this feature doesn’t seem to currently apply to Obsidian Publish sites (there’s no “Copy” button for code blocks on published sites).

It would be great if support could be added.

My particular use case: I’m an open source author, and in the process of migrating the documentation for several libraries to an Obsidian Publish site. Developer documentation naturally has a lot of code blocks, and making these easy for readers to copy would benefit the users and help motivate other open source authors to likewise consider Obsidian Publish for hosted documentation.

Thanks, cheers!

2 Likes

I support this as well. I’m not a software developer, but I often make notes about how to update or do something on my system, and also include snippets of code or something like BibTeX. Being able to click to copy code blocks would be a welcome improvement.

Use case or problem

Locally, I can see the copy button


or

but not when it’s published to Obsidian Publish, which is not ideal when others want to copy that block.

Proposed solution

Make it mirror what happens locally.

Current workaround (optional)

I don’t know any.
If there’s one, I would be interested in knowing, yet I still think that the experience locally should be mirrored when published.