figures

package module
v0.0.0-...-5a82ef3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2021 License: MIT Imports: 5 Imported by: 0

README

goldmark-figures

GoDoc

This goldmark parser extension adds paragraph image render as figure.

An image with nonempty alt text, occurring by itself in a paragraph, will be rendered as a figure with a caption. The image’s alt text will be used as the caption.

![**Figure:** [description](/link)](image.png "title")
<figure>
<img src="image.png" alt="Figure: description" title="title">
<figcaption><strong>Figure:</strong> <a href="/link">description</a></figcaption>
</figure>

If you just want a regular inline image, just make sure it is not the only thing in the paragraph. One way to do this is to insert a nonbreaking space after the image:

![This image won't be a figure](/url/of/image.png)\

This syntax is borrowed from Pandoc.

Documentation

Overview

Package figures is a extension for the goldmark (http://github.com/yuin/goldmark).

This extension adds html render for paragraph with image output as figure.

An image with nonempty alt text, occurring by itself in a paragraph, will be rendered as a figure with a caption. The image’s alt text will be used as the caption.

![**Figure:** [description](/link)](image.png "title")

This syntax is borrowed from [Pandoc](https://pandoc.org/MANUAL.html#images).

If you just want a regular inline image, just make sure it is not the only thing in the paragraph. One way to do this is to insert a nonbreaking space after the image:

![This image won't be a figure](/url/of/image.png)\
Example
package main

import (
	"log"
	"os"

	figures "github.com/mdigger/goldmark-figures"
	"github.com/yuin/goldmark"
)

func main() {
	var source = []byte(`
![**Figure:** [description](/link)](image.png "title")

![](image.png "title")

![**Figure:** [description](/link)](image.png "title")
![**alt**](image.png "title")
`)
	var md = goldmark.New(figures.Enable)
	err := md.Convert(source, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}
Output:

<figure>
<img src="image.png" alt="Figure: description" title="title">
<figcaption><strong>Figure:</strong> <a href="/link">description</a></figcaption>
</figure>
<p><img src="image.png" alt="" title="title"></p>
<p><img src="image.png" alt="Figure: description" title="title">
<img src="image.png" alt="alt" title="title"></p>

Index

Examples

Constants

This section is empty.

Variables

Enable is a goldmark.Option with image figures support.

View Source
var Extension goldmark.Extender = new(extension)

Extension is a goldmark.Extender with markdown image figures support.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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