diff --git a/docs/src/features/markdown_highlight.md b/docs/src/features/markdown_highlight.md index 4d089a63..370285dd 100644 --- a/docs/src/features/markdown_highlight.md +++ b/docs/src/features/markdown_highlight.md @@ -7,3 +7,9 @@ OhMyREPL will by default make code blocks written in markdown syntax (for exampl ## Settings Can be disabled or enabled with `enable_highlight_markdown(::Bool)`. + +To distinguish the `julia> ` in a markdown output from the real REPL prompt, its appearance is configurable. + +```@docs +OhMyREPL.markdown_prompt! +``` diff --git a/src/MarkdownHighlighter.jl b/src/MarkdownHighlighter.jl index e193cdfd..29fd82ad 100644 --- a/src/MarkdownHighlighter.jl +++ b/src/MarkdownHighlighter.jl @@ -1,4 +1,3 @@ - using Crayons import Markdown @@ -42,7 +41,7 @@ function Markdown.term(io::IO, md::Markdown.Code, columns) SYNTAX_HIGHLIGHTER_SETTINGS(crayons, tokens, 0, sourcecode) buff = IOBuffer() if lang == "jldoctest" || lang == "julia-repl" - print(buff, Crayon(foreground = :red, bold = true), "julia> ", Crayon(reset = true)) + print(buff, MARKDOWN_PROMPT, Crayon(reset = true)) end for (token, crayon) in zip(tokens, crayons) print(buff, crayon) @@ -66,3 +65,15 @@ function Markdown.term(io::IO, md::Markdown.Code, columns) end end end + +""" + markdown_prompt!(prompt = "julia> "; crayon = Crayon(foreground=:red, bold=true)) + +Set the prompt shown in `jldoctest` and `julia-repl` code blocks. +""" +function markdown_prompt!(prompt = "julia> "; crayon = Crayon(foreground = :red, bold = true)) + global MARKDOWN_PROMPT = sprint(print, crayon, prompt) + return +end + +markdown_prompt!()