markup/goldmark: Add removeSurroundingParagraph for Markdown images

* Removes any surrounding paragraph nodes
* And transfers any attributes from the surrounding paragraph down to the image node
* Adds IsBlock and Ordinal (zero based) field to the image context passed to the image render hooks

IsBlock is set to true if `wrapStandAloneImageWithinParagraph = false` and  the image's parent node has only one child.

Closes #8362
Fixes #10492
Fixes #10494
Fixes #10501
This commit is contained in:
Bjørn Erik Pedersen
2022-12-03 12:33:48 +01:00
parent 535ea8cc9b
commit 63126c6359
9 changed files with 469 additions and 24 deletions

View File

@@ -37,6 +37,12 @@ type LinkContext interface {
PlainText() string
}
type ImageLinkContext interface {
LinkContext
IsBlock() bool
Ordinal() int
}
type CodeblockContext interface {
AttributesProvider
text.Positioner