Documentation ¶
Index ¶
- Constants
- func CleanAttributeValue(v string) string
- func EscapeHTML(s string) string
- func FilePathFromPageCoverURL(uri string, block *notionapi.Block) string
- func GetBlockColorClass(block *notionapi.Block) string
- func HTMLFileNameForPage(page *notionapi.Page) string
- func ToHTML(page *notionapi.Page) []byte
- type BlockRenderFunc
- type Converter
- func (c *Converter) A(uri, text, cls string)
- func (c *Converter) DefaultRenderFunc(blockType string) func(*notionapi.Block)
- func (c *Converter) FormatDate(d *notionapi.Date) string
- func (c *Converter) GetInlineContent(blocks []*notionapi.TextSpan) string
- func (c *Converter) IsNextBlockOfType(t string) bool
- func (c *Converter) IsPrevBlockOfType(t string) bool
- func (c *Converter) NextBlock() *notionapi.Block
- func (c *Converter) NoIndentPrintf(format string, args ...interface{})
- func (c *Converter) PageByID(pageID string) *notionapi.Page
- func (c *Converter) PopBuffer() *bytes.Buffer
- func (c *Converter) PrevBlock() *notionapi.Block
- func (c *Converter) Printf(format string, args ...interface{})
- func (c *Converter) PushNewBuffer()
- func (c *Converter) RenderAlias(block *notionapi.Block)
- func (c *Converter) RenderAudio(block *notionapi.Block)
- func (c *Converter) RenderBlock(block *notionapi.Block)
- func (c *Converter) RenderBookmark(block *notionapi.Block)
- func (c *Converter) RenderBreadcrumb(block *notionapi.Block)
- func (c *Converter) RenderBulletedList(block *notionapi.Block)
- func (c *Converter) RenderCallout(block *notionapi.Block)
- func (c *Converter) RenderCaption(block *notionapi.Block)
- func (c *Converter) RenderChildren(block *notionapi.Block)
- func (c *Converter) RenderCode(block *notionapi.Block)
- func (c *Converter) RenderCodepen(block *notionapi.Block)
- func (c *Converter) RenderCollectionView(block *notionapi.Block)
- func (c *Converter) RenderCollectionViewPage(block *notionapi.Block)
- func (c *Converter) RenderColumn(block *notionapi.Block)
- func (c *Converter) RenderColumnList(block *notionapi.Block)
- func (c *Converter) RenderDivider(block *notionapi.Block)
- func (c *Converter) RenderDrive(block *notionapi.Block)
- func (c *Converter) RenderEmbed(block *notionapi.Block)
- func (c *Converter) RenderEquation(block *notionapi.Block)
- func (c *Converter) RenderFigma(block *notionapi.Block)
- func (c *Converter) RenderFile(block *notionapi.Block)
- func (c *Converter) RenderGist(block *notionapi.Block)
- func (c *Converter) RenderHeader(block *notionapi.Block)
- func (c *Converter) RenderHeaderLevel(block *notionapi.Block, level int)
- func (c *Converter) RenderImage(block *notionapi.Block)
- func (c *Converter) RenderInline(b *notionapi.TextSpan)
- func (c *Converter) RenderInlines(blocks []*notionapi.TextSpan)
- func (c *Converter) RenderMaps(block *notionapi.Block)
- func (c *Converter) RenderNumberedList(block *notionapi.Block)
- func (c *Converter) RenderPDF(block *notionapi.Block)
- func (c *Converter) RenderPage(block *notionapi.Block)
- func (c *Converter) RenderQuote(block *notionapi.Block)
- func (c *Converter) RenderSubHeader(block *notionapi.Block)
- func (c *Converter) RenderSubSubHeader(block *notionapi.Block)
- func (c *Converter) RenderTableOfContents(block *notionapi.Block)
- func (c *Converter) RenderText(block *notionapi.Block)
- func (c *Converter) RenderTodo(block *notionapi.Block)
- func (c *Converter) RenderToggle(block *notionapi.Block)
- func (c *Converter) RenderTransclusionReference(block *notionapi.Block)
- func (c *Converter) RenderTweet(block *notionapi.Block)
- func (c *Converter) RenderVideo(block *notionapi.Block)
- func (c *Converter) RewrittenURL(uri string) string
- func (c *Converter) ToHTML() ([]byte, error)
- type PageByIDFromPages
- type PageByIDProvider
Constants ¶
const CSS = `` /* 9616-byte string literal not displayed */
CSS we use. If Converter.FullHTML is true, it's included as part of generated HTML. Otherwise you have to provide HTML wrapper where you can either embed this CSS as <style>${css}</style> or reference it as <link rel="stylesheet" href="${css_file}">
const CSSPlus = `
.breadcrumbs {
}
`
CSSPlus is CSS additional to what Notion CSS has
Variables ¶
This section is empty.
Functions ¶
func CleanAttributeValue ¶
CleanAttributeValue cleans value of an attribute
func EscapeHTML ¶
EscapeHTML escapes HTML in the same way as Notion.
func GetBlockColorClass ¶
GetBlockColorClass returns "block-color-" + format.block_color which is name of css class for different colors
func HTMLFileNameForPage ¶
HTMLFileNameForPage returns file name for html file
Types ¶
type BlockRenderFunc ¶
BlockRenderFunc is a function for rendering a particular block
type Converter ¶
type Converter struct { // Buf is where HTML is being written to Buf *bytes.Buffer Page *notionapi.Page // tracks current number of numbered lists ListNo int // if true tries to render as closely to Notion's HTML // export as possible NotionCompat bool // UseKatexToRenderEquation requires katex CLI to be installed // https://katex.org/docs/cli.html // npm install -g katex // If true, converts BlockEquation to HTML using katex // Tested with katex 0.10.2 UseKatexToRenderEquation bool // If UseKatexToRenderEquation is true, you can provide path to katex binary // here. Otherwise we'll try to locate it using exec.LookPath() // If UseKatexToRenderEquation is true but we can't locate katex binary // we'll return an error KatexPath string // if true, adds <a href="#{$NotionID}">svg(anchor-icon)</a> // to h1/h2/h3 AddHeaderAnchor bool // allows over-riding rendering of specific blocks // return false for default rendering RenderBlockOverride BlockRenderFunc // RewriteURL allows re-writing URLs e.g. to convert inter-notion URLs // to destination URLs RewriteURL func(url string) string // Returns URL for a title cell (that links to a page) TableTitleCellURLOverride func(tv *notionapi.TableView, row, col int) string // if true, generates stand-alone HTML with inline CSS // otherwise it's just the inner part going inside the body FullHTML bool CustomCSS string // we need this to properly render ordered and numbered lists CurrBlocks []*notionapi.Block CurrBlockIdx int PageByIDProvider PageByIDProvider // data provided by they caller, useful when providing // RenderBlockOverride Data interface{} // contains filtered or unexported fields }
Converter converts a Page to HTML
func NewConverter ¶
NewConverter returns customizable HTML renderer
func (*Converter) DefaultRenderFunc ¶
DefaultRenderFunc returns a defult rendering function for a type of a given block
func (*Converter) FormatDate ¶
FormatDate formats the data
func (*Converter) GetInlineContent ¶
GetInlineContent is like RenderInlines but instead of writing to output buffer, we return it as string
func (*Converter) IsNextBlockOfType ¶
IsNextBlockOfType returns true if next block is of a given type
func (*Converter) IsPrevBlockOfType ¶
IsPrevBlockOfType returns true if previous block is of a given type
func (*Converter) NoIndentPrintf ¶
func (*Converter) PushNewBuffer ¶
func (c *Converter) PushNewBuffer()
PushNewBuffer creates a new buffer and sets Buf to it
func (*Converter) RenderAlias ¶
func (*Converter) RenderAudio ¶
RenderAudio renders BlockAudio
func (*Converter) RenderBlock ¶
RenderBlock renders a block to html
func (*Converter) RenderBookmark ¶
RenderBookmark renders BlockBookmark
func (*Converter) RenderBreadcrumb ¶
RenderBreadcrumb renders BlockBreadcrumb
func (*Converter) RenderBulletedList ¶
RenderBulletedList renders BlockBulletedList
func (*Converter) RenderCallout ¶
RenderCallout renders BlockCallout
func (*Converter) RenderCaption ¶
RenderCaption renders a caption
func (*Converter) RenderChildren ¶
func (*Converter) RenderCode ¶
RenderCode renders BlockCode
func (*Converter) RenderCodepen ¶
RenderCodepen renders BlockCodepen
func (*Converter) RenderCollectionView ¶
RenderCollectionView renders BlockCollectionView
func (*Converter) RenderCollectionViewPage ¶
RenderCollectionViewPage renders BlockCollectionViewPage
func (*Converter) RenderColumn ¶
RenderColumn renders BlockColumn Its parent is BlockColumnList
func (*Converter) RenderColumnList ¶
RenderColumnList renders BlockColumnList Its children are BlockColumn
func (*Converter) RenderDivider ¶
RenderDivider renders BlockDivider
func (*Converter) RenderDrive ¶
RenderDrive renders BlockDrive
func (*Converter) RenderEmbed ¶
RenderEmbed renders BlockEmbed
func (*Converter) RenderEquation ¶
RenderEquation renders BlockEquation
func (*Converter) RenderFigma ¶
RenderFigma renders BlockFigma
func (*Converter) RenderFile ¶
RenderFile renders BlockFile
func (*Converter) RenderGist ¶
RenderGist renders BlockGist
func (*Converter) RenderHeader ¶
RenderHeader renders BlockHeader
func (*Converter) RenderHeaderLevel ¶
RenderHeaderLevel renders BlockHeader, SubHeader and SubSubHeader
func (*Converter) RenderImage ¶
RenderImage renders BlockImage
func (*Converter) RenderInline ¶
RenderInline renders inline block
func (*Converter) RenderInlines ¶
RenderInlines renders inline blocks
func (*Converter) RenderMaps ¶
RenderMaps renders BlockMaps
func (*Converter) RenderNumberedList ¶
RenderNumberedList renders BlockNumberedList
func (*Converter) RenderPage ¶
RenderPage renders BlockPage
func (*Converter) RenderQuote ¶
RenderQuote renders BlockQuote
func (*Converter) RenderSubHeader ¶
RenderSubHeader renders BlockSubHeader
func (*Converter) RenderSubSubHeader ¶
RenderSubSubHeader renders BlocSubSubkHeader
func (*Converter) RenderTableOfContents ¶
RenderTableOfContents renders BlockTableOfContents
func (*Converter) RenderText ¶
RenderText renders BlockText
func (*Converter) RenderTodo ¶
RenderTodo renders BlockTodo
func (*Converter) RenderToggle ¶
RenderToggle renders BlockToggle
func (*Converter) RenderTransclusionReference ¶
func (*Converter) RenderTweet ¶
RenderTweet renders BlockTweet
func (*Converter) RenderVideo ¶
RenderVideo renders BlockVideo
func (*Converter) RewrittenURL ¶
RewrittenURL optionally transforms the url via the function provided by the user
type PageByIDFromPages ¶
type PageByIDFromPages struct {
// contains filtered or unexported fields
}
func NewPageByIDFromPages ¶
func NewPageByIDFromPages(pages []*notionapi.Page) *PageByIDFromPages
NewPageByIDFromPages creates PageByIDProvider from array of pages