Skip to content

Commit

Permalink
fix: fix blockquote paragrph issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 3, 2020
1 parent 9dc9023 commit 3996a00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/app/presentation/ledge-helper/ledge-helper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export class LedgeHelperComponent implements OnInit {
- list
- item
> spliqt
+ a
+ a
Expand Down
15 changes: 10 additions & 5 deletions src/app/shared/ledge-render/ledge-render.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import LedgeMarkdownConverter from '../components/model/ledge-markdown-converter
styleUrls: ['./ledge-render.component.scss'],
})
export class LedgeRenderComponent implements OnInit, AfterViewInit, OnChanges {
constructor() {}
@Input()
content: string;
markdownData: any[] = [];
token = null;
tokens: TokensList | any = [];
listQueue = [];

constructor() {}
isPureParagraph = true;

ngOnInit(): void {
this.renderContent(this.content);
Expand Down Expand Up @@ -79,9 +80,11 @@ export class LedgeRenderComponent implements OnInit, AfterViewInit, OnChanges {
return '';
case 'blockquote_start':
let body = '';
this.isPureParagraph = false;
while (this.next().type !== 'blockquote_end') {
body += this.tok();
}
this.isPureParagraph = true;
this.markdownData.push({ type: 'blockquote', text: body });
break;
case 'paragraph':
Expand Down Expand Up @@ -162,10 +165,12 @@ export class LedgeRenderComponent implements OnInit, AfterViewInit, OnChanges {

private handleParaGraph(token: marked.Tokens.Paragraph) {
const inline = marked.inlineLexer(token.text, this.tokens.links);
this.markdownData.push({
type: 'paragraph',
data: inline,
});
if (this.isPureParagraph) {
this.markdownData.push({
type: 'paragraph',
data: inline,
});
}

return inline;
}
Expand Down

0 comments on commit 3996a00

Please sign in to comment.