racket / scribble

Other
201 stars 91 forks source link

scribble indenter should not invade the textual part of at-expressions #58

Open mbutterick opened 8 years ago

mbutterick commented 8 years ago

Before indentation:

#lang scribble/text
@list{
foo
}

After:

#lang scribble/text
@list{
 foo
}

Note the space inserted before "foo", which changes the data represented by this at-expression. Since whitespace is meaningful inside curly braces, the indenter should always leave those sections alone.

mflatt commented 8 years ago

It turns out that indenting doesn't change the content of the at-expression, because the at-reader is defined to discard any leading whitespace that appears on all lines.

mbutterick commented 8 years ago

A better example, perhaps:

#lang at-exp racket
@list|{
{
bar
}
}|
'("{" "\n" "bar" "\n" "}")

Gets indented like so:

#lang at-exp racket
@list|{
 {
 bar
}
 }|

Which changes the result:

'(" " "{" "\n" " " "bar" "\n" "}")
mbutterick commented 8 years ago

Of course, I can use a here-string instead (the indenter seems to leave those alone). Maybe the more specific problem here is that the indenter is mishandling the special case of alternate curly delimiters.

elibarzilay commented 8 years ago

Yeah, the whole point of the @-syntax is that tools (like indenters) can invade the text part, but only if the relative indentation in there isn't changed -- but in the last example you have it does indeed change that. It also looks broken with plain {} delimiters: it looks like it's indenting the text inside nested braces by one space.