question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTML a tag not rendered correcly

See original GitHub issue

Given this JS

import { href } from "cities"
const source = `Go <a href="${href}">here</a>`

<Markdown source={source}/>

The output is not a link but a span with the links “here” only.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

4reactions
ScarellaDevcommented, Jan 5, 2018

@sonaye You can use the renderers option like this:

<Markdown
      source={text}
      renderers={{link : this.markdownLinkRenderer}}
    />

And an example of the markdownLinkRenderer function (I use it to add target=“_blank” to non relative links):

markdownLinkRenderer(props) {
    return props.href.startsWith("/") ?
      <a href={props.href}>{props.children}</a> :
      <a href={props.href} target="_blank" rel="nofollow noopener noreferrer">{props.children}</a>;
  }
1reaction
brandonstephenscommented, Apr 20, 2018

Appears to work if you take:

const source = `Go <a href="${href}">here</a>`

and make it

const source = `<p>Go <a href="${href}">here</a></p>`

Not sure if this works for your context or not, hope it helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

html tags surrounded with " " not rendering - Stack Overflow
If it's coming from a server and you are adding it to the DOM with javascript, you'll want to set innerHTML as it...
Read more >
[Bug] Not rendering properly · Issue #456 - GitHub
Bug Report. HTML is not being rendered properly. ... This is actually a bug: a unsupported tag should not break the inline context....
Read more >
My custom HTML code doesn't render correctly on Gmail
My problem is: After creating a new email with “Code Mode”, editing the HTML, and saving the email, Mautic (or probably GrapesJS) refactor...
Read more >
HTML email is not rendering correctly in Outlook
However, randomly in the email the HTML code was not rendered correctly; like </span> or &nb sp randomly appear along the lines.
Read more >
How can I prevent HTML tags getting rendered as plain text?
First you can mark your field as "raw" and the html would render correctly. {{ your_field | raw }} should render ok.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found