Fix #39, allow code blocks without trailing new line to run

This commit is contained in:
satoru
2021-06-23 20:56:42 +08:00
committed by Maas Lalani
parent 8c1a1aee53
commit 2bf2cd5506
2 changed files with 11 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ type Result struct {
}
// ?: means non-capture group
var re = regexp.MustCompile("(?s)(?:```|~~~)(\\w+)\n(.*)\n(?:```|~~~)\n")
var re = regexp.MustCompile("(?s)(?:```|~~~)(\\w+)\n(.*)\n(?:```|~~~)\\s?")
var (
ErrParse = errors.New("Error: could not parse code block")

View File

@@ -37,6 +37,16 @@ fmt.Println("Hello, world!")
},
{
markdown: `
~~~python
print("Hello, world!")
~~~`,
expected: code.Block{
Code: `print("Hello, world!")`,
Language: "python",
},
},
{
markdown: `
# Welcome to Slides
A terminal based presentation tool