- Have got upload images appearing in the post list - Allowed for deleting uploads - Allowed for seeing the upload progress - Fixed the setting of upload properties like the MIME type - Removed the stripe exif logic with just re-encoding PNGs and JPEGs by loading them and saving them
28 lines
546 B
Go
28 lines
546 B
Go
package markdown
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/PuerkitoBio/goquery"
|
|
)
|
|
|
|
type htmlTransform func(ctx context.Context, dom *goquery.Document) error
|
|
|
|
func applyTransforms(ctx context.Context, inHTML string, transforms []htmlTransform) string {
|
|
dom, err := goquery.NewDocumentFromReader(strings.NewReader(inHTML))
|
|
if err != nil {
|
|
return inHTML
|
|
}
|
|
for _, transform := range transforms {
|
|
if err := transform(ctx, dom); err != nil {
|
|
return inHTML
|
|
}
|
|
}
|
|
res, err := dom.Html()
|
|
if err != nil {
|
|
return inHTML
|
|
}
|
|
return res
|
|
}
|