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

## v2.0.1 - 2026-01-13

- Fixed a bug where the '#' symbol in ''' strings would be treated like a comment

## v2.0.0 - 2025-05-31

- Added [gleam_time](https://hexdocs.pm/gleam_time/index.html) as a dependency.
Expand Down
2 changes: 2 additions & 0 deletions src/tom.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ fn drop_comments(input: Tokens, acc: Tokens, in_string: Bool) -> Tokens {
["\\", "\"", ..input] if in_string ->
drop_comments(input, ["\"", "\\", ..acc], in_string)
["\"", ..input] -> drop_comments(input, ["\"", ..acc], !in_string)
["'", "'", "'", ..input] ->
drop_comments(input, ["'", "'", "'", ..acc], !in_string)
["#", ..input] if in_string -> drop_comments(input, ["#", ..acc], in_string)
["#", ..input] if !in_string ->
input
Expand Down
19 changes: 19 additions & 0 deletions test/tom_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,25 @@ pub fn parse_multi_line_single_quote_string_too_many_quotes_test() {
|> should.equal(Error(tom.Unexpected("''''", "'''")))
}

pub fn parse_multi_line_literal_string_with_hash_test() {
let expected =
dict.from_list([
#(
"a",
tom.String(
"This string contains a #hash character\nand more text after it\n",
),
),
])
"a = '''
This string contains a #hash character
and more text after it
'''
"
|> tom.parse
|> should.equal(Ok(expected))
}

pub fn parse_multi_line_string_escape_newline_test() {
let expected =
dict.from_list([
Expand Down