Skip to content

Commit

Permalink
Fix Markdown links not working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Yichuan Shen committed Jan 23, 2018
1 parent 5cbc27e commit 0341833
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
**Fixed**

* Fix color of hoshi points not being themed
* Fix Markdown links not working properly

**Changed**

Expand Down
28 changes: 16 additions & 12 deletions src/components/ContentDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,22 @@ class ContentDisplay extends Component {
}
}

render({tag, content}) {
return h(tag, Object.assign({
ref: el => this.element = el,
dangerouslySetInnerHTML: {
__html: htmlify(
content
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
)
}
}, this.props))
render({tag, content, children}) {
return content != null
? h(tag, Object.assign({
ref: el => this.element = el,
dangerouslySetInnerHTML: {
__html: htmlify(
content
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
)
}
}, this.props))
: h(tag, Object.assign({
ref: el => this.element = el
}, this.props), children)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/MarkdownContentDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ function Paragraph({children}) {
}

function Link({href, title, children}) {
if (href.match(/^((ht|f)tps?:\/\/|mailto:)/) == null)
if (href.match(/^((ht|f)tps?:\/\/|mailto:)/) == null)
return h('span', {}, typographer(children))

return h('a', {class: 'external', href, title}, typographer(children))
return h(ContentDisplay, {}, h('a', {class: 'external', href, title}, typographer(children)))
}

function Image({src, alt}) {
Expand Down

0 comments on commit 0341833

Please sign in to comment.