File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
crates/crates_io_markdown Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -22,14 +22,15 @@ impl<'a> MarkdownRenderer<'a> {
2222 (
2323 "code" ,
2424 hashset ( & [
25+ // Languages
2526 "language-bash" ,
26- "language-clike " ,
27+ "language-c " ,
2728 "language-glsl" ,
2829 "language-go" ,
2930 "language-ini" ,
3031 "language-javascript" ,
3132 "language-json" ,
32- "language-markup " ,
33+ "language-xml " ,
3334 "language-mermaid" ,
3435 "language-protobuf" ,
3536 "language-ruby" ,
@@ -38,6 +39,10 @@ impl<'a> MarkdownRenderer<'a> {
3839 "language-sql" ,
3940 "language-toml" ,
4041 "language-yaml" ,
42+ // Aliases
43+ "language-rs" ,
44+ "language-clike" ,
45+ "language-markup" ,
4146 ] ) ,
4247 ) ,
4348 ( "section" , hashset ( & [ "footnotes" ] ) ) ,
@@ -401,6 +406,27 @@ mod tests {
401406 "### ) ;
402407 }
403408
409+ #[ test]
410+ fn code_block_with_syntax_highlighting_with_aliases ( ) {
411+ let code_block = "```rs, no_run\n println!(\" Hello World\" );\n ```" ;
412+ assert_snapshot ! ( markdown_to_html( code_block, None , "" ) , @r###"
413+ <pre><code class="language-rs">println!("Hello World");
414+ </code></pre>
415+ "### ) ;
416+
417+ let code_block = "```markup, no_run\n <hello>World</hello>\n ```" ;
418+ assert_snapshot ! ( markdown_to_html( code_block, None , "" ) , @r###"
419+ <pre><code class="language-markup"><hello>World</hello>
420+ </code></pre>
421+ "### ) ;
422+
423+ let code_block = "```clike, no_run\n int main() { }\n ```" ;
424+ assert_snapshot ! ( markdown_to_html( code_block, None , "" ) , @r###"
425+ <pre><code class="language-clike">int main() { }
426+ </code></pre>
427+ "### ) ;
428+ }
429+
404430 #[ test]
405431 fn text_with_forbidden_class_attribute ( ) {
406432 let text = "<p class='bad-class'>Hello World!</p>" ;
You can’t perform that action at this time.
0 commit comments