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

spork/mdz eats whitespace #175

Open
iacore opened this issue Feb 4, 2024 · 4 comments
Open

spork/mdz eats whitespace #175

iacore opened this issue Feb 4, 2024 · 4 comments

Comments

@iacore
Copy link

iacore commented Feb 4, 2024

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.

@sogaiu
Copy link
Contributor

sogaiu commented Feb 5, 2024

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.

@bakpakin
Copy link
Member

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.

@sogaiu
Copy link
Contributor

sogaiu commented Apr 29, 2024

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

@iacore
Copy link
Author

iacore commented Apr 29, 2024

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?

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

3 participants