Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markdown: fix pipe #407

Merged
merged 1 commit into from
Jun 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions projects/rero/ng-core/src/lib/pipe/markdown.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import marked from 'marked';
import { Nl2brPipe } from './nl2br.pipe';

/**
* Pipe to transform markdown to html.
Expand All @@ -39,7 +38,7 @@ export class MarkdownPipe implements PipeTransform {
* @param value Markdown initial value.
* @returns HTML corresponding to markdown.
*/
transform(value: string): string {
return new Nl2brPipe(this._sanitizer).transform(marked(value));
transform(value: string): SafeHtml {
return this._sanitizer.bypassSecurityTrustHtml(marked(value, { gfm: true, breaks: false }));
}
}