Documentation ¶
Index ¶
- func MarkdownFileNameForPage(page *notionapi.Page) string
- func ToMarkdown(page *notionapi.Page) []byte
- type BlockRenderFunc
- type Converter
- func (c *Converter) AddNewlineBeforeBlock(block *notionapi.Block)
- func (c *Converter) DefaultRenderFunc(blockType string) func(*notionapi.Block)
- func (c *Converter) Eol()
- func (c *Converter) FormatDate(d *notionapi.Date) string
- func (c *Converter) GetInlineContent(blocks []*notionapi.TextSpan, trimeEndSpace bool) string
- func (c *Converter) InlineToString(b *notionapi.TextSpan) string
- func (c *Converter) IsNextBlockOfType(t string) bool
- func (c *Converter) IsPrevBlockOfType(t string) bool
- func (c *Converter) Newline()
- func (c *Converter) NextBlock() *notionapi.Block
- 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) RenderAudio(block *notionapi.Block)
- func (c *Converter) RenderBlock(block *notionapi.Block)
- func (c *Converter) RenderBookmark(block *notionapi.Block)
- func (c *Converter) RenderBulletedList(block *notionapi.Block)
- func (c *Converter) RenderCallout(block *notionapi.Block)
- func (c *Converter) RenderChildren(block *notionapi.Block)
- func (c *Converter) RenderCode(block *notionapi.Block)
- func (c *Converter) RenderCollectionView(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) 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, trimEndSpace bool)
- 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) RenderText(block *notionapi.Block)
- func (c *Converter) RenderTodo(block *notionapi.Block)
- func (c *Converter) RenderToggle(block *notionapi.Block)
- func (c *Converter) RenderTweet(block *notionapi.Block)
- func (c *Converter) RenderVideo(block *notionapi.Block)
- func (c *Converter) ToMarkdown() []byte
- func (c *Converter) WriteString(s string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarkdownFileNameForPage ¶
MarkdownFileNameForPage returns file name for markdown file
func ToMarkdown ¶
ToMarkdown converts a page to Markdown
Types ¶
type BlockRenderFunc ¶
BlockRenderFunc is a function for rendering a particular block
type Converter ¶
type Converter struct { Page *notionapi.Page // Buf is where HTML is being written to Buf *bytes.Buffer // 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 // data provided by they caller, useful when providing // RenderBlockOverride Data interface{} // we need this to properly render ordered and numbered lists CurrBlocks []*notionapi.Block CurrBlockIdx int Indent string ListNo int // contains filtered or unexported fields }
MarkdownRenderer converts a Page to HTML
func NewConverter ¶
NewConverter returns customizable Markdown renderer
func (*Converter) AddNewlineBeforeBlock ¶
func (*Converter) DefaultRenderFunc ¶
DefaultRenderFunc returns a defult rendering function for a type of a given block
func (*Converter) Eol ¶
func (c *Converter) Eol()
Eol writes end-of-line to the buffer. Doesn't write multiple.
func (*Converter) FormatDate ¶
FormatDate formats the date
func (*Converter) GetInlineContent ¶
GetInlineContent is like RenderInlines but instead of writing to output buffer, we return it as string
func (*Converter) InlineToString ¶
InlineToString renders inline block
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) Newline ¶
func (c *Converter) Newline()
Newline writes a newline to the buffer. It'll suppress multiple newlines.
func (*Converter) PushNewBuffer ¶
func (c *Converter) PushNewBuffer()
PushNewBuffer creates a new buffer and sets Buf to it
func (*Converter) RenderAudio ¶
RenderAudio renders BlockAudio
func (*Converter) RenderBlock ¶
RenderBlock renders a block to html
func (*Converter) RenderBookmark ¶
RenderBookmark renders BlockBookmark
func (*Converter) RenderBulletedList ¶
RenderBulletedList renders BlockBulletedList
func (*Converter) RenderCallout ¶
RenderCallout renders BlockCallout
func (*Converter) RenderChildren ¶
func (*Converter) RenderCode ¶
RenderCode renders BlockCode
func (*Converter) RenderCollectionView ¶
RenderCollectionView renders BlockCollectionView
func (*Converter) RenderColumn ¶
RenderColumn renders BlockColumn it's parent is BlockColumnList
func (*Converter) RenderColumnList ¶
RenderColumnList renders BlockColumnList it's children are BlockColumn
func (*Converter) RenderDivider ¶
RenderDivider renders BlockDivider
func (*Converter) RenderDrive ¶
RenderDrive renders BlockDrive
func (*Converter) RenderEmbed ¶
RenderEmbed renders BlockEmbed
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 ¶
func (*Converter) RenderInlines ¶
RenderInlines renders inline blocks
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) RenderText ¶
RenderText renders BlockText
func (*Converter) RenderTodo ¶
RenderTodo renders BlockTodo
func (*Converter) RenderToggle ¶
RenderToggle renders BlockToggle
func (*Converter) RenderTweet ¶
RenderTweet renders BlockTweet
func (*Converter) RenderVideo ¶
RenderVideo renders BlockTweet
func (*Converter) ToMarkdown ¶
func (*Converter) WriteString ¶
WriteString writes a string to the buffer