Disable link detection, as per comment
This commit is contained in:
parent
6c7259eec8
commit
0eddea1937
1 changed files with 18 additions and 3 deletions
|
@ -16,10 +16,25 @@ limitations under the License.
|
||||||
|
|
||||||
import marked from 'marked';
|
import marked from 'marked';
|
||||||
|
|
||||||
|
// replace the default link renderer function
|
||||||
|
// to prevent marked from turning plain URLs
|
||||||
|
// into links, because tits algorithm is fairly
|
||||||
|
// poor, so let's send plain URLs rather than
|
||||||
|
// badly linkified ones (the linkifier Vector
|
||||||
|
// uses on message display is way better, eg.
|
||||||
|
// handles URLs with closing parens at the end).
|
||||||
|
const renderer = new marked.Renderer();
|
||||||
|
renderer.link = function(href, title, text) {
|
||||||
|
if (text == href) {
|
||||||
|
return href;
|
||||||
|
}
|
||||||
|
return marked.Renderer.prototype.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
// marked only applies the default options on the high
|
// marked only applies the default options on the high
|
||||||
// level marked() interface, so we do it here.
|
// level marked() interface, so we do it here.
|
||||||
const marked_options = Object.assign({}, {
|
const marked_options = Object.assign({}, marked.defaults, {
|
||||||
renderer: new marked.Renderer(),
|
renderer: renderer,
|
||||||
gfm: true,
|
gfm: true,
|
||||||
tables: true,
|
tables: true,
|
||||||
breaks: true,
|
breaks: true,
|
||||||
|
@ -27,7 +42,7 @@ const marked_options = Object.assign({}, {
|
||||||
sanitize: true,
|
sanitize: true,
|
||||||
smartLists: true,
|
smartLists: true,
|
||||||
smartypants: false,
|
smartypants: false,
|
||||||
}, marked.defaults);
|
});
|
||||||
|
|
||||||
const real_parser = new marked.Parser(marked_options);
|
const real_parser = new marked.Parser(marked_options);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue