Documentation ¶
Overview ¶
Package for generating HTML files This includes HTML templates embedded in source for zero-config usage. Custom templates can be provided by setting the TemplateDir variable in the config.yaml file or the TEMPLATE_HOME env variable.
Index ¶
- func DecodeUsageExample(usageText string, headword dicttypes.Word, dictTokenizer tokenizer.Tokenizer, ...) string
- func MarkVocabLink(w dicttypes.Word, text, vocabFormat string) string
- func MarkVocabSummary(w dicttypes.Word, text, vocabFormat string) string
- func NewTemplateMap(appConfig config.AppConfig) map[string]*template.Template
- func WriteCollectionFile(colEntry *corpus.CollectionEntry, outputConfig HTMLOutPutConfig, ...) error
- func WriteCollectionList(colIEntries []corpus.CollectionEntry, analysisFile string, ...) error
- func WriteCorpusDoc(tokens []tokenizer.TextToken, vocab map[string]int, w io.Writer, ...) error
- func WriteDoc(tokens []tokenizer.TextToken, f io.Writer, tmpl template.Template, ...) error
- type CollectionListContent
- type CorpusEntryContent
- type CorpusEntryMeta
- type HTMLContent
- type HTMLOutPutConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeUsageExample ¶
func DecodeUsageExample(usageText string, headword dicttypes.Word, dictTokenizer tokenizer.Tokenizer, outputConfig HTMLOutPutConfig, wdict map[string]*dicttypes.Word) string
decodeUsageExample formats usage example text into links with highlight
Return marked up text with links and highlight
func MarkVocabLink ¶ added in v0.0.2
MarkVocabLink constructs a hyperlink for a headword, including Pinyin and English in the title attribute for the link mouseover
func MarkVocabSummary ¶ added in v0.0.2
MarkVocabSummary constructs a Summary HTML element for a headword.
func NewTemplateMap ¶
newTemplateMap builds a template map
func WriteCollectionFile ¶
func WriteCollectionFile(colEntry *corpus.CollectionEntry, outputConfig HTMLOutPutConfig, corpusConfig corpus.CorpusConfig, f io.Writer) error
WriteCollectionFile writes a HTML file describing the collection Parameters:
collectionFile: The name of the file describing the collection baseDir: The base directory for writing the file
func WriteCollectionList ¶ added in v0.0.5
func WriteCollectionList(colIEntries []corpus.CollectionEntry, analysisFile string, outputConfig HTMLOutPutConfig, f io.Writer) error
WriteCollectionList writes a HTML file listing all collections
func WriteCorpusDoc ¶
func WriteCorpusDoc(tokens []tokenizer.TextToken, vocab map[string]int, w io.Writer, corpusEntryMeta CorpusEntryMeta, sourceFormat string, outputConfig HTMLOutPutConfig, corpusConfig corpus.CorpusConfig, wdict map[string]*dicttypes.Word) error
WriteCorpusDoc writes a corpus document with markup for the array of tokens tokens: A list of tokens forming the document vocab: A list of word id's in the document filename: The file name to write to HTML template to use collectionURL: the URL of the collection that the corpus text belongs to collectionTitle: The collection title that the corpus entry belongs to aFile: The vocabulary analysis file written to or empty string for none sourceFormat: TEXT, or HTML used for formatting output
func WriteDoc ¶ added in v0.0.2
func WriteDoc(tokens []tokenizer.TextToken, f io.Writer, tmpl template.Template, glossChinese bool, title, vocabFormat string, markVocab func(dicttypes.Word, string, string) string) error
WriteDoc writes a document with markup for the array of tokens tokens: A list of tokens forming the document vocab: A list of word id's in the document f: The writer to write to GlossChinese: whether to convert the Chinese text in the file to markVocabs
Types ¶
type CollectionListContent ¶ added in v0.0.5
type CollectionListContent struct { ColIEntries []corpus.CollectionEntry DateUpdated, Title, AnalysisPage string }
CollectionListContent holds content for the template of a list of collections.
type CorpusEntryContent ¶
type CorpusEntryContent struct { // Page title Title string // Body text CorpusText string // Date that the content was updated DateUpdated string // A link to the connection of documents CollectionURL string // A title for the connection of documents CollectionTitle string // A title for this document EntryTitle string // Name of the file with analysis of this document AnalysisFile string // Name of file with bilingual parallel text ParallelTextFile string // Name of file with Chinese text, in case this is a bilingual or parallel file ChineseTextFile string }
CorpusEntryContent holds the content for a corpus entry to write to HTML
type CorpusEntryMeta ¶ added in v0.0.58
type CorpusEntryMeta struct { // A link to the connection of documents CollectionURL string // A title for the connection of documents CollectionTitle string // A title for this document EntryTitle string // Name of the file with analysis of this document AnalysisFile string // Name of file with bilingual parallel text ParallelTextFile string // Name of file with bilingual text BilingualTextFile string // Name of file with Chinese text, in case this is a bilingual or parallel file ChineseTextFile string }
CorpusEntryMeta holds metadata for a corpus entry
type HTMLContent ¶ added in v0.0.2
type HTMLContent struct {
Content, DateUpdated, Title, FileName string
Data interface{}
}
HTMLContent holds content for the template
type HTMLOutPutConfig ¶
type HTMLOutPutConfig struct { // Page title Title string // For rendering to HTML, if TemplateDir is not given Templates map[string]*template.Template // Used for selecting related words ContainsByDomain string // Domain that this corpus relates to, eg Modern Chinese Domain string // For linking to static assets, like CSS, etc GoStaticDir string // Containing a directory of Go templates, default to static templates if empty TemplateDir string // For formatting mouse over VocabFormat string // To write HTML files to WebDir string // Regex to match text in notes NotesReMatch string // Regex to replace text in notes NotesReplace string }
HTMLOutPutConfig holds parameters for writing output to HTML