add md block info

This commit is contained in:
Alexander Wang 2023-04-29 20:45:03 -07:00
parent 0bc3054e59
commit ddd997e3f0
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
3 changed files with 33 additions and 1 deletions

View file

@ -598,6 +598,18 @@ x: {
}
},
},
{
name: "md_block_string_err",
text: `test: |md
# What about pipes
Will escaping \| work?
|
`,
expErr: `d2/testdata/d2compiler/TestCompile/md_block_string_err.d2:4:19: unexpected text after md block string. See https://d2lang.com/tour/text#advanced-block-strings.
d2/testdata/d2compiler/TestCompile/md_block_string_err.d2:5:1: block string must be terminated with |`,
},
{
name: "underscore_edge_existing",

View file

@ -413,7 +413,11 @@ func (p *parser) parseMap(isFileMap bool) *d2ast.Map {
if after != p.pos {
if n.Unbox() != nil {
if n.MapKey != nil && n.MapKey.Value.Unbox() != nil {
p.errorf(after, p.pos, "unexpected text after %v", n.MapKey.Value.Unbox().Type())
ps := ""
if _, ok := n.MapKey.Value.Unbox().(*d2ast.BlockString); ok {
ps = ". See https://d2lang.com/tour/text#advanced-block-strings."
}
p.errorf(after, p.pos, "unexpected text after %v%s", n.MapKey.Value.Unbox().Type(), ps)
} else {
p.errorf(after, p.pos, "unexpected text after %v", n.Unbox().Type())
}

View file

@ -0,0 +1,16 @@
{
"graph": null,
"err": {
"ioerr": null,
"errs": [
{
"range": "d2/testdata/d2compiler/TestCompile/md_block_string_err.d2,3:18:50-3:24:56",
"errmsg": "d2/testdata/d2compiler/TestCompile/md_block_string_err.d2:4:19: unexpected text after md block string. See https://d2lang.com/tour/text#advanced-block-strings."
},
{
"range": "d2/testdata/d2compiler/TestCompile/md_block_string_err.d2,4:0:57-5:0:59",
"errmsg": "d2/testdata/d2compiler/TestCompile/md_block_string_err.d2:5:1: block string must be terminated with |"
}
]
}
}