diff --git a/main.go b/main.go index e78d6bf..02209fa 100644 --- a/main.go +++ b/main.go @@ -293,13 +293,13 @@ func executeCLI(cmd *cobra.Command, src *source, w io.Writer) error { return err } - s := string(b) + content := string(b) ext := filepath.Ext(src.URL) if isCode { - s = utils.WrapCodeBlock(string(b), ext) + content = utils.WrapCodeBlock(string(b), ext) } - out, err := r.Render(s) + out, err := r.Render(content) if err != nil { return err } @@ -318,14 +318,14 @@ func executeCLI(cmd *cobra.Command, src *source, w io.Writer) error { c.Stdout = os.Stdout return c.Run() case tui || cmd.Flags().Changed("tui"): - return runTUI(src.URL, s) + return runTUI(src.URL, content) default: _, err = fmt.Fprint(w, out) return err } } -func runTUI(path string, s string) error { +func runTUI(path string, content string) error { // Read environment to get debugging stuff cfg, err := env.ParseAs[ui.Config]() if err != nil { @@ -345,7 +345,7 @@ func runTUI(path string, s string) error { cfg.PreserveNewLines = preserveNewLines // Run Bubble Tea program - if _, err := ui.NewProgram(cfg, s).Run(); err != nil { + if _, err := ui.NewProgram(cfg, content).Run(); err != nil { return err } diff --git a/ui/ui.go b/ui/ui.go index c23e63a..eeda361 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -29,7 +29,7 @@ var ( ) // NewProgram returns a new Tea program. -func NewProgram(cfg Config, s string) *tea.Program { +func NewProgram(cfg Config, content string) *tea.Program { log.Debug( "Starting glow", "high_perf_pager", @@ -43,7 +43,7 @@ func NewProgram(cfg Config, s string) *tea.Program { if cfg.EnableMouse { opts = append(opts, tea.WithMouseCellMotion()) } - m := newModel(cfg, s) + m := newModel(cfg, content) return tea.NewProgram(m, opts...) } @@ -129,7 +129,7 @@ func (m *model) unloadDocument() []tea.Cmd { return batch } -func newModel(cfg Config, s string) tea.Model { +func newModel(cfg Config, content string) tea.Model { initSections() if cfg.GlamourStyle == styles.AutoStyle { @@ -152,11 +152,9 @@ func newModel(cfg Config, s string) tea.Model { } path := cfg.Path - if path == "" && s != "" { + if path == "" && content != "" { m.state = stateShowDocument - m.pager.currentDocument = markdown{ - Body: s, - } + m.pager.currentDocument = markdown{Body: content} return m }