@@ -10,10 +10,9 @@ use std::{boxed::Box, io::BufWriter};
1010
1111use clap:: { Parser , ValueEnum } ;
1212
13- use comrak:: {
14- adapters:: SyntaxHighlighterAdapter , plugins:: syntect:: SyntectAdapter , Arena , ListStyleType ,
15- Options , Plugins ,
16- } ;
13+ #[ cfg( feature = "syntect" ) ]
14+ use comrak:: { adapters:: SyntaxHighlighterAdapter , plugins:: syntect:: SyntectAdapter } ;
15+ use comrak:: { Arena , ListStyleType , Options , Plugins } ;
1716use comrak:: { ExtensionOptions , ParseOptions , RenderOptions } ;
1817
1918const EXIT_SUCCESS : i32 = 0 ;
@@ -136,6 +135,7 @@ struct Cli {
136135
137136 /// Syntax highlighting for codefence blocks. Choose a theme or 'none' for disabling.
138137 #[ arg( long, value_name = "THEME" , default_value = "base16-ocean.dark" ) ]
138+ #[ cfg( feature = "syntect" ) ]
139139 syntax_highlighting : String ,
140140
141141 /// Specify bullet character for lists (-, +, *) in CommonMark output
@@ -315,16 +315,22 @@ fn main() -> Result<(), Box<dyn Error>> {
315315 render,
316316 } ;
317317
318+ #[ cfg( feature = "syntect" ) ]
318319 let syntax_highlighter: Option < & dyn SyntaxHighlighterAdapter > ;
319- let mut plugins : Plugins = Plugins :: default ( ) ;
320+ # [ cfg ( feature = "syntect" ) ]
320321 let adapter: SyntectAdapter ;
321322
322- let theme = cli. syntax_highlighting ;
323- if theme. is_empty ( ) || theme == "none" {
324- syntax_highlighter = None ;
325- } else {
326- adapter = SyntectAdapter :: new ( Some ( & theme) ) ;
327- syntax_highlighter = Some ( & adapter) ;
323+ let mut plugins: Plugins = Plugins :: default ( ) ;
324+
325+ #[ cfg( feature = "syntect" ) ]
326+ {
327+ let theme = cli. syntax_highlighting ;
328+ if theme. is_empty ( ) || theme == "none" {
329+ syntax_highlighter = None ;
330+ } else {
331+ adapter = SyntectAdapter :: new ( Some ( & theme) ) ;
332+ syntax_highlighter = Some ( & adapter) ;
333+ }
328334 }
329335
330336 let mut s: Vec < u8 > = Vec :: with_capacity ( 2048 ) ;
@@ -356,7 +362,10 @@ fn main() -> Result<(), Box<dyn Error>> {
356362 } else {
357363 match cli. format {
358364 Format :: Html => {
359- plugins. render . codefence_syntax_highlighter = syntax_highlighter;
365+ #[ cfg( feature = "syntect" ) ]
366+ {
367+ plugins. render . codefence_syntax_highlighter = syntax_highlighter;
368+ }
360369 comrak:: format_html_with_plugins
361370 }
362371 Format :: Xml => comrak:: format_xml_with_plugins,
0 commit comments