Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Ensure existing marked renderer code runs with customization (#4078)
* Ensure existing marked renderer code runs with customization * Use noopener / noreferrer for marked links
- Loading branch information
Showing
2 changed files
with
22 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,22 @@ | ||
| angular.module('loomioApp').config (markedProvider, renderProvider) -> | ||
| markedProvider.setOptions | ||
| gfm: true | ||
| sanitize: true | ||
| breaks: true | ||
| markedProvider.setRenderer(renderProvider.$get(0).createRenderer()) | ||
| angular.module('loomioApp').config (markedProvider) -> | ||
| customRenderer = (opts) -> | ||
| _super = new marked.Renderer(opts) | ||
| renderer = _.clone(_super) | ||
| cook = (text) -> | ||
| text = emojione.shortnameToImage(text) | ||
| text = text.replace(/\[\[@([a-zA-Z0-9]+)\]\]/g, "<a class='lmo-user-mention' href='/u/$1'>@$1</a>") | ||
| text | ||
|
|
||
| renderer.paragraph = (text) -> _super.paragraph cook(text) | ||
| renderer.listitem = (text) -> _super.listitem cook(text) | ||
| renderer.tablecell = (text) -> _super.tablecell cook(text) | ||
|
|
||
| renderer.heading = (text, level) -> | ||
| _super.heading(emojione.shortnameToImage(text), level, text) | ||
|
|
||
| renderer.link = (href, title, text) -> | ||
| _super.link(href, title, text).replace('<a ', '<a rel="noopener noreferrer" target="_blank" ') | ||
|
|
||
| renderer | ||
|
|
||
| markedProvider.setRenderer customRenderer(gfm: true, sanitize: true, breaks: true) |
This file was deleted.
Oops, something went wrong.