set max-width for images in markdown

main
jolheiser 2024-10-23 21:55:31 -05:00
parent 3a4e09a218
commit 0f4b6ec936
No known key found for this signature in database
1 changed files with 1 additions and 0 deletions

View File

@ -112,6 +112,7 @@ func (a astTransformer) Transform(node *ast.Document, _ text.Reader, pc parser.C
case *ast.Image:
link := v.Destination
if len(link) > 0 && !bytes.HasPrefix(link, []byte("http")) {
v.SetAttributeString("style", []byte("max-width:100%;"))
v.Destination = []byte(resolveLink(ctx.repo, ctx.ref, ctx.path, string(link)) + "?raw&pretty")
}