Skip to content

Commit

Permalink
fix(parser/renderer): skip trailing empty lines in delimited blocks
Browse files Browse the repository at this point in the history
change the parser rules to identify the blank lines and skip them
during rendering when there is nothing else afterwards

fixes bytesparadise#470

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon committed Jan 7, 2020
1 parent 136ef4e commit cc65080
Show file tree
Hide file tree
Showing 5 changed files with 782 additions and 651 deletions.
94 changes: 82 additions & 12 deletions pkg/parser/delimited_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,13 @@ in the middle
Content: "with an empty line",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "in the middle",
Expand Down Expand Up @@ -411,7 +417,13 @@ then a normal paragraph.`
Content: "with an empty line",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "in the middle",
Expand Down Expand Up @@ -717,7 +729,13 @@ paragraphs
Content: "multiple",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "paragraphs",
Expand Down Expand Up @@ -1335,7 +1353,13 @@ end
Content: "require 'sinatra'",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "get '/hi' do",
Expand Down Expand Up @@ -1384,7 +1408,13 @@ end
Content: "require 'sinatra'",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "get '/hi' do",
Expand Down Expand Up @@ -1436,7 +1466,12 @@ end
Content: "require 'sinatra'",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{
{
types.StringElement{
Content: "get '/hi' do",
Expand Down Expand Up @@ -1914,7 +1949,12 @@ in the middle
Content: "with an empty line",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{
{
types.StringElement{
Content: "in the middle",
Expand Down Expand Up @@ -2003,7 +2043,13 @@ then a normal paragraph.`
Content: "with an empty line",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "in the middle",
Expand Down Expand Up @@ -2386,7 +2432,13 @@ paragraphs
Content: "multiple",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "paragraphs",
Expand Down Expand Up @@ -3138,7 +3190,13 @@ end
Content: "require 'sinatra'",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "get '/hi' do",
Expand Down Expand Up @@ -3195,7 +3253,13 @@ end
Content: "require 'sinatra'",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "get '/hi' do",
Expand Down Expand Up @@ -3255,7 +3319,13 @@ end
Content: "require 'sinatra'",
},
},
{},
},
},
types.BlankLine{},
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: [][]interface{}{

{
types.StringElement{
Content: "get '/hi' do",
Expand Down
Loading

0 comments on commit cc65080

Please sign in to comment.