Comments (2)
For regex 2 and 3 it make sense, I think. Do you want to submit a PR? You can probably find some tests for these replacements that you can augment too.
from literate.jl.
After some investigation, I would propose these three modified regexes:
repls = []
push!(repls, r"\[([^]]+?)\]\(@ref\)"s => s"\1") # [foo](@ref) => foo
push!(repls, r"\[([^]]+?)\]\(@ref .*?\)"s => s"\1") # [foo](@ref bar) => foo
push!(repls, r"\[([^]]+?)\]\(@id .*?\)"s => s"\1") # [foo](@id bar) => foo
In addition to including the trailing s
(which allows the match to cross between lines, https://perldoc.perl.org/perlre#Modifiers) I have also replaced (.*?)
with ([^]]+?)
, which excludes the character ]
from the matched ID within brackets.
These have the following behavior:
content = """
# # [Example](@id example-id)
# [foo](@ref), [bar](@ref bbaarr)
x = 1
"""
for repl in repls
content = replace(content, repl)
end
@assert content == """
# # Example
# foo, bar
x = 1
"""
content = """
# # [Example](@id example-id)
#
# [This is a long example which
# wraps a line](@ref)
#
# [In this case the](@ref reference also
# wraps a line)
#
# x = 1
"""
for repl in repls
content = replace(content, repl)
end
@assert content == """
# # Example
#
# This is a long example which
# wraps a line
#
# In this case the
#
# x = 1
"""
from literate.jl.
Related Issues (20)
- Standard multiline doc strings HOT 4
- Is it possible to get comments inside a code block while converting to markdown? HOT 2
- Remove `@raw html` decorations if target is Jupyter notebook HOT 2
- RequestError: HTTP/2 302 (Operation too slow ...) in Literate/Documenter build HOT 4
- "Makefile" like capability for Literate examples? HOT 4
- Add documentation explaining scoping and work-arounds HOT 3
- Issue with directories HOT 6
- Any possible interaction with the org-babel literate programming? HOT 2
- Hide clode blocks? HOT 1
- `Literate.markdown` with `execute=true` does not truncate array output HOT 2
- notebook() ignores outputdir? HOT 1
- Jupyter notebooks not working when running in different Julia versions HOT 3
- Feature request: Simulated REPL sesstion for markdown output
- Filtering blocks of code HOT 4
- [Bug] @__BINDER_ROOT_URL__ = <unknown> throws an error locally HOT 1
- Include error: no such file or directory HOT 1
- Literate generating @example blocks when it shouldn't HOT 1
- FR: Provide a way to play nice with Distributed
- Fetching output of display HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from literate.jl.