Hello everyone,
As we know Firebase saves strings as a single line (ASCII based) and "removes" newline characters indireclty. I encounter a problem with that since I want to save markdown text (rich text) in fields and render it in my Angular 17 application. I tried using a pipe which places \n or <br> breaks, where newlines existed before because I expect Firebase to save \n but in single line and ngx-markdown can't use it correctly.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'newlineFormat',
standalone: true,
})
export class NewlineFormatPipe implements PipeTransform {
transform(value: string | undefined): string {
if (!value) {
return '';
}
return value.replaceAll(/\\n/g, '\n'); // Also tried with other combinations like \n etc.
}
}
<markdown>{{ course.content | newlineFormat }}</markdown>
Has anyone ever encountered similar problems on how to fix this or is there a firebase utility for this?
Thanks for help! 