jgm / djot

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

Inconsistent treatment of attributes on links references and footnotes #118

Closed matklad closed 1 year ago

matklad commented 1 year ago
{.x}
[link]: url

{.x}
[^foot]: note
{
  "tag": "doc",
  "references": {
    "link": {
      "destination": "url",
      "attributes": {
        "class": "x"
      }
    }
  },
  "footnotes": {
    "foot": {
      "tag": "footnote",
      "children": [
        {
          "tag": "para",
          "attr": {
            "class": "x"
          },
          "children": [
            {
              "tag": "str",
              "text": "note"
            }
          ]
        }
      ]
    }
  }
}

This feels a bit inconsistent to me. I'd expect something like:

{
  "tag": "doc",
  "references": {
    "link": {
      "tag": "reference_definition",
      "attr": { "class": "x" },
      "destination": "url",
    }
  },
  "footnotes": {
    "foot": {
      "tag": "footnote",
      "attr": { "class": "x" },
      "children": [
        {
          "tag": "para",
          "children": [
            {
              "tag": "str",
              "text": "note"
            }
          ]
        }
      ]
    }
  }
}
  1. specify tag for both kinds of references
  2. use attr rather than attributes for reference_definition
  3. for footnote, attach attr to the footnote, rather than to a para