/
notion.go
94 lines (87 loc) · 2.12 KB
/
notion.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
"github.com/PuerkitoBio/goquery"
"github.com/jomei/notionapi"
"golang.org/x/net/html"
)
// ConvertNode from a html node into a Notion Block representation. Parsers children nodes of the HTML too.
func ConvertDocument(d *goquery.Document) []notionapi.Block {
nodes := d.Children().Nodes()
blocks := make([]notionapi.Block, len(n))
for i, n := range nodes {
blocks[i] = ConvertNode(n, d)
}
return blocks
}
func ConvertNode(n *html.Node, d *goquery.Document) notionapi.Block {
}
func Get(type ) {
switch BlockType(raw["type"].(string)) {
case BlockTypeParagraph:
b = &ParagraphBlock{}
case BlockTypeHeading1:
b = &Heading1Block{}
case BlockTypeHeading2:
b = &Heading2Block{}
case BlockTypeHeading3:
b = &Heading3Block{}
case BlockCallout:
b = &CalloutBlock{}
case BlockQuote:
b = &QuoteBlock{}
case BlockTypeBulletedListItem:
b = &BulletedListItemBlock{}
case BlockTypeNumberedListItem:
b = &NumberedListItemBlock{}
case BlockTypeToDo:
b = &ToDoBlock{}
case BlockTypeCode:
b = &CodeBlock{}
case BlockTypeToggle:
b = &ToggleBlock{}
case BlockTypeChildPage:
b = &ChildPageBlock{}
case BlockTypeEmbed:
b = &EmbedBlock{}
case BlockTypeImage:
b = &ImageBlock{}
case BlockTypeVideo:
b = &VideoBlock{}
case BlockTypeFile:
b = &FileBlock{}
case BlockTypePdf:
b = &PdfBlock{}
case BlockTypeBookmark:
b = &BookmarkBlock{}
case BlockTypeChildDatabase:
b = &ChildDatabaseBlock{}
case BlockTypeTableOfContents:
b = &TableOfContentsBlock{}
case BlockTypeDivider:
b = &DividerBlock{}
case BlockTypeEquation:
b = &EquationBlock{}
case BlockTypeBreadcrumb:
b = &BreadcrumbBlock{}
case BlockTypeColumn:
b = &ColumnBlock{}
case BlockTypeColumnList:
b = &ColumnListBlock{}
case BlockTypeLinkPreview:
b = &LinkPreviewBlock{}
case BlockTypeLinkToPage:
b = &LinkToPageBlock{}
case BlockTypeTemplate:
b = &TemplateBlock{}
case BlockTypeSyncedBlock:
b = &SyncedBlock{}
case BlockTypeTableBlock:
b = &TableBlock{}
case BlockTypeTableRowBlock:
b = &TableRowBlock{}
case BlockTypeUnsupported:
b = &UnsupportedBlock{}
default:
return &UnsupportedBlock{}, nil
}
}