hexojs / hexo-renderer-marked

Markdown renderer for Hexo
MIT License
179 stars 94 forks source link

Parse figcaption contents #286

Open neverbot opened 7 months ago

neverbot commented 7 months ago

Check List

Feature Request

When using the figcaption option,

marked:
  figcaption: true

generating images as

<figure>
  <img ... >
  <figcaption>...</figcaption>
</figure>

the figcaptions are usually intended to be rendered in some fancy way, including links or styles, etc.

I think it would be useful to parse its contents, changing from:

      return `<figure>${out}<figcaption aria-hidden="true">${text}</figcaption></figure>`;

to

      return `<figure>${out}<figcaption aria-hidden="true">${marked.parse(text)}</figcaption></figure>`;

If the figcaption has no special markdown, there is no difference. If we include some kind of markdown content, it will be parsed.

Additional context

No response

uiolee commented 4 months ago

the "Permitted content" of <figcaption> is Flow content. But the rendering result of markdown can be any content. It seems like this would make things more complicated.

neverbot commented 4 months ago

Could anybody break something using only markdown? And if they can... it's the user, they could be writing just bad html instead of bad markdown and parsing it (I am not sure I'm understanding the complications).

I've been using this change in a blog to add figcaptions with links to the original author of illustrations, think things like that would be useful.