jgm/djot.js

multiline link urls no longer trimmed and concatenated

Opened this issue · 4 comments

Previously djot would allow me to have long urls split across lines:

[link](
  https://some-really-long-url/
  with-several-parts/
  that-i-want-across-lines)

Before 0.2.4, it would eliminate the whitespace between those URL components:

$ djot test.dj 
<p><a href="https://some-really-long-url/with-several-parts/that-i-want-across-lines">link</a></p>

However, with 0.2.4, it now keeps spaces in the URL:

$ djot test.dj 
<p><a href="  https://some-really-long-url/  with-several-parts/  that-i-want-across-lines">link</a></p>

I didn't notice at first because the browser seems to "do the right thing", but is this intended / guaranteed to always work?

Many thanks for all the great work on djot!!

jgm commented

yes it's a bug!

jgm commented

Culprit is commit 1b5425c
Note that this commit also causes problems for, e.g.

> [link](a
> b)

-- the > is included in the URL. Back to the drawing board.

I'm not sure this is the best place to mention it, but #46 feels somewhat related to what I discussed in djot#247. Briefly I propose to consider that link URLs, references, and attribute blocks should change the parser mode, just like raw text in code spans, which has indirect impact in how invalid constructs are parsed (automatically closed at the end of bock, just like code spans).

jgm commented

Yes, the complexity in #46 is needed because we want to allow you to have regular text after something that would (if properly continued) introduce an attribute or link or reference.

These

[hi](*emph*

[hi][*emph*

[hi]{.class *emph*

become

<p>[hi](<strong>emph</strong></p>
<p>[hi][<strong>emph</strong></p>
<p><span>hi</span>{.class <strong>emph</strong></p>

You're asking whether that's something we should want.