@@ -18,6 +18,7 @@ import (
1818 "github.com/charmbracelet/bubbles/viewport"
1919 tea "github.com/charmbracelet/bubbletea"
2020 "github.com/charmbracelet/glamour"
21+ "github.com/charmbracelet/lipgloss"
2122 "github.com/maaslalani/slides/internal/code"
2223 "github.com/maaslalani/slides/internal/meta"
2324 "github.com/maaslalani/slides/styles"
3031)
3132
3233const (
33- delimiter = "\n ---\n "
34+ delimiter = "\n ---\n "
35+ colDelimiter = "\n -|-\n "
3436)
3537
3638// Model represents the model of this presentation, which contains all the
@@ -204,15 +206,21 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
204206// View renders the current slide in the presentation and the status bar which
205207// contains the author, date, and pagination information.
206208func (m Model ) View () string {
207- r , _ := glamour .NewTermRenderer (m .Theme , glamour .WithWordWrap (m .viewport .Width ))
208209 slide := m .Slides [m .Page ]
209- slide = code .HideComments (slide )
210- slide , err := r .Render (slide )
211- slide = strings .ReplaceAll (slide , "\t " , tabSpaces )
212- slide += m .VirtualText
213- if err != nil {
214- slide = fmt .Sprintf ("Error: Could not render markdown! (%v)" , err )
210+ cols := strings .Split (slide , colDelimiter )
211+
212+ for i := 0 ; i < len (cols ); i ++ {
213+ r , _ := glamour .NewTermRenderer (m .Theme , glamour .WithWordWrap (m .viewport .Width / len (cols )))
214+ cols [i ] = code .HideComments (cols [i ])
215+ var err error
216+ cols [i ], err = r .Render (cols [i ])
217+ cols [i ] = strings .ReplaceAll (cols [i ], "\t " , tabSpaces )
218+ if err != nil {
219+ cols [i ] = "Error: Could not render markdown! (" + err .Error () + ")"
220+ }
215221 }
222+ slide = lipgloss .JoinHorizontal (lipgloss .Top , cols ... )
223+ slide = lipgloss .JoinVertical (lipgloss .Center , slide , m .VirtualText )
216224 slide = styles .Slide .Render (slide )
217225
218226 var left string
0 commit comments