Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"div" custom element causes silent failures #30

Open
dustingetz opened this issue Nov 7, 2017 · 2 comments
Open

"div" custom element causes silent failures #30

dustingetz opened this issue Nov 7, 2017 · 2 comments

Comments

@dustingetz
Copy link

dustingetz commented Nov 7, 2017

Changing both occurences of "div1" to "div" (and also the third occurence in the test markdown) causes markdown rendering to silently fail (nothing is emitted).

Working remark scaffolding (clojurescript):

(def whitelist
  {"span" (fn [props] [:span (dissoc props :children :value) (:value props)])
   "div1" (fn [props] [:div (dissoc props :children :value) (:value props)])})

(defn markdown [value change! & [props]]
  (let [children
        (->
          (js/remark)
          (.use
            js/remarkGenericExtensions
            (clj->js
              {"elements"
               {"span" {"html" {"properties" {"value" "::content::"}}}
                "div1" {"html" {"properties" {"value" "::content::"}}}}}))
          (.use
            js/remarkReact
            (clj->js
              {"sanitize" false
               "remarkReactComponents" (util/map-values r/reactify-component whitelist)}))
          (.processSync value {"commonmark" true})
          .-contents)]
    [:div.markdown {:class (:class props)} children]))

Test markdown

# Test
!span[Hello World]{style="color: red;"}

div1: 
::: Hello World :::
{style="color: yellow; font-size: 3em; "}
@dustingetz
Copy link
Author

By the way, thank you for this plugin, very flexible and powerful, exactly what I was looking for, nice work!

@dustingetz
Copy link
Author

I now see that the "div" custom component isn't even needed, you can just do this and the right stuff happens:

div: 
::: Hello World :::
{style="color: yellow; font-size: 3em; "}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant