From 0a1538851765d143ce3b1695e0548f19964d2915 Mon Sep 17 00:00:00 2001 From: Alexei Yuzhakov Date: Sun, 6 Jun 2021 14:58:18 +0700 Subject: [PATCH] Fix #5 Allow to use triple dashes as a slide separator --- README.md | 4 ++-- cmd/root.go | 9 +++++++-- examples/slides.md | 12 ++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5dfeb41..0a12e2b 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,12 @@ Create a simple markdown file that contains your slides: # Welcome to Slides A terminal based presentation tool -~~~ +--- ## Everything is markdown In fact, this entire presentation is a markdown file. -~~~ +--- ## Everything happens in your terminal Create slides and present them without ever leaving your terminal. diff --git a/cmd/root.go b/cmd/root.go index c75a52d..835bf19 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,7 +13,10 @@ import ( "github.com/spf13/cobra" ) -const delimiter = "~~~" +const ( + delimiter = "\n---\n" + altDelimiter = "\n~~~\n" +) var root = &cobra.Command{ Use: "slides ", @@ -35,7 +38,9 @@ var root = &cobra.Command{ return errors.New("could not read file") } - slides := strings.Split(string(b), delimiter) + content := string(b) + content = strings.ReplaceAll(content, altDelimiter, delimiter) + slides := strings.Split(content, delimiter) user, err := user.Current() if err != nil { diff --git a/examples/slides.md b/examples/slides.md index 23d1f62..c839be1 100644 --- a/examples/slides.md +++ b/examples/slides.md @@ -1,12 +1,12 @@ # Welcome to Slides A terminal based presentation tool -~~~ +--- ## Everything is markdown In fact this entire presentation is a markdown file -~~~ +--- # h1 ## h2 @@ -27,15 +27,15 @@ You can use everything in markdown! | ------ | ------ | | Even | Tables | -~~~ +--- -All you need to do is separate slides with triple tildes `\~\~\~`, -Like so: +All you need to do is separate slides with triple dashes `---` on a separate line, +like so: ```markdown Slide 1 -\~\~\~ +--- Slide 2 ```