-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow fetching code blocks from external source, display reference in code block title #304
Comments
Hi! Thanks for using tabi and for requesting this cool feature. I like the idea. I've got a prototype shortcode which does exactly as you request. Will update soon! |
Amazing! Thank you for writing Tabi :) |
Thank you! I'm glad to hear :) The feature is added in #305. It's almost exactly what you requested; to place the code in a code block, you need to add the backticks and language manually. This is necessary so that Zola can handle the syntax highlighting. The docs should clarify the usage. Let me know whether this works for your or if you encounter any issues! Cheers EDIT: Just realised I didn't add the "Show source" part. I'll think about how to implement this. |
Thanks! Yep, I was able to make something similar, but without the source reference, too. I think it's an important part of this feature, it would be great if you could figure it out :) |
Adding the source to the codeblock is easy enough with CSS. The challenge is making the URL clickable without JavaScript—I don't think it's possible. Do you think this feature is important enough to warrant loading an extra (small) JS file? Would it be enough to show the path/URL, even if it's not clickable? |
I think we can start with just displaying it (can it have a copy button?) and add the other part later. Honestly, my CSS/HTML/JS knowledge is close to zero, so I don't know what exactly has to be done to enable it. |
Adding a "copy" option to the source would require JS too. The thing is I'm not a big fan of JavaScript. The feature you are requesting is impossible to do without it, though, as we can't modify the HTML of codeblocks; Zola auto-renders them. That's why I was asking how important the feature was. It's a simple enough change, so I'll add it soon. |
Turns out it's not as easy.
The only solution I see right now is to create another shortcode like This means adding two shortcodes per codeblock with visible source, in the right order, with the same data. Plus, loading the JS file to handle the "joining" of data. |
Alright, great! Do you think we should also have an option to override the displayed source path with something else? For example, the desired file location could be displayed instead of the original source path, indicating that this code block contents should be placed in the desired path. |
The
|
It's done in #307. Not a fan of the JavaScript + shortcode + shortcode setup, but it's the best we can do given the constraints. Check out the documentation and give it a go! Let me know whether it works for you or if you encounter any issues. Cheers |
Thanks for letting me know! Should be fixed with f081a92 |
Feature Request
Summary
I am writing a blog post which includes a lot of code blocks.
I would like to:
I tried searching for solutions, but was not able to find anything working.
Motivation
Such feature will allow to:
I believe this should be a very common problem for blog posts with heavy use of code.
Detailed Description
Perhaps, a
code_block_source
shortcode could be implemented, which could be used like this:This shortcode would fetch the
source
contents, render it with syntax highlighting, and add a clickablesource
reference to the code block (I believe it can be shown before thecopy
button, or after the language title).The
source
argument should accept both local paths and external URLs.The text was updated successfully, but these errors were encountered: