-
-
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
Snippets - Inserting markdown, is it possible to custom the level for inherited headers? #1052
Comments
I can already think of multiple corner cases that would break You would be better off implementing something like a relative header feature. I could see a Tree processor looking for any headers that have # Header Level 1
# Header Level 3 {: data-header-rel="2"}
# Header Level 4 {: data-header-rel="1"}
# Header Level 5 {: data-header-rel="1 -4"}
# Header Level 1 <h1>Header Level 1</h1>
<h3>Header Level 3</h3>
<h4>Header Level 4</h4>
<h5>Header Level 5</h5>
<h1>Header Level 1</h1> This would seem to avoid the pitfalls of @gir-bot remove S: triage |
Nice! Where could it be implemented in the source code? By there maybe: pymdown-extensions/pymdownx/snippets.py Line 62 in f121e08
|
Most likely, the best approach would be to create a separate TreeProcessor. It would run at a later time than the Snippet preprocessor. The snippet creator would need to doctor the headers as I mentioned earlier (and also enable the The TreeProcessor would execute right before |
When you write:
You mean, creating something like that somewhere in from markdown.treeprocessors import Treeprocessor
[...]
class SnippetTreeprocessor(Treeprocessor):
"""Snippet Treeprocessor.""" or inheriting directly from I'm asking a lot but it to determine if I'm feelling able to psuh a PR or not. |
Yes, in snippets. When called, it would probably exit immediately if attr_list is not enabled. |
Well, I take that back. It probably shouldn't care if |
I say this because you could probably do manual headers and it would work as well: <h2 data-header-rel="2">Header text</h2> |
I'm not positive I'm totally following the proposed solution, so please forgive the noise if what I'm saying doesn't make sense. But—looking at the implementation in (This is a great tool, thanks!) |
Currently, there is no support for special header logic. Snippets, in its current form, simply inserts the content where you reference it (indented appropriately). There has been no real decision yet on what the final solution will look like, assuming we implement it. |
When embedding a markdown file into another one, is there a way to control how headers are transformed? As performed in the markdown-include extension : https://github.com/cmacmackin/markdown-include#configuration.
If not, could it be a future feature?
The text was updated successfully, but these errors were encountered: