Skip to content

Commit

Permalink
accept data as interface, and use github markdown flavour (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnetop authored Nov 13, 2023
1 parent 0c90e52 commit fcbd8f3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
46 changes: 23 additions & 23 deletions internal/notesnook/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,27 @@ const (
)

type Nook struct {
ID string `json:"id"`
Type Type `json:"type"`
Title string `json:"title,omitempty"`
Pinned bool `json:"pinned,omitempty"`
Topics []Topic `json:"topics,omitempty"`
DateCreated int64 `json:"dateCreated"`
DateModified int64 `json:"dateModified"`
DateEdited int64 `json:"dateEdited,omitempty"`
Synced bool `json:"synced"`
Description string `json:"description,omitempty"`
ContentID string `json:"contentId,omitempty"`
Headline string `json:"headline,omitempty"`
Tags []string `json:"tags,omitempty"`
Locked bool `json:"locked,omitempty"`
Favorite bool `json:"favorite,omitempty"`
LocalOnly bool `json:"localOnly,omitempty"`
Readonly bool `json:"readonly,omitempty"`
NoteID string `json:"noteId,omitempty"`
Data string `json:"data,omitempty"`
NoteIDs []string `json:"noteIds,omitempty"`
From From `json:"from,omitempty"`
To To `json:"to,omitempty"`
Notebooks []Notebook `json:"notebooks,omitempty"`
ID string `json:"id"`
Type Type `json:"type"`
Title string `json:"title,omitempty"`
Pinned bool `json:"pinned,omitempty"`
Topics []Topic `json:"topics,omitempty"`
DateCreated int64 `json:"dateCreated"`
DateModified int64 `json:"dateModified"`
DateEdited int64 `json:"dateEdited,omitempty"`
Synced bool `json:"synced"`
Description string `json:"description,omitempty"`
ContentID string `json:"contentId,omitempty"`
Headline string `json:"headline,omitempty"`
Tags []string `json:"tags,omitempty"`
Locked bool `json:"locked,omitempty"`
Favorite bool `json:"favorite,omitempty"`
LocalOnly bool `json:"localOnly,omitempty"`
Readonly bool `json:"readonly,omitempty"`
NoteID string `json:"noteId,omitempty"`
Data interface{} `json:"data,omitempty"`
NoteIDs []string `json:"noteIds,omitempty"`
From From `json:"from,omitempty"`
To To `json:"to,omitempty"`
Notebooks []Notebook `json:"notebooks,omitempty"`
}
4 changes: 3 additions & 1 deletion internal/sn/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

md "github.com/JohannesKaufmann/html-to-markdown"
"github.com/JohannesKaufmann/html-to-markdown/plugin"
"github.com/PuerkitoBio/goquery"
"github.com/google/uuid"

Expand Down Expand Up @@ -40,7 +41,7 @@ func convertNotesnookToStandardNotes(nooks []notesnook.Nook) StandardNotes {
for _, nook := range nooks {
switch nook.Type {
case notesnook.TypeTipTap:
tipTaps[nook.ID] = nook.Data
tipTaps[nook.ID] = fmt.Sprintf("%s", nook.Data)
case notesnook.TypeNotebook: // notebook have topics (I'm treating them as sub notebooks)
id := uuid.New()
notebooks[nook.ID] = Notebook{
Expand Down Expand Up @@ -178,6 +179,7 @@ func ConvertNotebooksToTags() StandardNotes {

func convertHTMLToMarkdown(content string) string {
converter := md.NewConverter("", true, &md.Options{EscapeMode: "disabled"})
converter.Use(plugin.GitHubFlavored())

markdown, err := converter.ConvertString(content)
if err != nil {
Expand Down

0 comments on commit fcbd8f3

Please sign in to comment.