File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-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,16 @@ 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
+ return `<div material-docs-example="${ parsedContent [ 'example' ] } " file="${ parsedContent [ 'file' ] } " lines="${ parsedContent [ 'lines' ] } "></div>` ;
59
+ }
58
60
59
- return super . html ( html ) ;
60
- }
61
+ ) ;
62
+
63
+ return super . html ( html ) ;
64
+ }
61
65
62
66
/**
63
67
* 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