Skip to content

Commit 2fb9e3c

Browse files
ehusstraviscross
authored andcommitted
Fix formatting of markdown grammar with cut
This fixes a formatting issue with how the grammar is rendered in markdown when there is a cut operator. The Alt renderer was incorrectly missing a space on alternations that span multiple lines with a cut operator. This is because the Cut expression is essentially the same as a sequence, but the `last_expr` function was not treating it that way. The Cut was preventing it from seeing that the alternation had a Break at the end.
1 parent a26605e commit 2fb9e3c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/mdbook-spec/src/grammar/render_markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn render_production(prod: &Production, cx: &RenderCtx, output: &mut String) {
6565
fn last_expr(expr: &Expression) -> &ExpressionKind {
6666
match &expr.kind {
6767
ExpressionKind::Alt(es) | ExpressionKind::Sequence(es) => last_expr(es.last().unwrap()),
68+
ExpressionKind::Cut(e) => last_expr(e),
6869
ExpressionKind::Grouped(_)
6970
| ExpressionKind::Optional(_)
7071
| ExpressionKind::NegativeLookahead(_)
@@ -79,7 +80,6 @@ fn last_expr(expr: &Expression) -> &ExpressionKind {
7980
| ExpressionKind::Comment(_)
8081
| ExpressionKind::Charset(_)
8182
| ExpressionKind::NegExpression(_)
82-
| ExpressionKind::Cut(_)
8383
| ExpressionKind::Unicode(_) => &expr.kind,
8484
}
8585
}

0 commit comments

Comments
 (0)