Merge pull request #1 from johanmynhardt/develop

Fix: java.lang.ClassCastException when source `obj` is (X)HTML.
This commit is contained in:
Simon Brooke 2022-12-27 11:51:41 +00:00 committed by GitHub
commit 7f2ccd2d29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

@ -93,6 +93,4 @@
(if url (transform url dispatcher)
;; otherwise, if s is not a URL, consider it as an HTML fragment,
;; parse and process it
(process (tagsoup/parser (java.io.StringReader s)) dispatcher)
)))
(process (tagsoup/parser (java.io.StringReader. s)) dispatcher))))

View file

@ -0,0 +1,10 @@
(ns html-to-md.transformer-test
(:require
[clojure.test :as t :refer [deftest is testing]]
[html-to-md.html-to-md :refer [markdown-dispatcher]]
[html-to-md.transformer :refer [transform]]))
(deftest transform-payload
(testing "String `obj` for: 3. A string representation of an (X)HTML fragment;"
(is (= '("\n# This is a header\n")
(transform "<h1>This is a header</h1>" markdown-dispatcher)))))