Replies: 9 comments 114 replies
-
I will be honest, I actually do have captions on my radar and something I've been considering implementing. My goals might be slightly different.
I'm not sure that I get the multiple captions requirement. I have never seen this in the wild and I'm not convinced it is particularly helpful. I think a syntax that allows complex, multi-paragraph captions if required is sufficient. I imagine a simple syntax is sufficient:
Anyway, so yeah, it's been on my mind as something I was planning to implement, but the specifics I hadn't yet settled on yet. |
Beta Was this translation helpful? Give feedback.
-
Wouldn't it make more sense to nest figure stuff in this case?
The reason I question this is because this is a bit niche. Nothing is wrong with this approach, but If I were going to provide an extension that does captions, my goal is to simplify the approach and complexity to make it accessible and not too confusing. This would make prefixing less confusing. Otherwise, you need to make special rules where maybe only last caption gets prefixed (or if you prefer to have captions precede content, then only the first). I would probably want to encourage this approach (nesting) for simplicity. I think it makes things easier to manage and simpler for people to understand. I'm considered another approach as well which might make this easier by just following a block with a caption. The caption would be applied to the preceding block content automatically:
If you had multiple captions, the next caption would be applied to the figure, nesting the caption content automatically.
My only concern with this approach is whether Python Markdown will always have the previous block properly visible. Fenced code uses placeholders, so I'd have to test how this works in practice, but if it does, this would simplify the approach to something pretty easily understandable. |
Beta Was this translation helpful? Give feedback.
-
I won't rule out the idea of multiple captions, but I think there are ways to handle it without needing multiple captions under one figure. At least that is my initial thought. |
Beta Was this translation helpful? Give feedback.
-
I'll post this here on a different thread in order not to mix topics. Looking at markdown-it-figure, I see that the <figure id="figure-1234">
<img src="/images/foo.png" alt="Alt Text" />
<figcaption>
<p>
<span class="figure-id">1234: </span>
Caption
</p>
</figcaption>
</figure> Would this be interesting to have it here? |
Beta Was this translation helpful? Give feedback.
-
Starting a new thread. So I refactored the extension and tried to simplify some things.
Hopefully, with the new flexibility, everything that is needed can be achieved. I realize that I walked back some things, but I did so after considering the interaction based on the new refactor. I'm obviously open to discussing anything that was moved out that we feel may need to come back if a reasonable use case is provided. The PR was updated with the latest changes. |
Beta Was this translation helpful? Give feedback.
-
I'm bringing this again:
I want to migrate the following page Model ER to mkdocs. As you can see, there are a lot of images in this material. Each section has a main figure, that explains the usage of an ER diagram in a generic way. Also, it has some examples. In order to have some order in figure numbering, I was thinking of "nesting" figures by section: ## Section
Some text.
![Generic image](url)
/// figure-caption
attrs: {class: "attribution"}
Attribution
///
/// figure-caption| 1
Caption generic
///
//// example
Some example text.
![Example 1](url)
/// figure-caption | 1.1
Example 1 caption
///
////
//// example
Some example text.
![Example 2](url)
/// figure-caption | 1.2
Example 2 caption
///
//// In this case, I need to use manual mode, but maybe other pages doesn't need manual, and I wouldn't like to lose I hope this example makes sense. |
Beta Was this translation helpful? Give feedback.
-
Yeah sorry, I meant per-type. - pymdownx.blocks.caption:
auto: true
auto_level: 1
types:
- caption
- name: figure-caption
prefix: "Figura {}."
- name: "table-caption"
prefix: "Taula {}."
- name: "figure-manual-caption"
auto: false # This will override extension `auto`
prefix: "Figura {}."
With this config, If I need a specific numbering, I can use
As each type is different, and the counters are independent. They are not affected by each other, and it's possible to use each one of them all based on your needs.
The point of this example is that if I would like to use manual mode in a specific case (regardless of the nature), I will need to give up on |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm testing manual depth In this case, I would like that the nested attribution didn't have a prefix prepended, but the virtual nested did. - pymdownx.blocks.caption:
auto: true
auto_level: 2 ![Image](https://via.placeholder.com/150)
/// figure-caption
attrs: {class: "attribution"}
Attribution
///
/// figure-caption
Caption for image
///
![Image](https://via.placeholder.com/150)
/// figure-caption | ^1
Virtual nested caption
/// Setting |
Beta Was this translation helpful? Give feedback.
-
I don't know if it's too late to address this, but the caption syntax Using |
Beta Was this translation helpful? Give feedback.
-
Hello,
I was thinking about a customizable and easy way for writing images with captions in markdown.
I've come across the
markdown_captions
extension, which is simple and works quite well. Basically, it gets the alt text from the image and transforms it in a<figure>
element.From their documentation:
Nevertheless, in my opinion, it's not customizable.
A set of features that I would love to have are:
<figure>
.class
attribute to each<figcaption>
(for styling purposes).id
attribute to<figure>
, that could be set manually or automatically (inspired by markdown-it-figure)<figure>
, likeFigure %d:
, where%d
its a numerical value.<figcaption>
.So, a possible way to implement this would be to write a
Blocks Extension
, similar toDefinition
.This would mean that we could provide a flexible syntax that allowed such features and customizations.
I haven't thought a lot about the syntax, but it could be something like:
So, I'm writing this discussion for two main reasons.
First, since I think using the Blocks Extension could be a solution, I would like to know your opinion about this: how to approach it, possible challenges, etc...
Secondly, I'm not asking this feature to be available in
pymodwn-extensions
. I'm willing to try to implement it and maintain it in a separate package, BUT, if you think this extension could be useful for more users, I'm willing to collaborate in it in this project.Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions