tomarkdown

package
v0.0.0-...-30f7cf6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2021 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarkdownFileNameForPage

func MarkdownFileNameForPage(page *notionapi.Page) string

MarkdownFileNameForPage returns file name for markdown file

func ToMarkdown

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

ToMarkdown converts a page to Markdown

Types

type BlockRenderFunc

type BlockRenderFunc func(block *notionapi.Block) bool

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

func NewConverter(page *notionapi.Page) *Converter

NewConverter returns customizable Markdown renderer

func (*Converter) AddNewlineBeforeBlock

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

func (*Converter) DefaultRenderFunc

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

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

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

FormatDate formats the date

func (*Converter) GetInlineContent

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

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

func (*Converter) InlineToString

func (c *Converter) InlineToString(b *notionapi.TextSpan) string

InlineToString renders inline block

func (*Converter) IsNextBlockOfType

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

IsNextBlockOfType returns true if next block is of a given type

func (*Converter) IsPrevBlockOfType

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

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) NextBlock

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

NextBlock is a block preceding current block

func (*Converter) PopBuffer

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

PopBuffer pops a buffer

func (*Converter) PrevBlock

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

PrevBlock is a block preceding current block

func (*Converter) Printf

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

func (*Converter) PushNewBuffer

func (c *Converter) PushNewBuffer()

PushNewBuffer creates a new buffer and sets Buf to it

func (*Converter) RenderAudio

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

RenderAudio renders BlockAudio

func (*Converter) RenderBlock

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

RenderBlock renders a block to html

func (*Converter) RenderBookmark

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

RenderBookmark renders BlockBookmark

func (*Converter) RenderBulletedList

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

RenderBulletedList renders BlockBulletedList

func (*Converter) RenderCallout

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

RenderCallout renders BlockCallout

func (*Converter) RenderChildren

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

func (*Converter) RenderCode

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

RenderCode renders BlockCode

func (*Converter) RenderCollectionView

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

RenderCollectionView renders BlockCollectionView

func (*Converter) RenderColumn

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

RenderColumn renders BlockColumn it's parent is BlockColumnList

func (*Converter) RenderColumnList

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

RenderColumnList renders BlockColumnList it's children are BlockColumn

func (*Converter) RenderDivider

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

RenderDivider renders BlockDivider

func (*Converter) RenderDrive

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

RenderDrive renders BlockDrive

func (*Converter) RenderEmbed

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

RenderEmbed renders BlockEmbed

func (*Converter) RenderFigma

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

RenderFigma renders BlockFigma

func (*Converter) RenderFile

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

RenderFile renders BlockFile

func (*Converter) RenderGist

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

RenderGist renders BlockGist

func (*Converter) RenderHeader

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

RenderHeader renders BlockHeader

func (*Converter) RenderHeaderLevel

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

RenderHeaderLevel renders BlockHeader, SubHeader and SubSubHeader

func (*Converter) RenderImage

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

RenderImage renders BlockImage

func (*Converter) RenderInline

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

func (*Converter) RenderInlines

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

RenderInlines renders inline blocks

func (*Converter) RenderNumberedList

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

RenderNumberedList renders BlockNumberedList

func (*Converter) RenderPDF

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

RenderPDF renders BlockPDF

func (*Converter) RenderPage

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

RenderPage renders BlockPage

func (*Converter) RenderQuote

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

RenderQuote renders BlockQuote

func (*Converter) RenderSubHeader

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

RenderSubHeader renders BlockSubHeader

func (*Converter) RenderSubSubHeader

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

RenderSubSubHeader renders BlocSubSubkHeader

func (*Converter) RenderText

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

RenderText renders BlockText

func (*Converter) RenderTodo

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

RenderTodo renders BlockTodo

func (*Converter) RenderToggle

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

RenderToggle renders BlockToggle

func (*Converter) RenderTweet

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

RenderTweet renders BlockTweet

func (*Converter) RenderVideo

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

RenderVideo renders BlockTweet

func (*Converter) ToMarkdown

func (c *Converter) ToMarkdown() []byte

func (*Converter) WriteString

func (c *Converter) WriteString(s string)

WriteString writes a string to the buffer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL