Background
I am creating the README.md for my GitHub repo ("MyRepo"), which provides certain VBA functionality. Here I wish to display a code snippet, which the user should paste into their own code.
Since this snippet enables the functionality, it is a crucial element of the project. As such, I maintain it modularly in src/Snippet.bas.
Goal
I am wish to combine the following features for the snippet in my README:
- The button
to copy the snippet with a single click. - The scrollable pane, which keeps the
READMEvisually uncluttered by the large snippet.
- The injection of code from an upstream source file.
- The dynamic injection of the latest code from that file.
- The relative reference (
src/Snippet.bas) to that file, rather than the unwieldy absolute (https://github.com/Greg/MyRepo/tree/HEAD/src/Snippet.bas). - The inclusion of the entire file, rather than a fixed section of it (
#L14-L22).
Issue
Unfortunately, (1) appears only for code samples written manually within ``` fences; and not for permalinks to the code. As for (2), it appears only for the permalinks; and not for the manually written samples.
While permalinks do achieve (3), they seem anchored to a specific commit, and thus fail at (4). Furthermore, it seems they require the absolute URL, and do not render the relative for (5). Finally, they are anchored rigidly lines (#L14-L22) within the file, and thus do not accommodate (6).
Question
Is there a way to achieve all (or more) of these features in GitHub Flavored Markdown, or in the HTML it permits? Or would this task require sophisticated GitHub Actions?
Alternatively, is there a URL parameter like copy, which automatically copies the linked file to the clipboard?
src/Snippet.bas?copy=1