File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
src/renderer/html_handlebars Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -935,8 +935,9 @@ fn add_playground_pre(
935
935
/// Modifies all `<code>` blocks to convert "hidden" lines and to wrap them in
936
936
/// a `<span class="boring">`.
937
937
fn hide_lines ( html : & str , code_config : & Code ) -> String {
938
- let language_regex = Regex :: new ( r"\blanguage-(\w+)\b" ) . unwrap ( ) ;
939
- let hidelines_regex = Regex :: new ( r"\bhidelines=(\S+)" ) . unwrap ( ) ;
938
+ static LANGUAGE_REGEX : Lazy < Regex > = Lazy :: new ( || Regex :: new ( r"\blanguage-(\w+)\b" ) . unwrap ( ) ) ;
939
+ static HIDELINES_REGEX : Lazy < Regex > = Lazy :: new ( || Regex :: new ( r"\bhidelines=(\S+)" ) . unwrap ( ) ) ;
940
+
940
941
CODE_BLOCK_RE
941
942
. replace_all ( html, |caps : & Captures < ' _ > | {
942
943
let text = & caps[ 1 ] ;
@@ -951,12 +952,12 @@ fn hide_lines(html: &str, code_config: &Code) -> String {
951
952
)
952
953
} else {
953
954
// First try to get the prefix from the code block
954
- let hidelines_capture = hidelines_regex . captures ( classes) ;
955
+ let hidelines_capture = HIDELINES_REGEX . captures ( classes) ;
955
956
let hidelines_prefix = match & hidelines_capture {
956
957
Some ( capture) => Some ( & capture[ 1 ] ) ,
957
958
None => {
958
959
// Then look up the prefix by language
959
- language_regex . captures ( classes) . and_then ( |capture| {
960
+ LANGUAGE_REGEX . captures ( classes) . and_then ( |capture| {
960
961
code_config. hidelines . get ( & capture[ 1 ] ) . map ( |p| p. as_str ( ) )
961
962
} )
962
963
}
You can’t perform that action at this time.
0 commit comments