Documentation
¶
Index ¶
Constants ¶
View Source
const ( CSSClassUnknownCustom = `gem-unknown-element` CSSClassText = `gem-text` CSSClassLink = `gem-link` CSSClassLinkRocket = `gem-link-rocket` CSSClassPreformattedText = `gem-preformatted-text` CSSClass1stHeader = `gem-header-1` CSSClass2ndHeader = `gem-header-2` CSSClass3rdHeader = `gem-header-3` CSSClassUnorderedList = `gem-list-unordered` CSSClassQuote = `gem-quote` )
CSS Classes for the default element types
Variables ¶
View Source
var LineHeading1 = HTMLElement{ Tags: []string{"h1"}, Class: CSSClass1stHeader, }
View Source
var LineHeading2 = HTMLElement{ Tags: []string{"h2"}, Class: CSSClass2ndHeader, }
View Source
var LineHeading3 = HTMLElement{ Tags: []string{"h3"}, Class: CSSClass3rdHeader, }
View Source
var LineLink = HTMLElement{ Tags: []string{"a"}, Class: CSSClassLink, Prefix: "<b class='" + CSSClassLinkRocket + "'>=> </b>", Suffix: "<br>", MetaWriter: func(tag string, metas map[gemtext.MetaType]string) string { return "href='" + metas[gemtext.LinkRef] + "'" }, }
View Source
var LinePreformattedText = HTMLElement{ Tags: []string{"pre"}, Class: CSSClassPreformattedText, Linebreak: true, MetaWriter: func(tag string, metas map[gemtext.MetaType]string) string { if metas[gemtext.PreformattedTextAlttext] == "" { return "" } return "title='" + metas[gemtext.PreformattedTextAlttext] + "'" }, }
View Source
var LineQuote = HTMLElement{ Tags: []string{"blockquote"}, Class: CSSClassQuote, Linebreak: true, JoinAdjacent: true, }
View Source
var LineText = HTMLElement{ Tags: []string{"p"}, Class: CSSClassText, JoinAdjacent: true, Linebreak: true, }
View Source
var LineUnorderedList = HTMLElement{ Tags: []string{"ul"}, Class: CSSClassUnorderedList, Linebreak: true, JoinAdjacent: true, AlwaysTags: []string{"li"}, }
Functions ¶
This section is empty.
Types ¶
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
func NewFormatter ¶
func NewFormatter(fc FormatterConf) (*Formatter, error)
func (*Formatter) FormatString ¶
func (f *Formatter) FormatString(r gemtext.LineReader) (string, error)
FormatString writes a parsed gemtext file into html and returns a string See FormatWriter for more documentation
func (*Formatter) FormatWriter ¶
FormatWriter writes a parsed gemtext file into html the html header, footer, and stylesheets is left up to the caller to handle
type FormatterConf ¶
type HTMLElement ¶
type HTMLElement struct {
// the html tags used (in order of highest to lowest)
Tags []string
// the css class given to an instance of this
// (only given to the top level tag if more than 1 is used)
Class string
// whether or not it will merge the tags with the next and previous tags
JoinAdjacent bool
// AdjacentTags are html takes like the ones in tags but are repeated
// for every line regardless of JoinAdjactent
AlwaysTags []string
// print a linebreak before and after the line content?
Linebreak bool
// suffix the result with this
Suffix string
// prefix the result with this
Prefix string
// a small function that decides how to write the other meta tags
// such as for links
MetaWriter func(tag string, metas map[gemtext.MetaType]string) string
}
HTMLElement writes an html element from a gemtext block with some metadata
func (HTMLElement) Write ¶
func (h HTMLElement) Write(w io.Writer, l gemtext.Line, r LineReader) (err error)
Click to show internal directories.
Click to hide internal directories.