1# goldmark-figure
 2
 3[![goldmark-figure Go reference](https://pkg.go.dev/badge/github.com/mangoumbrella/goldmark-figure.svg)](https://pkg.go.dev/github.com/mangoumbrella/goldmark-figure)
 4[![goldmark-figure test results](https://github.com/mangoumbrella/goldmark-figure/actions/workflows/test.yml/badge.svg?event=push)](https://github.com/mangoumbrella/goldmark-figure/actions/workflows/test.yml/badge.svg?event=push)
 5[![goldmark-figure Go report card](https://goreportcard.com/badge/github.com/mangoumbrella/goldmark-figure)](https://goreportcard.com/report/github.com/mangoumbrella/goldmark-figure)
 6
 7[goldmark-figure](https://github.com/MangoUmbrella/goldmark-figure) is a
 8[goldmark](http://github.com/yuin/goldmark)
 9extension to parse mardown paragraphs that start with an image into HTML
10`<figure>` elements. One nice thing is it doesn't use any new markdown
11syntaxes.
12
13Example markdown source:
14
15```md
16![Picture of Oscar.](/path/to/cat.jpg)
17Awesome caption about **Oscar** the kitty.
18```
19
20Render result:
21
22```html
23<figure>
24    <img src="/path/to/cat.jpg" alt="Picture of Oscar." />
25    <figcaption>Awesome caption about <strong>Oscar</strong> the kitty.</figcaption>
26</figure>
27```
28
29# Installation
30
31```
32go get github.com/mangoumbrella/goldmark-figure
33```
34
35# Usage
36
37```go
38import (
39    "bytes"
40    "fmt"
41
42    "github.com/mangoumbrella/goldmark-figure"
43    "github.com/yuin/goldmark"
44)
45
46func main() {
47    markdown := goldmark.New(
48        goldmark.WithExtensions(
49            figure.Figure,
50        ),
51    )
52    source := `
53    ![Picture of Oscar.](/path/to/cat.jpg)
54    Awesome caption about **Oscar** the kitty.
55    `
56    var buf bytes.Buffer
57    if err := markdown.Convert([]byte(source), &buf); err != nil {
58        panic(err)
59    }
60    fmt.Print(buf.String())
61}
62```
63
64See [`figure_test.go`](/figure_test.go) for detailed usages.
65
66# LICENSE
67
68MIT
69
70# Authors
71
72Yilei Yang