jgm / djot

A light markup language
https://djot.net
MIT License
1.67k stars 43 forks source link

Distinguish bare <> from normal ()[] links in the ast #63

Closed matklad closed 1 year ago

matklad commented 1 year ago
<http://example.com> [My Link](http://example.com)
[
  {
    "children": [
      {
        "tag": "str",
        "text": "http://example.com"
      }
    ],
    "tag": "link",
    "destination": "http://example.com"
  },
  {
    "tag": "str",
    "text": " "
  },
  {
    "children": [
      {
        "tag": "str",
        "text": "My Link"
      }
    ],
    "tag": "link",
    "destination": "http://example.com"
  }
]

The problem here is that the two cases are indistinguishable on the AST layer, but it might be usful. In particular, they might want different word-break css.

jgm commented 1 year ago

Pandoc handles this by adding a uri class to "autolinks" (<..>). We could do something similar.

matklad commented 1 year ago

My gut feeling is probably do just

{
    "tag": "autolink",
    "destination": "http://example.com"
}

It seems best to add "desugaring" of the destination into children to the rendered -- it might want to, for example, strip the protocol so that it is rendered as example.com.

jgm commented 1 year ago

Yes, that probably makes more sense.