File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import {basename, extname} from 'path';
5
5
const whitespaceRegex = / \W + / g;
6
6
7
7
/** Regular expression that matches example comments. */
8
- const exampleCommentRegex = / < ! - - \W * e x a m p l e \( ( [ ^ ) ] + ) \) \W * - - > / g;
8
+ const exampleCommentRegex = / < ! - - \W * e x a m p l e \( \{ ( . * \: . * ) + \} \) \W * - - > / g;
9
9
10
10
/**
11
11
* Custom renderer for marked that will be used to transform markdown files to HTML
@@ -52,12 +52,20 @@ export class DocsMarkdownRenderer extends Renderer {
52
52
* `<!-- example(name) -->` turns into `<div material-docs-example="name"></div>`
53
53
*/
54
54
html ( html : string ) {
55
- html = html . replace ( exampleCommentRegex , ( _match : string , name : string ) =>
56
- `<div material-docs-example="${ name } "></div>`
57
- ) ;
55
+ html = html . replace ( exampleCommentRegex , ( _match : string , content : string ) =>
56
+ {
57
+ const parsedContent = JSON . parse ( content ) ;
58
+ const exampleName = parsedContent [ 'example' ]
59
+ const file = parsedContent [ 'file' ] ;
60
+ const lines = parsedContent [ 'lines' ] ;
61
+ const expanded = ! ! parsedContent [ 'expanded' ] ;
62
+ return `<div material-docs-example="${ exampleName } " file="${ file } " lines="${ lines } " exapnded="${ expanded } "></div>` ;
63
+ }
58
64
59
- return super . html ( html ) ;
60
- }
65
+ ) ;
66
+
67
+ return super . html ( html ) ;
68
+ }
61
69
62
70
/**
63
71
* Method that will be called after a markdown file has been transformed to HTML. This method
You can’t perform that action at this time.
0 commit comments