Skip to content

Commit

Permalink
[Markdown] Docstring for html and latex functions (#52733)
Browse files Browse the repository at this point in the history
Part of #52725
  • Loading branch information
fonsp authored Jan 5, 2024
1 parent 67e6127 commit f68d7f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions stdlib/Markdown/src/render/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ htmlinline(io::IO, x) = tohtml(io, x)

export html

"""
html([io::IO], md)
Output the contents of the Markdown object `md` in HTML format, either
writing to an (optional) `io` stream or returning a string.
One can alternatively use `show(io, "text/html", md)` or `repr("text/html", md)`, which
differ in that they wrap the output in a `<div class="markdown"> ... </div>` element.
# Example
```jldoctest
julia> html(md"hello _world_")
"<p>hello <em>world</em></p>\\n"
```
"""
html(md) = sprint(html, md)

function show(io::IO, ::MIME"text/html", md::MD)
Expand Down
14 changes: 14 additions & 0 deletions stdlib/Markdown/src/render/latex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,20 @@ function latexesc(io, s::AbstractString)
end
end

"""
latex([io::IO], md)
Output the contents of the Markdown object `md` in LaTeX format, either
writing to an (optional) `io` stream or returning a string.
One can alternatively use `show(io, "text/latex", md)` or `repr("text/latex", md)`.
# Example
```jldoctest
julia> latex(md"hello _world_")
"hello \\\\emph{world}\\n\\n"
```
"""
latex(md) = sprint(latex, md)
latexinline(md) = sprint(latexinline, md)
latexesc(s) = sprint(latexesc, s)
Expand Down

0 comments on commit f68d7f8

Please sign in to comment.