jsarafajr / slackify-markdown

Convert markdown into Slack-specific markdown
MIT License
129 stars 25 forks source link

Can't get links to work #22

Closed pranavbadami closed 3 years ago

pranavbadami commented 3 years ago

Hey, great stuff on this library! One issue I'm having is that I can't get links to work properly. For example, when I try the library with the example from the README, here's what I see in my console: Example:

const markdown = `
  # List of items

  * item 1
  * item 2
  * item 3

  [here is an example](https://example.com)
  `;

  console.log(slackifyMarkdown(markdown));

Output: image

I'd expect the last line of the output text to read: <https://example.com|here is an example>. Any pointers on solving this?

Here's my version info if it's helpful:

"slackify-markdown": {
      "version": "4.1.0",
      "resolved": "https://registry.npmjs.org/slackify-markdown/-/slackify-markdown-4.1.0.tgz",
      "integrity": "sha512-dvGUjHAe78NqISOXh+UwEDdPjxRxyYtxo6iYWCCJfX5Eg4nVP5GrTJfJGonrYVRM1Mor0iO2xnFz2ykBeE9xDQ==",
      "requires": {
        "mdast-util-to-markdown": "^0.6.2",
        "remark-gfm": "^1.0.0",
        "remark-parse": "^9.0.0",
        "remark-stringify": "^9.0.1",
        "unified": "^9.0.0",
        "unist-util-remove": "^2.0.1",
        "unist-util-visit": "^2.0.3"
      }
    },

Thanks in advance for any help!

krisztian-fl commented 3 years ago

Same here, managed to track it down to an TypeError: URL is not a constructor error in the isURL helper. In a node console it is working fine, in the browser, it seems to be falling back to the builtin URL function. Feels like a naming clash.

jsarafajr commented 3 years ago

@krisztian-fl Hi, just to clarify, you use slackify-markdown in the browser, right? Never tried it in the browser by myself.

krisztian-fl commented 3 years ago

@krisztian-fl Hi, just to clarify, you use slackify-markdown in the browser, right? Never tried it in the browser by myself.

@jsarafajr yep, it's being used in frontend code. I'm gonna try aliasing that import and get back to you with the results.

krisztian-fl commented 3 years ago

@jsarafajr Here's a rather simple fix, using the builtin URL class: https://github.com/jsarafajr/slackify-markdown/pull/24

jsarafajr commented 3 years ago

@krisztian-fl thanks, published a new version with the fix.