Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Add support for spaces and tabs between a backlash and newline creating a linebreak

## v12.0.1 - 2026-06-08

- Fixed a bug where the parse could diverge when parsing multiline blockquotes
Expand Down
25 changes: 24 additions & 1 deletion src/jot.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ fn drop_spaces(in: String) -> String {
}
}

fn drop_spaces_tabs(in: String) -> String {
case in {
" " <> rest | "\t" <> rest -> drop_spaces_tabs(rest)
other -> other
}
}

fn count_drop_spaces(in: String, count: Int) -> #(String, Int) {
case in {
" " <> rest -> count_drop_spaces(rest, count + 1)
Expand Down Expand Up @@ -1295,7 +1302,23 @@ fn parse_inline(
parse_inline(in, splitters, "", [Linebreak, Text(text), ..acc])

" " <> in ->
parse_inline(in, splitters, "", [NonBreakingSpace, Text(text), ..acc])
case drop_spaces_tabs(in) {
"\n" <> in ->
parse_inline(in, splitters, "", [Linebreak, Text(text), ..acc])
_ ->
parse_inline(in, splitters, "", [
NonBreakingSpace,
Text(text),
..acc
])
}

"\t" <> in2 ->
case drop_spaces_tabs(in2) {
"\n" <> in ->
parse_inline(in, splitters, "", [Linebreak, Text(text), ..acc])
_ -> parse_inline(in, splitters, text <> "\\", acc)
}

_other -> parse_inline(in, splitters, text <> "\\", acc)
}
Expand Down
11 changes: 11 additions & 0 deletions test/cases/escapes.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ on multiple lines.
<p>The <code>code</code> is<br>
on multiple lines.</p>
```

There can be spaces and tabs between the backslash and the newline:

```
ab\
c
.
<p>ab<br>
c</p>
```

10 changes: 0 additions & 10 deletions test/cases_unimplemented/escapes.test
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
There can be spaces and tabs between the backslash and the newline:

```
ab\
c
.
<p>ab<br>
c</p>
```

There can also be spaces and tabs before the backslash, which are ignored:

```
Expand Down
Loading