jgm / djot.js

JavaScript implementation of djot
MIT License
141 stars 15 forks source link

multiline link urls no longer trimmed and concatenated #64

Open ztatlock opened 10 months ago

ztatlock commented 10 months ago

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 10 months ago

yes it's a bug!

jgm commented 10 months ago

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

> [link](a
> b)

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

faelys commented 10 months ago

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 10 months ago

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.