notionapi: github.com/kjk/notionapi/tohtml Index | Files

package tohtml

import "github.com/kjk/notionapi/tohtml"

Index

Package Files

css_notion.go html.go

Constants

const CSS = "" /* 9672 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}">

func EscapeHTML Uses

func EscapeHTML(s string) string

EscapeHTML escapes HTML in the same way as Notion.

func HTMLFileNameForPage Uses

func HTMLFileNameForPage(page *notionapi.Page) string

HTMLFileNameForPage returns file name for html file

func ToHTML Uses

func ToHTML(page *notionapi.Page) []byte

ToHTML converts a page to HTML

type BlockRenderFunc Uses

type BlockRenderFunc func(block *notionapi.Block) bool

BlockRenderFunc is a function for rendering a particular block

type Converter Uses

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

    // if true, generates stand-alone HTML with inline CSS
    // otherwise it's just the inner part going inside the body
    FullHTML bool

    // we need this to properly render ordered and numbered lists
    CurrBlocks   []*notionapi.Block
    CurrBlockIdx int

    // related pages if this page is rendered as part of
    // collection of pages (like a website)
    Pages []*notionapi.Page

    // data provided by they caller, useful when providing
    // RenderBlockOverride
    Data interface{}
    // contains filtered or unexported fields
}

HTMLRenderer converts a Page to HTML

func NewConverter Uses

func NewConverter(page *notionapi.Page) *Converter

NewConverter returns customizable HTML renderer

func (*Converter) A Uses

func (c *Converter) A(uri, text, cls string)

A writes <a></a> element to output

func (*Converter) DefaultRenderFunc Uses

func (c *Converter) DefaultRenderFunc(blockType string) func(*notionapi.Block)

DefaultRenderFunc returns a defult rendering function for a type of a given block

func (*Converter) FormatDate Uses

func (c *Converter) FormatDate(d *notionapi.Date) string

FormatDate formats the data

func (*Converter) GetInlineContent Uses

func (c *Converter) GetInlineContent(blocks []*notionapi.TextSpan) string

GetInlineContent is like RenderInlines but instead of writing to output buffer, we return it as string

func (*Converter) IsNextBlockOfType Uses

func (c *Converter) IsNextBlockOfType(t string) bool

IsNextBlockOfType returns true if next block is of a given type

func (*Converter) IsPrevBlockOfType Uses

func (c *Converter) IsPrevBlockOfType(t string) bool

IsPrevBlockOfType returns true if previous block is of a given type

func (*Converter) NextBlock Uses

func (c *Converter) NextBlock() *notionapi.Block

NextBlock is a block preceding current block

func (*Converter) PageByID Uses

func (c *Converter) PageByID(pageID string) *notionapi.Page

PageByID returns Page given its ID

func (*Converter) PopBuffer Uses

func (c *Converter) PopBuffer() *bytes.Buffer

PopBuffer pops a buffer

func (*Converter) PrevBlock Uses

func (c *Converter) PrevBlock() *notionapi.Block

PrevBlock is a block preceding current block

func (*Converter) Printf Uses

func (c *Converter) Printf(format string, args ...interface{})

func (*Converter) PushNewBuffer Uses

func (c *Converter) PushNewBuffer()

PushNewBuffer creates a new buffer and sets Buf to it

func (*Converter) RenderAudio Uses

func (c *Converter) RenderAudio(block *notionapi.Block)

RenderAudio renders BlockAudio

func (*Converter) RenderBlock Uses

func (c *Converter) RenderBlock(block *notionapi.Block)

RenderBlock renders a block to html

func (*Converter) RenderBookmark Uses

func (c *Converter) RenderBookmark(block *notionapi.Block)

RenderBookmark renders BlockBookmark

func (*Converter) RenderBreadcrumb Uses

func (c *Converter) RenderBreadcrumb(block *notionapi.Block)

RenderBreadcrumb renders BlockBreadcrumb

func (*Converter) RenderBulletedList Uses

func (c *Converter) RenderBulletedList(block *notionapi.Block)

RenderBulletedList renders BlockBulletedList

func (*Converter) RenderCallout Uses

func (c *Converter) RenderCallout(block *notionapi.Block)

RenderCallout renders BlockCallout

func (*Converter) RenderCaption Uses

func (c *Converter) RenderCaption(block *notionapi.Block)

func (*Converter) RenderChildren Uses

func (c *Converter) RenderChildren(block *notionapi.Block)

func (*Converter) RenderCode Uses

func (c *Converter) RenderCode(block *notionapi.Block)

RenderCode renders BlockCode

func (*Converter) RenderCodepen Uses

func (c *Converter) RenderCodepen(block *notionapi.Block)

RenderCodepen renders BlockCodepen

func (*Converter) RenderCollectionView Uses

func (c *Converter) RenderCollectionView(block *notionapi.Block)

RenderCollectionView renders BlockCollectionView

func (*Converter) RenderCollectionViewPage Uses

func (c *Converter) RenderCollectionViewPage(block *notionapi.Block)

RenderCollectionViewPage renders BlockCollectionViewPage

func (*Converter) RenderColumn Uses

func (c *Converter) RenderColumn(block *notionapi.Block)

RenderColumn renders BlockColumn it's parent is BlockColumnList

func (*Converter) RenderColumnList Uses

func (c *Converter) RenderColumnList(block *notionapi.Block)

RenderColumnList renders BlockColumnList it's children are BlockColumn

func (*Converter) RenderDivider Uses

func (c *Converter) RenderDivider(block *notionapi.Block)

RenderDivider renders BlockDivider

func (*Converter) RenderDrive Uses

func (c *Converter) RenderDrive(block *notionapi.Block)

RenderDrive renders BlockDrive

func (*Converter) RenderEmbed Uses

func (c *Converter) RenderEmbed(block *notionapi.Block)

RenderEmbed renders BlockEmbed

func (*Converter) RenderEquation Uses

func (c *Converter) RenderEquation(block *notionapi.Block)

RenderEquation renders BlockEquation

func (*Converter) RenderFigma Uses

func (c *Converter) RenderFigma(block *notionapi.Block)

RenderFigma renders BlockFigma

func (*Converter) RenderFile Uses

func (c *Converter) RenderFile(block *notionapi.Block)

RenderFile renders BlockFile

func (*Converter) RenderGist Uses

func (c *Converter) RenderGist(block *notionapi.Block)

RenderGist renders BlockGist

func (*Converter) RenderHeader Uses

func (c *Converter) RenderHeader(block *notionapi.Block)

RenderHeader renders BlockHeader

func (*Converter) RenderHeaderLevel Uses

func (c *Converter) RenderHeaderLevel(block *notionapi.Block, level int)

RenderHeaderLevel renders BlockHeader, SubHeader and SubSubHeader

func (*Converter) RenderImage Uses

func (c *Converter) RenderImage(block *notionapi.Block)

RenderImage renders BlockImage

func (*Converter) RenderInline Uses

func (c *Converter) RenderInline(b *notionapi.TextSpan)

RenderInline renders inline block

func (*Converter) RenderInlines Uses

func (c *Converter) RenderInlines(blocks []*notionapi.TextSpan)

RenderInlines renders inline blocks

func (*Converter) RenderMaps Uses

func (c *Converter) RenderMaps(block *notionapi.Block)

RenderMaps renders BlockMaps

func (*Converter) RenderNYI Uses

func (c *Converter) RenderNYI(block *notionapi.Block)

func (*Converter) RenderNumberedList Uses

func (c *Converter) RenderNumberedList(block *notionapi.Block)

RenderNumberedList renders BlockNumberedList

func (*Converter) RenderPDF Uses

func (c *Converter) RenderPDF(block *notionapi.Block)

RenderPDF renders BlockPDF

func (*Converter) RenderPage Uses

func (c *Converter) RenderPage(block *notionapi.Block)

RenderPage renders BlockPage

func (*Converter) RenderQuote Uses

func (c *Converter) RenderQuote(block *notionapi.Block)

RenderQuote renders BlockQuote

func (*Converter) RenderSubHeader Uses

func (c *Converter) RenderSubHeader(block *notionapi.Block)

RenderSubHeader renders BlockSubHeader

func (*Converter) RenderSubSubHeader Uses

func (c *Converter) RenderSubSubHeader(block *notionapi.Block)

RenderSubSubHeader renders BlocSubSubkHeader

func (*Converter) RenderTableOfContents Uses

func (c *Converter) RenderTableOfContents(block *notionapi.Block)

RenderTableOfContents renders BlockTableOfContents

func (*Converter) RenderText Uses

func (c *Converter) RenderText(block *notionapi.Block)

RenderText renders BlockText

func (*Converter) RenderTodo Uses

func (c *Converter) RenderTodo(block *notionapi.Block)

RenderTodo renders BlockTodo

func (*Converter) RenderToggle Uses

func (c *Converter) RenderToggle(block *notionapi.Block)

RenderToggle renders BlockToggle

func (*Converter) RenderTweet Uses

func (c *Converter) RenderTweet(block *notionapi.Block)

RenderTweet renders BlockTweet

func (*Converter) RenderVideo Uses

func (c *Converter) RenderVideo(block *notionapi.Block)

RenderVideo renders BlockVideo

func (*Converter) ToHTML Uses

func (c *Converter) ToHTML() ([]byte, error)

ToHTML renders a page to html

Package tohtml imports 8 packages (graph). Updated 2019-09-14. Refresh now. Tools for package owners.