Skip to content

Commit

Permalink
added doc string for @md_str string literal (#51168)
Browse files Browse the repository at this point in the history
fixed tailing blank lines

added an example

added suggestion from reviewer stevengj
  • Loading branch information
mitiemann committed Dec 31, 2023
1 parent 1b183b9 commit 4192b48
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stdlib/Markdown/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,11 @@ complex features (such as references) without cluttering the basic syntax.
In principle, the Markdown parser itself can also be arbitrarily extended by packages, or an entirely
custom flavour of Markdown can be used, but this should generally be unnecessary.
## [Markdown String Literals](@id stdlib-markdown-literals)
Markdown strings can be constructed using the string literal syntax `md"..."`.
```@docs
Markdown.@md_str
```
12 changes: 12 additions & 0 deletions stdlib/Markdown/src/Markdown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ function docexpr(source::LineNumberNode, mod::Module, s, flavor = :julia)
:($doc_str($(mdexpr(s, flavor)), $(QuoteNode(source)), $mod))
end

"""
macro md_str(s)
Parse the given string as Markdown text and return a corresponding `Markdown.MD` object.
# Example
```jldoctest
julia> Markdown.html(md"# Hello, world!")
"<h1>Hello, world&#33;</h1>\\n"
```
"""
macro md_str(s, t...)
mdexpr(s, t...)
end
Expand Down

0 comments on commit 4192b48

Please sign in to comment.