Skip to content

Commit

Permalink
fix(parser): support valid characters in URLs (#417)
Browse files Browse the repository at this point in the history
added a lot of missing characters, but excluded
the `[` and `]` as they are used to pass arguments
in external and relative links.

Fixes #416:

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Sep 19, 2019
1 parent cc4c79d commit 98a84d4
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 92 deletions.
28 changes: 28 additions & 0 deletions pkg/parser/file_inclusion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,34 @@ include::../../test/includes/hello_world.go.txt[]
}
verifyPreflight("test.adoc", expected, source)
})

It("include go file with a simple range", func() {

source := `----
include::../../test/includes/hello_world.go.txt[lines=1]
----`
expected := types.PreflightDocument{
Blocks: []interface{}{
types.DelimitedBlock{
Kind: types.Listing,
Attributes: types.ElementAttributes{},
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: []types.InlineElements{
{
types.StringElement{
Content: `package includes`,
},
},
},
},
},
},
},
}
verifyPreflight("test.adoc", expected, source)
})
})
})

Expand Down
27 changes: 27 additions & 0 deletions pkg/parser/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,33 @@ next lines`
verifyDocumentBlock(expected, source)
})

It("relative link with all valid characters", func() {
source := `a link to link:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.[as expected]`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: []types.InlineElements{
{
types.StringElement{Content: "a link to "},
types.InlineLink{
Location: types.Location{
types.StringElement{
Content: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.",
},
},
Attributes: types.ElementAttributes{
types.AttrInlineLinkText: types.InlineElements{
types.StringElement{
Content: "as expected",
},
},
},
},
},
},
}
verifyDocumentBlock(expected, source)
})

Context("text attribute with comma", func() {

It("relative link only with text having comma", func() {
Expand Down
Loading

0 comments on commit 98a84d4

Please sign in to comment.