aboutsummaryrefslogtreecommitdiff
path: root/util_test.go
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-07-15 18:01:39 -0500
committerGitHub <[email protected]>2026-07-15 18:01:39 -0500
commit9c6ad663cf5901669aaed59cb16482e0f716a313 (patch)
treec492d849ae96fb12e19f0bc21be5b8ab14df9c3b /util_test.go
parent971bdb3e8073965ebbb1924864b0442cd3d8dc95 (diff)
downloaddevianter-9c6ad663cf5901669aaed59cb16482e0f716a313.tar.gz
devianter-9c6ad663cf5901669aaed59cb16482e0f716a313.tar.bz2
devianter-9c6ad663cf5901669aaed59cb16482e0f716a313.zip
fix: extract text from tiptap bodies, and read the right description field (#4)v0.3.3
Checking the library against the live API disproved what its comments claimed. Comment and Description were handing back raw JSON blobs, and the parser this package has always carried could not have prevented it. DeviantArt no longer stores rich text as Draft.js. It uses tiptap: Draft.js, what we parse: {"blocks":[{"text":"..."}]} tiptap, what DA sends: {"version":1,"document":{"type":"doc",...}} Across 34 live comments: 33 tiptap, 0 Draft.js, and 33 whose .Comment was the raw JSON. flattenMarkup now walks the tiptap tree — text nodes joined per block, hardBreak as a newline, entities decoded — and keeps the Draft.js path for old bodies that still carry it. Nodes with no text of their own (images, galleries, emotes) drop out, as they always did. The description had a second, larger bug behind that one. It lives in Extended.DescriptionText, not TextContent, which GetDeviation read: of 24 deviations sampled, 23 populated the former and 1 the latter. So Post.Description was empty for nearly every deviation, and the txt[1] guard removed in 3dad0ea was never what stood in the way. Prefer Extended.DescriptionText and fall back, since either may be the one set. Verified against the live API rather than by reading: comments still raw JSON went 33/34 to 0/34, and descriptions that were "" now return prose. Also corrects the doc comments that asserted the Draft.js story on pkg.go.dev, and notes that flattening drops images, links, and emotes.
Diffstat (limited to 'util_test.go')
0 files changed, 0 insertions, 0 deletions