Closed mcdemarco closed 3 years ago
More info from Discord:
It appears that the JavaScript being used in the Cookbook to do magic stuff with the Left Table of Contents is interfering with 'download' related links.
As a short term fix either:
- Right Mouse Button (RMB) click on the Example Download link and choose whatever your web-browser names the the 'Open link in new Tab' context menu item.
- Middle Mouse Button (MMB) click on the Example Download link, which also causes the linking HTML file to be opened in a 'new tab'. -- @Greyelf#9751
Reloading the page after the broken pages is shown also seems to fix the link and serve the correct file.
A possible fix is to add a target attribute to the link. To archive this attribute lists would be required. Those are not supported by github, though:
[Download](#){: target='_top' download}
Download{: target='_top' download}
The download attribute advises browsers, that support it to download the file instead of displaying it.
Based on what @PakL proposed, here are the changes needed:
1) Enable the "attribute lists" (attr_list) extension in MkDocs through adding it to the mkdocs.yml
file:
markdown_extensions:
- admonition
- attr_list
- codehilite:
guess_lang: false
- toc:
permalink: "#"
2) Edit every file with a download link to have new attributes. For example, for the Chapbook: Adding Functionality page, there would be two changes:
...
[Download Example](chapbook_adding_functionality_example.html){: target='_top' download="chapbook_adding_functionality_example.html"}
...
[Download Twee Code](chapbook_adding_functionality_twee.txt){: target='_top' download="chapbook_adding_functionality_twee.txt"}
Started work on fixing examples. Here is what remains:
I wrote a script to do this automatically for me so it was easier to start completely from scratch. It's possible some links were missed as the script only targeted markdown links with "download" in the link text.
When I click a download link, e.g., https://twinery.org/cookbook/deletingvariables/snowman/snowman_deletingvariables_example.html I get a malformed page instead of a download. It looks like this:
I had this issue in the latest Chrome on a Mac, as well as in Safari 12.1. No client-side errors are reported by Chrome.
I tried a few similar downloads, not all for Snowman examples, and they did the same thing.