@@ -28,14 +28,15 @@ var (
2828 // CommitSHA as provided by goreleaser.
2929 CommitSHA = ""
3030
31- readmeNames = []string {"README.md" , "README" , "Readme.md" , "Readme" , "readme.md" , "readme" }
32- readmeBranches = []string {"main" , "master" }
33- configFile string
34- pager bool
35- style string
36- width uint
37- showAllFiles bool
38- mouse bool
31+ readmeNames = []string {"README.md" , "README" , "Readme.md" , "Readme" , "readme.md" , "readme" }
32+ readmeBranches = []string {"main" , "master" }
33+ configFile string
34+ pager bool
35+ style string
36+ width uint
37+ showAllFiles bool
38+ preserveNewLines bool
39+ mouse bool
3940
4041 rootCmd = & cobra.Command {
4142 Use : "glow [SOURCE|DIR]" ,
@@ -151,6 +152,7 @@ func validateOptions(cmd *cobra.Command) error {
151152 width = viper .GetUint ("width" )
152153 mouse = viper .GetBool ("mouse" )
153154 pager = viper .GetBool ("pager" )
155+ preserveNewLines = viper .GetBool ("preserveNewLines" )
154156
155157 // validate the glamour style
156158 style = viper .GetString ("style" )
@@ -332,6 +334,7 @@ func runTUI(workingDirectory string) error {
332334 cfg .GlamourMaxWidth = width
333335 cfg .GlamourStyle = style
334336 cfg .EnableMouse = mouse
337+ cfg .PreserveNewLines = preserveNewLines
335338
336339 // Run Bubble Tea program
337340 if _ , err := ui .NewProgram (cfg ).Run (); err != nil {
@@ -372,7 +375,7 @@ func init() {
372375 rootCmd .Flags ().StringVarP (& style , "style" , "s" , glamour .AutoStyle , "style name or JSON path" )
373376 rootCmd .Flags ().UintVarP (& width , "width" , "w" , 0 , "word-wrap at width" )
374377 rootCmd .Flags ().BoolVarP (& showAllFiles , "all" , "a" , false , "show system files and directories (TUI-mode only)" )
375-
378+ rootCmd . Flags (). BoolVarP ( & preserveNewLines , "preserve-new-lines" , "n" , false , "preserve newlines in the output" )
376379 rootCmd .Flags ().BoolVarP (& mouse , "mouse" , "m" , false , "enable mouse wheel (TUI-mode only)" )
377380 _ = rootCmd .Flags ().MarkHidden ("mouse" )
378381
@@ -381,6 +384,8 @@ func init() {
381384 _ = viper .BindPFlag ("width" , rootCmd .Flags ().Lookup ("width" ))
382385 _ = viper .BindPFlag ("debug" , rootCmd .Flags ().Lookup ("debug" ))
383386 _ = viper .BindPFlag ("mouse" , rootCmd .Flags ().Lookup ("mouse" ))
387+ _ = viper .BindPFlag ("preserveNewLines" , rootCmd .Flags ().Lookup ("preserve-new-lines" ))
388+
384389 viper .SetDefault ("style" , glamour .AutoStyle )
385390 viper .SetDefault ("width" , 0 )
386391
0 commit comments