@@ -406,32 +406,6 @@ mod test {
406406use rocket:: local:: asynchronous:: Client ;
407407use rocket:: { Build , Rocket } ;
408408
409- #[ test]
410- fn test_syntax_highlighting ( ) {
411- let code =r#"
412- # Hello
413-
414- ```postgresql
415- SELECT * FROM test;
416- ```
417- "# ;
418-
419- let arena =Arena :: new ( ) ;
420- let root =parse_document ( & arena, code, & options ( ) ) ;
421-
422- // Style headings like we like them
423- let mut plugins =ComrakPlugins :: default ( ) ;
424- let binding =MarkdownHeadings :: new ( ) ;
425- plugins. render . heading_adapter =Some ( & binding) ;
426- plugins. render . codefence_syntax_highlighter =Some ( & SyntaxHighlighter { } ) ;
427-
428- let mut html =vec ! [ ] ;
429- format_html_with_plugins ( root, & options ( ) , & mut html, & plugins) . unwrap ( ) ;
430- let html =String :: from_utf8 ( html) . unwrap ( ) ;
431-
432- assert ! ( html. contains( "<span class=\" syntax-highlight\" >SELECT</span>" ) ) ;
433- }
434-
435409#[ test]
436410fn test_wrapping_tables ( ) {
437411let markdown =r#"
@@ -574,4 +548,77 @@ This is the end of the markdown
574548 rsp. status( )
575549) ;
576550}
551+
552+ // Test backend for line highlights and line numbers added
553+ #[ test]
554+ fn gitbook_codeblock_test ( ) {
555+ let contents =r#"
556+ {% code title="Test name for html" lineNumbers="true" %}
557+ ```javascript-highlightGreen="1"
558+ import something
559+ let a = 1
560+ ```
561+ {% endcode %}
562+ "# ;
563+
564+ let expected =r#"
565+ <div class="code-block with-title line-numbers">
566+ <div class="title">
567+ Test name for html
568+ </div>
569+ <pre data-controller="copy">
570+ <div class="code-toolbar">
571+ <span data-action="click->copy#codeCopy" class="material-symbols-outlined btn-code-toolbar">content_copy</span>
572+ <span class="material-symbols-outlined btn-code-toolbar" disabled>link</span>
573+ <span class="material-symbols-outlined btn-code-toolbar" disabled>edit</span>
574+ </div>
575+ <code language='javascript' data-controller="code-block">
576+ <div class="highlight code-line-highlight-green">importsomething</div>
577+ <div class="highlight code-line-highlight-none">leta=1</div>
578+ <div class="highlight code-line-highlight-none"></div>
579+ </code>
580+ </pre>
581+ </div>"# ;
582+
583+ // Parse Markdown
584+ let arena =Arena :: new ( ) ;
585+ let spaced_contents =crate :: utils:: markdown:: gitbook_preprocess ( contents) ;
586+ let root =parse_document ( & arena, & spaced_contents, & crate :: utils:: markdown:: options ( ) ) ;
587+
588+ crate :: utils:: markdown:: wrap_tables ( root, & arena) . unwrap ( ) ;
589+
590+ // MkDocs, gitbook syntax support, e.g. tabs, notes, alerts, etc.
591+ crate :: utils:: markdown:: mkdocs ( root, & arena) . unwrap ( ) ;
592+
593+ // Style headings like we like them
594+ let mut plugins =ComrakPlugins :: default ( ) ;
595+ let headings =crate :: utils:: markdown:: MarkdownHeadings :: new ( ) ;
596+ plugins. render . heading_adapter =Some ( & headings) ;
597+ plugins. render . codefence_syntax_highlighter =
598+ Some ( & crate :: utils:: markdown:: SyntaxHighlighter { } ) ;
599+
600+ let mut html =vec ! [ ] ;
601+ format_html_with_plugins (
602+ root,
603+ & crate :: utils:: markdown:: options ( ) ,
604+ & mut html,
605+ & plugins,
606+ )
607+ . unwrap ( ) ;
608+ let html =String :: from_utf8 ( html) . unwrap ( ) ;
609+
610+ println ! ( "expected: {}" , expected) ;
611+
612+ println ! ( "response: {}" , html) ;
613+
614+ assert ! (
615+ html. chars( )
616+ . filter( |c| !c. is_whitespace( ) )
617+ . collect:: <String >( )
618+ == expected
619+ . chars( )
620+ . filter( |c| !c. is_whitespace( ) )
621+ . collect:: <String >( )
622+ )
623+ }
577624}