spork icon indicating copy to clipboard operation
spork copied to clipboard

spork/mdz eats whitespace

Open iacore opened this issue 1 year ago • 4 comments

how to reproduce

  • go in this repo
  • run in Janet REPL:
(import spork/mdz)
(mdz/markup (slurp "doc/data.mdz"))

now, you should see this output

@{:current-file "<anonymous>" :front-matter { :author "Caleb Figgers" :license "MIT" :order 1 :template "mdzdoc/main.html" :title "data"} :markup-dom @[ "\n" (:a {"href" "https://clojure.org/"} @[@["Clojure"]]) (:p "contains a very useful core library (or \"namespace\" in Clojure parlance) called "

the space between Clojure is and contains is gone!

Also, the :a tag should be inside :p tag, not before it.

iacore avatar Feb 04 '24 18:02 iacore

I was able to reproduce, i.e. I noticed the lack of a space and the :p tag behavior doesn't seem appropriate.

Fixes would be nice :)


A couple of work-arounds [1]:

  • Wrap the initial paragraph explicitly, e.g.

    @p{@link[https://clojure.org/]{Clojure} contains  ...}
    
  • Don't start the paragraph with a link, e.g.

    The language @link[https://clojure.org/]{Clojure} contains ...
    

I'm not suggesting that it wouldn't be better for the current behavior to be improved, the above are just interim alternatives that seem to yield improved results. If one is willing to modify one's content, may be one or the other is useful.


[1] Limited testing with either of the work-around via:

(htmlgen/html (get (mdz/markup (slurp "file.mdz")) :markup-dom))

seemed to yield ok results here.

sogaiu avatar Feb 05 '24 09:02 sogaiu

So this is something that has been in mendoza since the beginning and not sure the best way to resolve it - starting a section with a tag is ambiguous in that some tags are "inline" and some tags are block elements. I think the recommended work around of using @p{...} is the right thing here, but aside from creating complicated parsing rules, I might just leave this as wontfix.

bakpakin avatar Apr 27 '24 21:04 bakpakin

If there's no good way to address this, may be some kind of mention in documentation could be helpful?

sogaiu avatar Apr 29 '24 01:04 sogaiu

complicated parsing rules

I thought of a rule, which states,


Any group of elements with an empty line before and after,

if it's only one element, it's not wrapped in <p>

otherwise, it is wrapped in <p>

@link[]() this is in a paragraph

this is in a paragraph @link[]()

@link[this is not in a paragraph but should be in a paragraph?]()

@codeblock`this is not in a paragraph`

What existing code does this break?

iacore avatar Apr 29 '24 11:04 iacore