textlint-rule / textlint-rule-no-dead-link

textlint rule to check if all links are alive.
29 stars 11 forks source link

Don't check reference-style links #105

Closed gregurco closed 1 year ago

gregurco commented 6 years ago

Hello. This rule is not validating links in reference-style. For example:

(some link text)[1]

[1]: https://foo.bar

Plugin is simply ignore it, but error expected.

azu commented 6 years ago

Thanks for report.

This rule is not validating links in reference-style.

Yes. Currently this rule does not support it.

Probably, we can support reference-style by following imeplemtation. (I did not test the code)

// Similar with https://github.com/textlint-rule/textlint-rule-no-dead-link/blob/3984344d642e0323903d6d34326d02f6a33be269/src/no-dead-link.js#L223
    ["Definition"](node) {
      if (typeof node.url === 'undefined') {
        return;
      }

      // [1]: http://example.com
      //      ^
      const index = node.raw.indexOf(node.url) || 0;

      URIs.push({
        node,
        uri: node.url,
        index,
      });
   },

📝 Note: Definition Node type is markdown specific. (It is not a parts of TxtAST)

image