Browse Source

Fix multiline comments with rn line endings, fixes #171. (#172)

pull/173/head
Fredrik Ekre 4 years ago committed by GitHub
parent
commit
fbd39a3d5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 4
      src/Literate.jl
  3. 4
      test/runtests.jl

4
CHANGELOG.md

@ -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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
### Fixed
- Fix multiline comment support for `\r\n` line endings. ([#171][github-171], [#172][github-172])
## [2.9.3] - 2021-09-01 ## [2.9.3] - 2021-09-01
### Fixed ### Fixed
@ -149,6 +151,8 @@ https://discourse.julialang.org/t/ann-literate-jl/10651 for release announcement
[github-167]: https://github.com/fredrikekre/Literate.jl/pull/167 [github-167]: https://github.com/fredrikekre/Literate.jl/pull/167
[github-168]: https://github.com/fredrikekre/Literate.jl/issues/168 [github-168]: https://github.com/fredrikekre/Literate.jl/issues/168
[github-169]: https://github.com/fredrikekre/Literate.jl/pull/169 [github-169]: https://github.com/fredrikekre/Literate.jl/pull/169
[github-171]: https://github.com/fredrikekre/Literate.jl/issues/171
[github-172]: https://github.com/fredrikekre/Literate.jl/pull/172
[Unreleased]: https://github.com/fredrikekre/Literate.jl/compare/v2.9.3...HEAD [Unreleased]: https://github.com/fredrikekre/Literate.jl/compare/v2.9.3...HEAD
[2.9.3]: https://github.com/fredrikekre/Literate.jl/compare/v2.9.2...v2.9.3 [2.9.3]: https://github.com/fredrikekre/Literate.jl/compare/v2.9.2...v2.9.3

4
src/Literate.jl

@ -161,9 +161,9 @@ function replace_default(content, sym;
end end
return str return str
end end
content = replace_multiline(r"^#=+\R^(\X*?)\R=+#$"m, content) content = replace_multiline(r"(*ANYCRLF)^#=+$\R^(\X*?)\R^=+#$"m, content)
if config["mdstrings"]::Bool if config["mdstrings"]::Bool
content = replace_multiline(r"^md\"\"\"\R^(\X*?)\R\"\"\"$"m, content) content = replace_multiline(r"(*ANYCRLF)^md\"\"\"$\R^(\X*?)\R^\"\"\"$"m, content)
end end

4
test/runtests.jl

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

Loading…
Cancel
Save