Skip to content

Commit

Permalink
fix: rendering emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Feb 7, 2017
1 parent cbaee21 commit 8c7e4d7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
## 2.0.3
### Bug fixes
- fix: rendering emojis
- fix: css var polyfill

## 2.0.2
Expand Down
2 changes: 1 addition & 1 deletion src/render.js
Expand Up @@ -39,7 +39,7 @@ export function init () {
renderer.code = function (code, lang = '') {
const hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)

return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl.replace(/:/g, '__colon__')}</code></pre>`
return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
}
renderer.link = function (href, title, text) {
if (!/:/.test(href)) {
Expand Down
1 change: 1 addition & 0 deletions src/util.js
Expand Up @@ -160,6 +160,7 @@ export const merge = Object.assign || function (to) {

export function emojify (text) {
return text
.replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g, match => match.replace(/:/g, '__colon__'))
.replace(/:(\w*?):/ig, '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/$1.png" alt="$1" />')
.replace(/__colon__/g, ':')
}
Expand Down

0 comments on commit 8c7e4d7

Please sign in to comment.