@@ -9,6 +9,7 @@ use tracing_subscriber::{self, EnvFilter};
99
1010use technique:: formatting:: * ;
1111use technique:: formatting:: { self } ;
12+
1213use technique:: parsing;
1314
1415mod problem;
@@ -108,6 +109,15 @@ fn main() {
108109 PDF. By default this will highlight the source of the \
109110 input file for the purposes of reviewing the raw \
110111 procedure.")
112+ . arg (
113+ Arg :: new ( "output" )
114+ . short ( 'o' )
115+ . long ( "output" )
116+ . value_parser ( [ "pdf" , "typst" ] )
117+ . default_value ( "pdf" )
118+ . action ( ArgAction :: Set )
119+ . help ( "Output format: pdf (default) or typst markup." )
120+ )
111121 . arg (
112122 Arg :: new ( "filename" )
113123 . required ( true )
@@ -215,6 +225,12 @@ fn main() {
215225 print ! ( "{}" , result) ;
216226 }
217227 Some ( ( "render" , submatches) ) => {
228+ let output_format = submatches
229+ . get_one :: < String > ( "output" )
230+ . unwrap ( ) ;
231+
232+ debug ! ( output_format) ;
233+
218234 let filename = submatches
219235 . get_one :: < String > ( "filename" )
220236 . unwrap ( ) ; // argument are required by definition so always present
@@ -244,7 +260,17 @@ fn main() {
244260 } ;
245261
246262 let result = formatting:: render ( & Typst , & technique, 70 ) ;
247- rendering:: via_typst ( & filename, & result) ;
263+
264+ match output_format. as_str ( ) {
265+ "typst" => {
266+ print ! ( "{}" , result) ;
267+ // and exit
268+ std:: process:: exit ( 0 ) ;
269+ }
270+ _ => {
271+ rendering:: via_typst ( & filename, & result) ;
272+ }
273+ }
248274 }
249275 Some ( _) => {
250276 println ! ( "No valid subcommand was used" )
0 commit comments