@@ -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,23 @@ 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+ #[ cfg_attr( not( feature = "syntect" ) , allow( unused_mut) ) ]
324+ let mut plugins: Plugins = Plugins :: default ( ) ;
325+
326+ #[ cfg( feature = "syntect" ) ]
327+ {
328+ let theme = cli. syntax_highlighting ;
329+ if theme. is_empty ( ) || theme == "none" {
330+ syntax_highlighter = None ;
331+ } else {
332+ adapter = SyntectAdapter :: new ( Some ( & theme) ) ;
333+ syntax_highlighter = Some ( & adapter) ;
334+ }
328335 }
329336
330337 let mut s: Vec < u8 > = Vec :: with_capacity ( 2048 ) ;
@@ -356,7 +363,10 @@ fn main() -> Result<(), Box<dyn Error>> {
356363 } else {
357364 match cli. format {
358365 Format :: Html => {
359- plugins. render . codefence_syntax_highlighter = syntax_highlighter;
366+ #[ cfg( feature = "syntect" ) ]
367+ {
368+ plugins. render . codefence_syntax_highlighter = syntax_highlighter;
369+ }
360370 comrak:: format_html_with_plugins
361371 }
362372 Format :: Xml => comrak:: format_xml_with_plugins,
0 commit comments