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

Characters disappear if url/label contains valid attributes. #46

Closed
hellux opened this issue Feb 19, 2023 · 7 comments
Closed

Characters disappear if url/label contains valid attributes. #46

hellux opened this issue Feb 19, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@hellux
Copy link
Contributor

hellux commented Feb 19, 2023

[text]({a=b})

yields

doc
  para
    link destination="{ab}"
      str text="text"

instead of

doc
  para
    link destination="{a=b}"
      str text="text"
@jgm
Copy link
Owner

jgm commented Feb 22, 2023

Can see same thing with

[hi]({#ab})

[hi]({.ab})

@jgm
Copy link
Owner

jgm commented Feb 22, 2023

When we match a destination, we (inlines.ts l. 440)

        // convert all matches inside destination to str

The problem is that the attribute parser gives us events for key and value, but not for the =; similarly for the identifier or class, but not the markers # or .. Interior whitespace is also not given an event, so it too will be lost:

% ./djot          
[hi]({a=b c=d})
<p><a href="{abcd}">hi</a></p>

Probably the best fix is to use a different strategy for matching destinations. You might ask, why not just use the position after the ( as the start of the destination and the position before the ) as the end? Because the destination might be broken up by newlines and thus might not occupy a contiguous segment of the input text.

@jgm jgm added the bug Something isn't working label Feb 22, 2023
@jgm
Copy link
Owner

jgm commented Sep 10, 2023

One idea for fixing this would be to have the events parser create multiple +destination/-destination pairs when the URL is split over lines.
parse.ts could then look for multiple destinations and concatenate them. If we were sure that each +destination/-destination pair was on a single line, we could just take all the text between the start and the end.

@jgm jgm closed this as completed in 1b5425c Sep 11, 2023
@jgm jgm reopened this Oct 7, 2023
@jgm
Copy link
Owner

jgm commented Oct 7, 2023

Reopening; I had to revert the fix because it was buggy.
See #64.

@jgm
Copy link
Owner

jgm commented Oct 7, 2023

I think the problem is with strMatches in inlines.ts.

@jgm
Copy link
Owner

jgm commented Oct 7, 2023

Similar issue: [link]({.class})

@jgm
Copy link
Owner

jgm commented Oct 7, 2023

The function converts all matches to str, but some of the characters, like ., don't generate match events, so they are lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants