Skip to content

Commit

Permalink
Fix multiline comment support with \r\n line endings, fixes #165. (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Aug 16, 2021
1 parent 65f55d3 commit aab932a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Fix multiline comment support for `\r\n` line endings. ([#165][github-165], [#167][github-167])

## [2.9.1] - 2021-07-30
### Fixed
Expand Down Expand Up @@ -136,6 +138,8 @@ https://discourse.julialang.org/t/ann-literate-jl/10651 for release announcement
[github-159]: https://github.com/fredrikekre/Literate.jl/pull/159
[github-162]: https://github.com/fredrikekre/Literate.jl/issues/162
[github-163]: https://github.com/fredrikekre/Literate.jl/pull/163
[github-165]: https://github.com/fredrikekre/Literate.jl/issues/165
[github-167]: https://github.com/fredrikekre/Literate.jl/pull/167

[Unreleased]: https://github.com/fredrikekre/Literate.jl/compare/v2.9.1...HEAD
[2.9.1]: https://github.com/fredrikekre/Literate.jl/compare/v2.9.0...v2.9.1
Expand Down
4 changes: 2 additions & 2 deletions src/Literate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ function replace_default(content, sym;
end
return str
end
content = replace_multiline(r"^#=+$\R^(\X*?)\R^=+#$"m, content)
content = replace_multiline(r"^#=+\R^(\X*?)\R=+#$"m, content)
if config["mdstrings"]::Bool
content = replace_multiline(r"^md\"\"\"$\R^(\X*?)\R^\"\"\"$"m, content)
content = replace_multiline(r"^md\"\"\"\R^(\X*?)\R\"\"\"$"m, content)
end


Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,15 @@ end end
@test !isfile("inputfile.md")
Literate.markdown(inputfile; execute=false)
@test isfile("inputfile.md")

# fredrikekre/Literate.jl#165: \r\n line endings with multiline comments/mdstrings
write(inputfile, "#=\r\nhello world\r\nhej världen\r\n=#")
chunks, _ = Literate.preprocessor(inputfile, outdir; user_kwargs=(), user_config=(), type=:md)
@test chunks[2].lines == ["" => "hello world", "" => "hej världen"]
write(inputfile, "md\"\"\"\r\nhello world\r\nhej världen\r\n\"\"\"")
chunks, _ = Literate.preprocessor(inputfile, outdir; user_kwargs=pairs((; mdstrings=true)),
user_config=(), type=:md)
@test chunks[2].lines == ["" => "hello world", "" => "hej världen"]
end
end
end end
Expand Down

0 comments on commit aab932a

Please sign in to comment.