${code}
`;
23 | }
24 |
25 | // nest inline code block within pre tags
26 | renderer.codespan = (code) => {
27 | return `${code}
`;
28 | }
29 | this.md = marked.setOptions({
30 | gfm: true,
31 | tables: true,
32 | breaks: false,
33 | pedantic: false,
34 | sanitize: true,
35 | smartLists: true,
36 | smartypants: false,
37 | renderer: renderer
38 | });
39 | }
40 |
41 | ngOnChanges() {
42 | this.parsedMarkdown = this.md.parse(this.markdown || '');
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/components/prism.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Input, Renderer2, ElementRef, AfterViewInit } from '@angular/core'
2 | declare var Prism: any
3 |
4 | @Component({
5 | selector: 'prism-block',
6 | template: ``,
7 | })
8 | export class PrismComponent implements AfterViewInit {
9 | @Input() code: string
10 | @Input() language: string
11 |
12 | private preNode: Node
13 | private codeNode: Node
14 | private nativeElement: Node
15 |
16 | ngAfterViewInit () {
17 | this.preNode = this._renderer.createElement('pre')
18 | this.codeNode = this._renderer.createElement('code')
19 | this._renderer.addClass(this.codeNode, 'language-' + this.language)
20 | this._renderer.appendChild(this.nativeElement, this.preNode)
21 | this._renderer.appendChild(this.preNode, this.codeNode)
22 | this.codeNode.textContent = this.code
23 |
24 | Prism.highlightElement(this.codeNode)
25 | }
26 |
27 | constructor(private _renderer: Renderer2, private _el: ElementRef) {
28 | this.nativeElement = _el.nativeElement
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/components/ui-api.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Input } from '@angular/core'
2 | import { ComponentAPI } from '../interfaces'
3 | import { colors, fonts } from '../styles'
4 |
5 |
6 | @Component({
7 | selector: 'ui-api',
8 | template: `
9 | {{example.description}}
24 |{{guide.description}}
25 |