figure

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 6 Imported by: 2

README

goldmark-figure

goldmark-figure Go reference goldmark-figure test results goldmark-figure Go report card

goldmark-figure is a goldmark extension to parse mardown paragraphs that start with an image into HTML <figure> elements. One nice thing is it doesn't use any new markdown syntaxes.

Example markdown source:

![Picture of Oscar.](/path/to/cat.jpg)
Awesome caption about **Oscar** the kitty.

Render result:

<figure>
    <img src="/path/to/cat.jpg" alt="Picture of Oscar." />
    <figcaption>Awesome caption about <strong>Oscar</strong> the kitty.</figcaption>
</figure>

Installation

go get github.com/mangoumbrella/goldmark-figure

Usage

import (
    "bytes"
    "fmt"

    "github.com/mangoumbrella/goldmark-figure"
    "github.com/yuin/goldmark"
)

func main() {
    markdown := goldmark.New(
        goldmark.WithExtensions(
            figure.Figure,
        ),
    )
    source := `
    ![Picture of Oscar.](/path/to/cat.jpg)
    Awesome caption about **Oscar** the kitty.
    `
    var buf bytes.Buffer
    if err := markdown.Convert([]byte(source), &buf); err != nil {
        panic(err)
    }
    fmt.Print(buf.String())
}

See figure_test.go for detailed usages.

LICENSE

MIT

Authors

Yilei Yang

Documentation

Overview

Copyright 2023 The goldmark-figure authors

Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.

Index

Constants

This section is empty.

Variables

View Source
var Figure = &extension{}

Figure is an extension to render <figure> elements.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL