borkdude / quickblog

Light-weight static blog engine for Clojure and babashka
https://blog.michielborkent.nl/
MIT License
165 stars 28 forks source link

Standard markdown syntax for tables can lead to empty tables in HTML #59

Closed ljpengelen closed 1 year ago

ljpengelen commented 1 year ago

I noticed that markdown like the following will be translated to an empty table:

| Header A | Header B |
| -------- | -------- |
| 1        | 2        |

The HTML tags are present in the output, but the content isn't:

<table><thead><tr></tr></thead><tbody><tr></tr><tr></tr></tbody></table>

This has to do with what's happening in pre-process-md:

(defn pre-process-markdown [markdown]
  (-> markdown
      (str/replace #"--" (fn [_] "$$NDASH$$"))
      (str/replace #"\[[^\]]+\n"
                   (fn [match]
                     (str/replace match "\n" "$$RET$$")))))

If I use the following markup, the table ends up in the output just fine:

| Header A | Header B |
| - | - |
| 1        | 2        |

I'm happy to look into this, but I'm not sure what the intention of pre-process-markdown is.

borkdude commented 1 year ago

The intention of "$$RET$$" is to work around some bugs in the markdown-clj lib. It causes:

[foo 
bar](https://foobar.com)

to incorrectly render. I don't know if this is still the case or if it was fixed. Worth looking into an upgrade and if it isn't fixed yet, I'm open to another fix.

I'm not sure what the $$NDASH$$ was. It might have to do with code formatting.

I removed it for now and I'll revisit when I discover what it was for :)

ljpengelen commented 1 year ago

Thanks for the quick fix!