shortcodes

package
v0.5.12 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FontAwesomeIconShortcode = Shortcode{
		Name: "fa-icon",
		InlineFn: func(node *Node, ctx beContext.Context) (output string) {
			class, _ := node.Attributes.Lookup["class"]
			classes := htmlcss.ParseClass(class)
			styles := make(map[string]string)

			if v, ok := node.Attributes.Lookup["fa-icon"]; ok && v != "" {
				if _, ignore := node.Attributes.Lookup["name"]; !ignore {
					node.Attributes.Set("name", v)
				}
			}

			faParseFamilyStyle(node, classes)
			faParseIconName(node, classes)
			faParseIconSize(node, classes)
			faParseFlipRotate(node, classes, styles)
			faParseFixedWidth(node, classes)
			faParseBorder(node, classes, styles)
			faParsePull(node, classes, styles)

			output += `<i`
			if v := classes.String(); v != "" {
				output += fmt.Sprintf(` class=%q`, v)
			}
			if len(styles) > 0 {
				s := ""
				for _, key := range maps.SortedKeys(styles) {
					s += key + ":" + styles[key] + ";"
				}
				output += fmt.Sprintf(` style=%q`, s)
			}
			output += `></i>`
			return
		},
	}
)

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