Skip to content

Commit

Permalink
fix(marked): url parsing conflict between marked and native url parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ritz078 committed Nov 9, 2015
1 parent 005f88a commit eb6997f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h1>Loading embed.js in a block</h1>
else
"C"
```
Flavum buff.ly/1fPIjQf , ferox http://open.spotify.com/track/4th1RQAelzqgY7wL53UGQt torquiss vix aperto de http://plnkr.co/edit/AK732k bi-color, http://www.iitr.ac.in/Main/assets/images/topold.jpg audax nixus.Pol, alter devatio!Crescere aliquando ducunt ad noster lixa. :smile: :P https://www.youtube.com/watch?v=bQRLVxZHKPs http://www.liveleak.com/view?i=42a_1426999994 https://gist.github.com/jeremiahlee/1748966 https://gist.github.com/thomasmb/7132686 https://twitter.com/ProductHunt/status/652826210666418176/photo/1 http://www.ted.com/talks/monica_lewinsky_the_price_of_shame http://www.dailymotion.com/video/x2k8un2_2015-wc-nz-vs-wi-holder-reacts-on-guptills-237_sport https://vine.co/v/bjHh0zHdgZT https://vimeo.com/119199079 http://www.w3schools.com/html/horse.mp3
Flavum buff.ly/1fPIjQf , ferox http://open.spotify.com/track/4th1RQAelzqgY7wL53UGQt torquiss vix aperto de http://plnkr.co/edit/AK732k bi-color, http://www.iitr.ac.in/Main/assets/images/topold.jpg audax nixus.Pol, alter devatio!Crescere aliquando [kkjhjh](http://github.com) ducunt ad noster lixa. :smile: :P https://www.youtube.com/watch?v=bQRLVxZHKPs http://www.liveleak.com/view?i=42a_1426999994 https://gist.github.com/jeremiahlee/1748966 https://gist.github.com/thomasmb/7132686 https://twitter.com/ProductHunt/status/652826210666418176/photo/1 http://www.ted.com/talks/monica_lewinsky_the_price_of_shame http://www.dailymotion.com/video/x2k8un2_2015-wc-nz-vs-wi-holder-reacts-on-guptills-237_sport https://vine.co/v/bjHh0zHdgZT https://vimeo.com/119199079 http://www.w3schools.com/html/horse.mp3
</div>
<div id="block2" class="block">
Cur rumor nocere?Emeritis adelphis satis perderes domina est.Gloss cadunt in bi-color brema!
Expand Down
7 changes: 4 additions & 3 deletions dist/embed.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/embed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/embed.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/js/embed.es6
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const helper = require('./modules/video/helper.es6');

this.options.beforeEmbedJSApply();

let output = options.link && build.LINK ? (new Url(input, options).process()) : output;
let output = options.link && build.LINK ? (new Url(input, options).process()) : input;
output = options.marked && build.MARKDOWN ? (new Markdown(output, options).process()) : output;
output = options.emoji && build.EMOJI ? (new Emoji(output, options).process()) : output;
output = options.fontIcons && build.SMILEY ? (new Smiley(output, options).process()) : output;
Expand Down
22 changes: 15 additions & 7 deletions src/js/modules/markdown.es6
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@ class Markdown {
process() {
let renderer = new marked.Renderer()
renderer.code = function(text) {
let highlightedCode = window.hljs ? hljs.highlightAuto(text) : {value:text}
let highlightedCode = window.hljs ? hljs.highlightAuto(text) : {
value: text
}
let language = window.hljs ? highlightedCode.language : ''
let template =`<pre><code class="ejs-code hljs ${language}">${highlightedCode.value}</code></pre>`;
let template = `<pre><code class="ejs-code hljs ${language}">${highlightedCode.value}</code></pre>`;
return template
}
renderer.paragraph = (text) => `<p> ${text} </p>` //for font smiley in end.
this.options.markedOptions.renderer = renderer
let output = marked(this.output, this.options.markedOptions)
return output
}
renderer.link = (text,title,link) => {
if (text.indexOf('&lt;/a') === -1) return text
if (text.match(/&gt;(.+)&lt;\/a/gi)){
return `<a href="${RegExp.$1}" rel=${this.options.linkOptions.rel}" target="${this.options.linkOptions.target}" title="${title}">${link}</a>`
}
}
renderer.paragraph = (text) => `<p> ${text} </p>` //for font smiley in end.
this.options.markedOptions.renderer = renderer
let output = marked(this.output, this.options.markedOptions)
return output
}
}

module.exports = Markdown

0 comments on commit eb6997f

Please sign in to comment.