From 439f69e6545671d8c2e5fb126eafb42c91c46307 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 1 Sep 2021 20:25:40 +0200 Subject: [PATCH] Fix named at-examples to not contain spaces, fixes #168. (#169) --- CHANGELOG.md | 5 +++++ src/Literate.jl | 2 +- test/runtests.jl | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18e7596..6301497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ 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 named `@examples` from `Literate.markdown` to not contain spaces even if the source + filename does. ([#168][github-168], [#169][github-169]) ## [2.9.2] - 2021-08-16 ### Fixed @@ -142,6 +145,8 @@ https://discourse.julialang.org/t/ann-literate-jl/10651 for release announcement [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 +[github-168]: https://github.com/fredrikekre/Literate.jl/issues/168 +[github-169]: https://github.com/fredrikekre/Literate.jl/pull/169 [Unreleased]: https://github.com/fredrikekre/Literate.jl/compare/v2.9.2...HEAD [2.9.2]: https://github.com/fredrikekre/Literate.jl/compare/v2.9.1...v2.9.2 diff --git a/src/Literate.jl b/src/Literate.jl index 8d77df1..63bc675 100644 --- a/src/Literate.jl +++ b/src/Literate.jl @@ -258,7 +258,7 @@ function create_configuration(inputfile; user_config, user_kwargs, type=nothing) cfg["execute"] = type === :md ? false : true cfg["codefence"] = get(user_config, "flavor", cfg["flavor"]) isa DocumenterFlavor && !get(user_config, "execute", cfg["execute"]) ? - ("````@example $(get(user_config, "name", cfg["name"]))" => "````") : + ("````@example $(get(user_config, "name", replace(cfg["name"], r"\s" => "_")))" => "````") : ("````julia" => "````") # Guess the package (or repository) root url edit_commit = "master" # TODO: Make this configurable like Documenter? diff --git a/test/runtests.jl b/test/runtests.jl index c021524..78327e9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -834,6 +834,12 @@ end end chunks, _ = Literate.preprocessor(inputfile, outdir; user_kwargs=pairs((; mdstrings=true)), user_config=(), type=:md) @test chunks[2].lines == ["" => "hello world", "" => "hej världen"] + + # fredrikekre/Literate.jl#168 + f = "file with space.jl" + write(f, "1 + 1") + Literate.markdown(f, outdir) + @test occursin("file_with_space", read(joinpath(outdir, "file with space.md"), String)) end end end end