Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown highlighting: Make prompt configurable #273

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/src/features/markdown_highlight.md
Original file line number Diff line number Diff line change
@@ -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!
```
15 changes: 13 additions & 2 deletions src/MarkdownHighlighter.jl
Original file line number Diff line number Diff line change
@@ -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!()