Skip to content
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

Support for relative paths and line ranges in remote_text shortcode #397

Closed
apirogov opened this issue Sep 21, 2024 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@apirogov
Copy link

Feature Request

Summary

The remote_text shortcode is insanely useful, because I prefer having a source file with code and not copy it into the markdown. However, I did not find a way to use the shortcode with a relative path, I have to use it like

```python
{{ remote_text(src="/content/blog/article_name/code_file.py") }}
```

Instead, I would like to be able to write

```python
{{ remote_text(src="code_file.py") }}
```

Ideally I could do something like:

```python
{{ remote_text(src="../../some_location/code_file.py" start=10 end=20) }}
```

as is supported (with some pretty weird syntax) by e.g. pymdown.extensions for mkdocs.

Motivation

The relative path feature would make renaming the article/its directory much easier and less error-prone. I tend to colocate the source files with more complex articles, and I tend to rename the article multiple times before its done (I follow a YYYY-MM-DD-article-name-slug directory naming scheme to have a chronological order, and I often need to e.g. fix up the date).

The line range feature would be super useful both for reusing text sections on different pages, or to have different parts of the source file added in an article with paragraphs of text in between with explanations etc.


Unrelated to the issue, just wanted to say thanks for creating this awesome template! In the recent updates tabi and zola got all the features that I had to hack in before with a bunch of workarounds and copy-pasted snippets, but recently I updated to the most recent version and was happy to see that I do not need any custom hacks anymore, everything is configurable to my needs without much effort :)

@welpo
Copy link
Owner

welpo commented Sep 22, 2024

Hey @apirogov!

I've added support for relative paths in #398 and support for line ranges in #399. Let me know if you encounter any issues!


Thanks for the kind words. I'm happy to hear tabi works for you~

In the future, feel free to share your hacks as PRs or feature requests! Even if incomplete; I'm sure we could make use of them.

@welpo welpo closed this as completed Sep 22, 2024
@apirogov
Copy link
Author

Perfect, thanks a lot! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants