trim space
This commit is contained in:
parent
107a47e9e3
commit
cd09aba54f
5 changed files with 52 additions and 3 deletions
|
|
@ -270,7 +270,7 @@ func (c *compiler) compileLabel(attrs *d2graph.Attributes, f d2ir.Node) {
|
|||
// TODO: Delete instead.
|
||||
attrs.Label.Value = scalar.ScalarString()
|
||||
case *d2ast.BlockString:
|
||||
if scalar.ScalarString() == "" {
|
||||
if strings.TrimSpace(scalar.ScalarString()) == "" {
|
||||
c.errorf(f.LastPrimaryKey(), "block string cannot be empty")
|
||||
}
|
||||
attrs.Language = scalar.Tag
|
||||
|
|
|
|||
|
|
@ -611,9 +611,22 @@ x: {
|
|||
d2/testdata/d2compiler/TestCompile/md_block_string_err.d2:5:1: block string must be terminated with |`,
|
||||
},
|
||||
{
|
||||
name: "no_empty_block_strings",
|
||||
name: "no_empty_block_string",
|
||||
text: `Text: |md |`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/no_empty_block_strings.d2:1:1: block string cannot be empty`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/no_empty_block_string.d2:1:1: block string cannot be empty`,
|
||||
},
|
||||
{
|
||||
name: "no_white_spaces_only_block_string",
|
||||
text: `Text: |md |`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/no_white_spaces_only_block_string.d2:1:1: block string cannot be empty`,
|
||||
},
|
||||
{
|
||||
name: "no_new_lines_only_block_string",
|
||||
text: `Text: |md
|
||||
|
||||
|
||||
|`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/no_new_lines_only_block_string.d2:1:1: block string cannot be empty`,
|
||||
},
|
||||
{
|
||||
name: "underscore_edge_existing",
|
||||
|
|
|
|||
12
testdata/d2compiler/TestCompile/no_empty_block_string.exp.json
generated
vendored
Normal file
12
testdata/d2compiler/TestCompile/no_empty_block_string.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"graph": null,
|
||||
"err": {
|
||||
"ioerr": null,
|
||||
"errs": [
|
||||
{
|
||||
"range": "d2/testdata/d2compiler/TestCompile/no_empty_block_string.d2,0:0:0-0:11:11",
|
||||
"errmsg": "d2/testdata/d2compiler/TestCompile/no_empty_block_string.d2:1:1: block string cannot be empty"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
12
testdata/d2compiler/TestCompile/no_new_lines_only_block_string.exp.json
generated
vendored
Normal file
12
testdata/d2compiler/TestCompile/no_new_lines_only_block_string.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"graph": null,
|
||||
"err": {
|
||||
"ioerr": null,
|
||||
"errs": [
|
||||
{
|
||||
"range": "d2/testdata/d2compiler/TestCompile/no_new_lines_only_block_string.d2,0:0:0-3:1:13",
|
||||
"errmsg": "d2/testdata/d2compiler/TestCompile/no_new_lines_only_block_string.d2:1:1: block string cannot be empty"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
12
testdata/d2compiler/TestCompile/no_white_spaces_only_block_string.exp.json
generated
vendored
Normal file
12
testdata/d2compiler/TestCompile/no_white_spaces_only_block_string.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"graph": null,
|
||||
"err": {
|
||||
"ioerr": null,
|
||||
"errs": [
|
||||
{
|
||||
"range": "d2/testdata/d2compiler/TestCompile/no_white_spaces_only_block_string.d2,0:0:0-0:16:16",
|
||||
"errmsg": "d2/testdata/d2compiler/TestCompile/no_white_spaces_only_block_string.d2:1:1: block string cannot be empty"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue