File tree 4 files changed +17
-5
lines changed
main/resources/META-INF/resources/frontend
java/com/flowingcode/vaadin/addons/demo
resources/META-INF/resources/frontend
4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,8 @@ The `// begin-block` and `// end-block` comments are removed after post-processi
183
183
add(other);
184
184
```
185
185
186
+ For highlighting code in CSS, use ` /*// begin-block filenameAndId */ `
187
+
186
188
<!-- FROM https://github.com/FlowingCode/CommonsDemo/pull/62 -->
187
189
![ image] ( https://github.com/FlowingCode/CommonsDemo/assets/11554739/02063272-029f-4b4b-bd6f-821f2f8a0158 )
188
190
Original file line number Diff line number Diff line change @@ -416,7 +416,11 @@ pre[class*="language-"] {
416
416
//process instructions in element nodes
417
417
if ( nodes [ i ] . nodeType != 1 ) continue ;
418
418
419
- const text = nodes [ i ] . textContent ! ;
419
+ var text = nodes [ i ] . textContent ! ;
420
+
421
+ var blockComment = text . match ( "^/\\*(?<content>(\\*(?!\/)|[^\\*])*)\\*\/" ) ;
422
+ if ( blockComment ) text = blockComment . groups ! . content ;
423
+
420
424
var m = text . match ( "^//\\s*begin-block\\s+(\\S+)\\s*" ) ;
421
425
422
426
if ( m ) {
Original file line number Diff line number Diff line change @@ -41,11 +41,15 @@ public MultiSourceDemo() {
41
41
div .addClassName ("custom-style" );
42
42
SourceCodeViewer .highlightOnHover (div , "main" );
43
43
add (div );
44
- // end-block
45
44
46
45
Button button1 = new Button ("Highlight code in AdditionalSources" );
47
46
SourceCodeViewer .highlightOnClick (button1 , "AdditionalSources.java#fragment" );
48
- add (button1 );
47
+ add (new Div (button1 ));
48
+
49
+ Button button2 = new Button ("Highlight code in CSS" );
50
+ SourceCodeViewer .highlightOnClick (button2 , "multi-source-demo.css#css-fragment" );
51
+ add (new Div (button2 ));
52
+ // end-block
49
53
}
50
54
51
55
}
Original file line number Diff line number Diff line change
1
+ /*// begin-block css */
1
2
.custom-style {
2
- color : red;
3
- }
3
+ color : red;
4
+ }
5
+ /*// end-block */
You can’t perform that action at this time.
0 commit comments