Documentation
¶
Overview ¶
Package create makes HTML and other web resources from a text file.
Example (BytesStats) ¶
// Disable ANSI color output color.Enable = false fmt.Println(bytesStats("filename.txt", 0)) fmt.Println(bytesStats("filename.txt", 123)) fmt.Println(bytesStats("filename.txt", 1234567890))
Output: saved to filename.txt (zero-byte file) saved to filename.txt, 123B saved to filename.txt, 1.23 GB (1234567890)
Index ¶
- Variables
- func ColorScheme() [3]string
- func FontCSS(name string, e encoding.Encoding, embed bool) ([]byte, error)
- func Fonts() []string
- func Layouts() []string
- func Normalize(e encoding.Encoding, r ...rune) []byte
- func Port(port uint) bool
- func Referrer() [8]string
- func Robots() [9]string
- type Args
- type Font
- type Layout
- type Meta
- type PageData
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCleanPath = errors.New("cleanup temporary path match failed") ErrFileExist = errors.New("filename already exists") ErrFileNil = errors.New("filename cannot be empty") ErrFont = errors.New("unknown font name or family") ErrNilByte = errors.New("cannot convert a nil byte value") ErrPorts = errors.New("cannot run the http server using these ports") )
Functions ¶
func ColorScheme ¶
func ColorScheme() [3]string
ColorScheme values for the content attribute of <meta name="color-scheme">.
Example ¶
fmt.Print(ColorScheme()[0])
Output: normal
func Fonts ¶ added in v0.0.31
func Fonts() []string
Fonts are values for the CSS font-family attribute.
Example ¶
fmt.Print(Fonts()[2])
Output: vga
func Normalize ¶ added in v0.0.31
Normalize runes into bytes by making adjustments to text control codes.
Types ¶
type Args ¶
type Args struct { Source struct { Encoding encoding.Encoding // Original encoding of the text source HiddenBody string // Pre-text content override, accessible by a hidden flag Name string // Text source, usually a file or pack name } Save struct { AsFiles bool // Save assets as files Cache bool // Cache, when false will always unpack a new .gohtml template Compress bool // Compress and store all assets into an archive OW bool // OW overwrite any existing files when saving Destination string // Destination HTML destination either a directory or file } Title struct { Flag bool Value string } FontFamily struct { Flag bool Value string } Metadata Meta SauceData struct { Use bool Title string Author string Group string Description string Width uint Lines uint } Port uint // Port for HTTP server FontEmbed bool // embed the font as Base64 data Test bool // unit test mode Layout string // Layout of the HTML Syntax string // Syntax and color theming printing HTML // contains filtered or unexported fields }
Args holds arguments and options sourced from user flags and the config file.
type Font ¶ added in v0.0.31
type Font uint
Font enum.
func AutoFont ¶ added in v0.0.31
AutoFont applies the automatic font-family setting to suggest a font based on the given encoding.
type Layout ¶ added in v0.0.31
type Layout int
Layout are HTML template variations.
const ( // Standard template with external CSS, JS, fonts. Standard Layout // Inline template with CSS and JS embedded. Inline // Compact template with external CSS, JS, fonts and no meta-tags. Compact // None template, just print the generated HTML. None )
type Meta ¶ added in v0.0.31
type Meta struct { Author struct { Flag bool Value string } ColorScheme struct { Flag bool Value string } Description struct { Flag bool Value string } Keywords struct { Flag bool Value string } Referrer struct { Flag bool Value string } Robots struct { Flag bool Value string } ThemeColor struct { Flag bool Value string } Generator bool NoTranslate bool RetroTxt bool }
Meta data to embed into the HTML.
type PageData ¶
type PageData struct { ExternalEmbed bool FontEmbed bool MetaGenerator bool MetaNoTranslate bool MetaRetroTxt bool BuildVersion string CacheRefresh string Comment string FontFamily string MetaAuthor string MetaColorScheme string MetaDesc string MetaKeywords string MetaReferrer string MetaRobots string MetaThemeColor string PageTitle string PreText string SauceTitle string SauceAuthor string SauceGroup string SauceDescription string SauceWidth uint SauceLines uint CSSEmbed template.CSS ScriptEmbed template.JS }
PageData temporarily holds template data used for the HTML layout.
Click to show internal directories.
Click to hide internal directories.