-
-
Notifications
You must be signed in to change notification settings - Fork 258
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
Per-snippet auto dedent #2217
Comments
I'm not sure I understand. The |
In one example, I am taking part of a JSON file's content, which I then surround to make a valid JSON file in the wiki: In this case, the snippet has indentations, and I don't need dedentation, so this is fine. Later, I needed to add a snippet that could be taken out of context, but since it has indents, I want to remove them, giving: But now that I enabled dedendation, my JSON snippet is also dedented, giving: So, currently, I need to keep dedentation disabled, and write the code surrounding the snippet, which becomes code that needs to be kept track of outside of the main repository |
In general, Snippets was never meant to be an advanced template language. The entire idea was just a "dumb" way to insert content from one source to another. I can see how it can be frustrating because you are wanting in one case to manipulate the content knowing the context, but in the other case have the context of indentation stripped out. Let me think about this and see if I can come up with an approach that I'm happy with. I don't think I'll go with the |
As mentioned, I do see what you are aiming for, and I do understand what the cause is. As previously stated, this was always meant to be just a dumb, simple inserter, but, when I have the time, if I can come up with a syntax I'm happy with, we can have per snippet auto-indent. |
We have a similar problem, but I don't think, there's a need to discuss whether it's a dumb or an intelligent templating language or whatever this is. I think, the whole point of the issue is: There are different kinds of files and for some, one wants auto dedention and for some, one doesn't, meaning, there needs to be a local option additionally to the global one.
Other options might include:
markdown_extensions:
- pymdownx.highlight
- pymdownx.snippets:
base_path: ['snippets']
dedent_subsections:
auto_dedentable: true
non_auto_dedentable: false
```{.json dedent_subsections=false}
--8<-- "my_json_file.json:40:42"
```
```json
--8<-- dedent_subsections=false
my_json_file.json:40:42
--8<--
```
|
My providing of context as to my goals for the extension and providing context as to why I want to limit the scope of the plugin are perfectly relevant. With that said, I've also already given my statement. If/when I come up with a syntax I'm happy with, I will implement it.
This ties snippets to the code block extensions. It is separate from that , so such interaction will not be supported. Snippets is a preprocessor run before code blocks so code blocks knowledge of whether specific lines are snippets or not will be lost. This is a non-starter.
This is limited to block format, but something to consider. Most likely I will extend the syntax in some form that works for both blocks and inline.
I probably won't go in this direction, but there may be some additional syntax we can add moving forward. |
Description
While the "Dedent subsections" feature is nice to extract code that don't need the entire context around it, it requires all snippets to be dedented, which then causes issues elsewhere.
For now, my workaround is to just put a stripped down version of the code surrounding it, but this goes against the idea that the snippets are maintained elsewhere, not in the wiki itself.
Benefits
This would allow to select which snippets get dedented while not affecting other snippet
Solution Idea
I think that the existing global option would dedent all snippets, but not using the global option would let the user decide on each snippet, by adding an
auto_dedent
next to the snippet lines/sectionExample:
--8<-- "https://github.com/freya022/BotCommands/raw/3.X/examples/src/main/kotlin/io/github/freya022/bot/commands/slash/SlashBan.kt:declare_aggregate-kotlin_dsl:auto_dedent"
The text was updated successfully, but these errors were encountered: