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 parser #2

Merged
merged 9 commits into from
Aug 29, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat(posts):tidy up the posts area
  • Loading branch information
Jason Hodges committed Aug 29, 2017
commit ffb727099b7352a484aa3c2d86eafbdc7dfde53d
7 changes: 2 additions & 5 deletions src/app/ngx-blog/components/post/post.component.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/ngx-blog/components/post/post.component.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions src/app/ngx-blog/components/post/post.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import 'prismjs/components/prism-typescript';

@Component({
selector: 'ngxb-post, [ngxb-post]',
// templateUrl: 'post.component.html',
template: `
<ng-content></ng-content>`,
encapsulation: ViewEncapsulation.None,
Expand All @@ -35,15 +34,14 @@ export class PostComponent implements OnInit, OnChanges, AfterViewInit {
constructor(public postsService: PostsService,
public element: ElementRef) { }

ngOnInit() { }
ngOnInit() { }

ngAfterViewInit() {
if (this.data) {
this.handleData();
return;
}
if (this.src) {
console.log('src: \n', this.src);
this.handleSrc();
return;
}
Expand All @@ -52,11 +50,11 @@ export class PostComponent implements OnInit, OnChanges, AfterViewInit {

// SimpleChanges parameter is required for AoT compilation (do not remove)
ngOnChanges(changes: SimpleChanges) {
if ('data' in changes) {
if (changes.data) {
this.handleData();
return;
}
if ('src' in changes) {
if (changes.src) {
this.handleSrc();
return;
}
Expand All @@ -80,7 +78,6 @@ export class PostComponent implements OnInit, OnChanges, AfterViewInit {
}

handleRaw(raw: string) {
// const markdown = this.prepare(raw);
const markdown = raw;
this.element.nativeElement.innerHTML = marked(markdown);
Prism.highlightAll(false);
Expand Down
9 changes: 0 additions & 9 deletions src/app/ngx-blog/components/posts/posts.component.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/ngx-blog/components/posts/posts.component.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions src/app/ngx-blog/components/posts/posts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,12 @@ export class PostsComponent implements OnInit {

ngOnInit() {
this.postsService.getPosts().subscribe((e) => {
debugger;
console.log('%c*** COMP: PostsComponent | function ngOnInit ***', 'background-color: blue;color:white;font-style:bold;', e)
e.entries.map((p: any) => {
this.tap(p, 'p: ');
this.mainPosts.push({
title: p.post.attributes.title,
body: p.post.body
});
});
console.log('%c*** COMP: PostsComponent | function ngOnInit ***', 'background-color: blue;color:white;font-style:bold;', this.mainPosts)
});
}

tap(x: any, w?: string) {
console.log(`%c ${ w ? w : '*****'}`, 'background-color:yellow;color:black;font-style:bold;padding-right: 20px;', x);
return x;
};
}
5 changes: 1 addition & 4 deletions src/app/ngx-blog/services/posts.service.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/ngx-blog/services/posts.service.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions src/app/ngx-blog/services/posts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ export class PostsService {

this.md.setOptions({
gfm: true,
breaks: true,
// highlight: function (code: any) {
// return require('highlightjs').highlightAuto(code).value;
// }
breaks: true
});
}

convert(markdown: string) {
debugger;
let raw = markdown.replace(/"/g, '');
// this.prepare(raw);
return this.md(raw);
}

Expand Down Expand Up @@ -62,7 +57,6 @@ export class PostsService {
}

extractData(response: Response) {
debugger;
return response.text() || '';
}

Expand Down