From f68d7f8d1102824e666cb9af3e1454b6aa616c20 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Fri, 5 Jan 2024 13:58:06 +0100 Subject: [PATCH] [Markdown] Docstring for html and latex functions (#52733) Part of #52725 --- stdlib/Markdown/src/render/html.jl | 15 +++++++++++++++ stdlib/Markdown/src/render/latex.jl | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/stdlib/Markdown/src/render/html.jl b/stdlib/Markdown/src/render/html.jl index a48180509400f..3831e6acc7bb9 100644 --- a/stdlib/Markdown/src/render/html.jl +++ b/stdlib/Markdown/src/render/html.jl @@ -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 `
...
` element. + +# Example +```jldoctest +julia> html(md"hello _world_") +"

hello world

\\n" +``` +""" html(md) = sprint(html, md) function show(io::IO, ::MIME"text/html", md::MD) diff --git a/stdlib/Markdown/src/render/latex.jl b/stdlib/Markdown/src/render/latex.jl index d18a2e760ef3d..03bb78ba3efec 100644 --- a/stdlib/Markdown/src/render/latex.jl +++ b/stdlib/Markdown/src/render/latex.jl @@ -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)