Been updating my personal Mastodon tooling to download and convert my bookmarked toots. Here's how little code is needed to download a single message and convert its HTML content into Markdown, all using these #ThingUmbrella packages:
- https://thi.ng/hiccup: Interop data format (i.e. just nested JS arrays) to encode hierarchical documents
- https://thi.ng/hiccup-html-parse: Parses HTML into hiccup format
- https://thi.ng/hiccup-markdown: Serialize hiccup to Markdown (also includes a Markdown parser to hiccup, but not used here)
- https://thi.ng/zipper: Functional tree editing, manipulation & navigation (here to clean/transform the parsed HTML document)
Edit: Gist version of this example code:
https://gist.github.com/postspectacular/1d7ebdc5a81894c16ab744cb8d25c320