Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions block.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"net/http"
"strings"
"time"
)

Expand Down Expand Up @@ -297,11 +298,11 @@ func (b BasicBlock) GetParent() *Parent {
return b.Parent
}
func concatenateRichText(richtext []RichText) string {
var result string
var text strings.Builder
for _, rt := range richtext {
result += rt.PlainText
text.WriteString(rt.PlainText)
}
return result
return text.String()
}

func (h Heading1Block) GetRichTextString() string {
Expand Down Expand Up @@ -385,7 +386,7 @@ func (b EquationBlock) GetRichTextString() string {
}

func (b BasicBlock) GetRichTextString() string {
return "No rich text of a basic block."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this text was removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was to avoid surprises and misleading messages, mainly:

  • I don't think one should get a string that is not a part of a wiki page when decoding the various blocks.
  • The text as-is really is trying to say "you didn't override this method in the struct that has a anonymous BasicBlock struct inside of it", but is misleading.

I should have commented more on this when I opened the PR - sorry about that.

return ""
}

var _ Block = (*BasicBlock)(nil)
Expand Down
4 changes: 2 additions & 2 deletions block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package notionapi_test
import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
"os"
"reflect"
"testing"
"time"
Expand Down Expand Up @@ -469,7 +469,7 @@ func TestBlockArrayUnmarshal(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
data, err := ioutil.ReadFile(tt.filePath)
data, err := os.ReadFile(tt.filePath)
if err != nil {
t.Fatal(err)
}
Expand Down