Documentation
¶
Overview ¶
青空文庫注記のファイルから抽象構文木(AST)を抽出し、そこから各種形式に直列化するライブラリ及びコマンドラインツールです。今のところ、出力はLaTeX、HTML(及びにそれをもとにしたEpubとAZW3)、青空文庫形式風テキストファイル、JSONに対応しています。AST経由なので他の直列化形式に対応することも比較的簡単です。
Index ¶
- Variables
- func ConvertMKT(mkt string) (s string, err error)
- func ListProcessedTokens(text string) string
- func ListRawTokens(text string) string
- func RenderAozoraText(ast *Node, w *strings.Builder) (err error)
- func RenderHTML(ast *Node, w *strings.Builder) (err error)
- func RenderHTMLFull(ast *Node, w *strings.Builder) (err error)
- func RenderJSON(ast *Node, w *strings.Builder) (err error)
- func RenderLaTeX(ast *Node, w *strings.Builder) (err error)
- func RenderLaTeXFull(ast *Node, w *strings.Builder) (err error)
- func RenderNavHTML(ast *Node, w *strings.Builder) (err error)
- func Serialize(n *Node, w *strings.Builder, ...)
- func SerializeDescendants(n *Node, w *strings.Builder, ...)
- func SetCorrectionLog(out io.Writer)
- func SetFragment(v bool)
- func SetFullUnicode()
- func SetJIS0208()
- func SetJIS0213()
- func SetMessageLog(out io.Writer)
- func SetParsable(v bool)
- func SetRubyEmph(v bool)
- func SetStrict(v bool)
- func SetVerbose()
- func ToHiragana(r rune) rune
- func ToSJIS(text string) string
- func ToUTF8(data []byte) string
- type Book
- func (b *Book) EmbedImages()
- func (b *Book) GetURI() string
- func (b *Book) RenderAZW3() []byte
- func (b *Book) RenderEpub() []byte
- func (b *Book) RenderMonolithicHTML() []byte
- func (b *Book) RenderPackage(format string) []byte
- func (b *Book) SetCreator(c string)
- func (b *Book) SetMetadataFromText()
- func (b *Book) SetPublisher(p string)
- func (b *Book) SetTitle(t string)
- func (b *Book) SetURI(l string)
- type CharTypeID
- type Node
- func (n *Node) AddContributor(name string)
- func (n *Node) Children() []*Node
- func (n *Node) ClearChildren()
- func (n *Node) ClearMetadata()
- func (n *Node) HasChild() bool
- func (n *Node) IsLastSibling() bool
- func (n *Node) NestingLevel() int
- func (n *Node) Parent() *Node
- func (n *Node) Remove()
- func (n *Node) SetAttr(key string, val string)
- func (n *Node) SetSubtitle(subtitle string)
- func (n *Node) SetTitle(title string)
- func (n *Node) Siblings() []*Node
- func (n *Node) String() string
Constants ¶
This section is empty.
Variables ¶
var AozoraCSS string
AozoraCSS is the default CSS to be used with HTML files rendered through aozoraconvert.
var LaTeXdefinitions string
LaTeXdefinitions contains the default definitions of commands and environments for LaTeX output.
Functions ¶
func ConvertMKT ¶
ConvertMKT returns the unicode string corresponding to the JIS code point given in the 面区点(men-ku-ten) format. mkt needs to be formatetted as a string of the form "d-dd-dd".
func ListProcessedTokens ¶
ListProcessedTokens lists the tokens after preparation for parsing.
func ListRawTokens ¶
ListRawTokens lists the tokens returned through the initial tokenization.
func RenderAozoraText ¶
RenderAozoraText renders ast as a string formatted in the style of Aozorabunko.
func RenderHTML ¶
RenderHTML renders ast as an html fragment.
func RenderHTMLFull ¶
RenderHTMLFull renders ast as a full HTML file including doctype declararation and head element.
func RenderJSON ¶
RenderJSON renders ast in JSON format.
func RenderLaTeX ¶
RenderLaTeX renders ast as a LaTeX fragment.
func RenderLaTeXFull ¶
RenderLaTeXFull renders ast as a whole compileable LaTeX document. You will need to use the uplatex engine.
func RenderNavHTML ¶
RenderNavHTML returns the table of contents for the text given by ast. TOC is formatted as an html ordered list.
func Serialize ¶
Serialize AST given by n as a string. ingressFunc controls output when entering a node, egressFunc controls the output when exiting a node.
func SerializeDescendants ¶
func SerializeDescendants(n *Node, w *strings.Builder, ingressFunc, egressFunc func(*Node, *strings.Builder))
SerializeDescendants leaves out the top node n in serializing.
func SetCorrectionLog ¶
SetCorrectionLog sets the output destination regarding automatic correction made while parsing in a non-strict way.
func SetFragment ¶
func SetFragment(v bool)
SetFragment controls whether input should be treated as a full aozorabunko text or just a fragment.
func SetFullUnicode ¶
func SetFullUnicode()
SetFullUnicode sets output to allow the full range of unicode codepoints.
func SetMessageLog ¶
SetMessageLog sets the output destination for general messages from parser and renderer.
func SetParsable ¶
func SetParsable(v bool)
SetParsable sets output to a parsable form if v is true. Only useful for text output.
func SetRubyEmph ¶
func SetRubyEmph(v bool)
SetRubyEmph sets whether ruby are handled as text-emphasis or as ruby (only relevant for (X)HTML output).
func SetStrict ¶
func SetStrict(v bool)
SetStrict tells the parser whether fixable errors in the input file should abort the parsing.
func SetVerbose ¶
func SetVerbose()
func ToHiragana ¶
ToHiragana converts r to hiragana (iff. r is katakana)
Types ¶
type Book ¶
type Book struct {
Title, Creator, Publisher string
Files []fileData
UUID string
Body *Node
URI string
Images []records.ImageRecord
CSS string
Hash string
DateMod string
TxtFileName string
}
Book represents a book from Aozora Bunko
func NewEbookFromZip ¶
NewEbookFromZip returns Book from dz which must be zip archive containing the Aozorabunko text and any needed graphics files.
func (*Book) EmbedImages ¶
func (b *Book) EmbedImages()
EmbedImages embeds the image data in the relevant nodes in the ast of b.l
func (*Book) RenderEpub ¶
RenderEpub returns b as a zipped Epub file.
func (*Book) RenderMonolithicHTML ¶
RenderMonolithicHTML returns the book with the images embedded into the HTML.
func (*Book) RenderPackage ¶
RenderPackage returns a zip package for the given format
func (*Book) SetMetadataFromText ¶
func (b *Book) SetMetadataFromText()
SetMetadataFromText sets metadata from text.
func (*Book) SetPublisher ¶
SetPublisher sets the publisher to p.
type CharTypeID ¶
type CharTypeID int
CharTypeID represents character types.
const ( Symbol CharTypeID = 1 << iota //Symbol captures everything that isn't captured by the other categories. Hiragana Katakana Kanji Whitespace Punctuation Roman )
Define charater types.
func (CharTypeID) String ¶
func (i CharTypeID) String() string
type Node ¶
Node represents a node in an AST.
func AST ¶
AST returns the root node of the AST for data. data should be a properly formatted Aozorabunko text. If not, it will probably panic.
func (*Node) AddContributor ¶
AddContributor adds a contributor
func (*Node) Children ¶
Children returns the children of n in order as a slice, starting with the the first child of n.
func (*Node) ClearMetadata ¶
func (n *Node) ClearMetadata()
ClearMetadata clears the metadata node of n.
func (*Node) IsLastSibling ¶
IsLastSibling returns whether or not n has any further siblings.
func (*Node) NestingLevel ¶
NestingLevel returns the nesting level of n
func (*Node) Remove ¶
func (n *Node) Remove()
Remove removes the node. After remove, n will have no siblings, and no parent.
func (*Node) SetSubtitle ¶
SetSubtitle sets the subtitle.
func (*Node) SetTitle ¶
SetTitle sets the title of n to title. n must have a child node with Attr["type"]=="metadata"
Source Files
¶
- accents.go
- api.go
- chartypeid_string.go
- debug.go
- doc.go
- ebooks.go
- ebooksRender.go
- encoding.go
- fixTokenString.go
- global.go
- htmlTags.go
- jisx0213data.go
- jptools.go
- latexTags.go
- log.go
- nodes.go
- parser.go
- parserHelper.go
- renderAozoraText.go
- renderAzw3HTML.go
- renderEpubHTML.go
- renderHelpers.go
- renderHtml.go
- renderHtmlMonolithic.go
- renderJson.go
- renderLaTex.go
- serialize.go
- tokenizer.go
- tokenizerHelpers.go
- tokens.go
- tokentype_string.go
- utils.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
aozoraConvert
command
|
|
|
Package mobi implements writing KF8-style formatted MOBI and AZW3 books.
|
Package mobi implements writing KF8-style formatted MOBI and AZW3 books. |
|
jfif
Package jfif implements writing JPEG images with fixed JFIF header.
|
Package jfif implements writing JPEG images with fixed JFIF header. |
|
pdb
Package pdb implements reading and writing PalmDB databases.
|
Package pdb implements reading and writing PalmDB databases. |
|
records
Package records contains facilities to create MOBI formatted books.
|
Package records contains facilities to create MOBI formatted books. |
|
types
Package types contains types and constants to create MOBI formatted books.
|
Package types contains types and constants to create MOBI formatted books. |