mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-12-05 02:01:32 +00:00
Create Markdown service
This commit is contained in:
parent
154c6c8fef
commit
f14be39faf
15
src/app/markdown.service.spec.ts
Normal file
15
src/app/markdown.service.spec.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { MarkdownService } from './markdown.service';
|
||||
|
||||
describe('MarkdownService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [MarkdownService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([MarkdownService], (service: MarkdownService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
14
src/app/markdown.service.ts
Normal file
14
src/app/markdown.service.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Converter } from 'showdown';
|
||||
|
||||
@Injectable()
|
||||
export class MarkdownService {
|
||||
private converter: Converter;
|
||||
constructor() {
|
||||
this.converter = new Converter();
|
||||
}
|
||||
|
||||
convertToHtml(text: string) {
|
||||
return this.converter.makeHtml(text);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user