@@ -64,7 +64,7 @@ export class DocsMarkdownRenderer extends Renderer {
6464 * {
6565 * "example": "exampleName",
6666 * "file": "example-html.html",
67- * "region": "some-region",
67+ * "region": "some-region"
6868 * }
6969 * ) -->`
7070 * turns into
@@ -78,20 +78,21 @@ export class DocsMarkdownRenderer extends Renderer {
7878 * `<div material-docs-example="name"></div>`
7979 */
8080 html ( html : string ) {
81- html = html . replace ( exampleCommentRegex , ( _match : string , content : string ) => {
82- if ( content . startsWith ( '{' ) ) {
83- const { example, file, region} = JSON . parse ( content ) ;
84- return `<div material-docs-example="${ example } "
85- file="${ file } "
86- region="${ region } "></div>` ;
87- } else {
88- return `<div material-docs-example="${ content } "></div>` ;
89- }
90- }
91- ) ;
92-
93- return super . html ( html ) ;
94- }
81+ html = html . replace ( exampleCommentRegex , ( _match : string , content : string ) => {
82+ // using [\s\S]* because .* does not match line breaks
83+ if ( content . match ( / \{ [ \s \S ] * \} / g) ) {
84+ const { example, file, region} = JSON . parse ( content ) ;
85+ return `<div material-docs-example="${ example } "
86+ file="${ file } "
87+ region="${ region } "></div>` ;
88+ } else {
89+ return `<div material-docs-example="${ content } "></div>` ;
90+ }
91+ }
92+ ) ;
93+
94+ return super . html ( html ) ;
95+ }
9596
9697 /**
9798 * Method that will be called after a markdown file has been transformed to HTML. This method
0 commit comments