@@ -956,7 +956,7 @@ fn hide_lines(html: &str, code_config: &Code) -> String {
956
956
let classes = & caps[ 2 ] ;
957
957
let code = & caps[ 3 ] ;
958
958
959
- if classes. contains ( "language-rust" ) {
959
+ if classes. contains ( "language-rust" ) && code_config . default_hidelines {
960
960
format ! (
961
961
"<code class=\" {}\" >{}</code>" ,
962
962
classes,
@@ -1283,6 +1283,38 @@ mod tests {
1283
1283
map. insert ( "python" . to_string ( ) , "~" . to_string ( ) ) ;
1284
1284
map
1285
1285
} ,
1286
+ default_hidelines : true ,
1287
+ } ,
1288
+ ) ;
1289
+ assert_eq ! ( & * got, * should_be) ;
1290
+ }
1291
+ }
1292
+
1293
+ #[ test]
1294
+ fn no_default_hide_lines ( ) {
1295
+ let inputs = [
1296
+ (
1297
+ "<pre class=\" playground\" ><code class=\" language-rust\" >\n # #![allow(unused)]\n #fn main() {\n x()\n #}</code></pre>" ,
1298
+ "<pre class=\" playground\" ><code class=\" language-rust\" >\n # #![allow(unused)]\n #fn main() {\n x()\n #}</code></pre>" , ) ,
1299
+ (
1300
+ "<pre class=\" playground\" ><code class=\" language-rust editable\" >let s = \" foo\n # bar\n \" ;</code></pre>" ,
1301
+ "<pre class=\" playground\" ><code class=\" language-rust editable\" >let s = \" foo\n # bar\n \" ;</code></pre>" , ) ,
1302
+ (
1303
+ "<pre class=\" playground\" ><code class=\" language-rust editable\" >let s = \" foo\n ## bar\n \" ;</code></pre>" ,
1304
+ "<pre class=\" playground\" ><code class=\" language-rust editable\" >let s = \" foo\n ## bar\n \" ;</code></pre>" , ) ,
1305
+ (
1306
+ "<pre class=\" playground\" ><code class=\" language-rust editable\" >let s = \" foo\n # bar\n #\n \" ;</code></pre>" ,
1307
+ "<pre class=\" playground\" ><code class=\" language-rust editable\" >let s = \" foo\n # bar\n #\n \" ;</code></pre>" , ) ,
1308
+ (
1309
+ "<code class=\" language-rust ignore\" >let s = \" foo\n # bar\n \" ;</code>" ,
1310
+ "<code class=\" language-rust ignore\" >let s = \" foo\n # bar\n \" ;</code>" , ) ,
1311
+ ] ;
1312
+ for ( src, should_be) in & inputs {
1313
+ let got = hide_lines (
1314
+ src,
1315
+ & Code {
1316
+ hidelines : HashMap :: < String , String > :: default ( ) ,
1317
+ default_hidelines : false ,
1286
1318
} ,
1287
1319
) ;
1288
1320
assert_eq ! ( & * got, * should_be) ;
0 commit comments