diff --git a/doc/src/manual/strings.md b/doc/src/manual/strings.md index 57431d07c0aa5..d4ec3f117ca92 100644 --- a/doc/src/manual/strings.md +++ b/doc/src/manual/strings.md @@ -1242,7 +1242,7 @@ julia> lpad(str, 14) julia> typeof(lpad(str, 7)) Base.AnnotatedString{String} -julia> str2 = Base.AnnotatedString(" julia", [(2:6, :face, :magenta)]) +julia> str2 = Base.AnnotatedString(" julia", [(2:6, :datum, 10)]) " julia" julia> Base.annotatedstring(str, str2) diff --git a/stdlib/Markdown/src/Markdown.jl b/stdlib/Markdown/src/Markdown.jl index 0d45d9e534df2..5640cb7a6ef8a 100644 --- a/stdlib/Markdown/src/Markdown.jl +++ b/stdlib/Markdown/src/Markdown.jl @@ -12,7 +12,7 @@ module Markdown import Base: AnnotatedString, AnnotatedIOBuffer, show, ==, with_output_color, mapany using Base64: stringmime -using StyledStrings: StyledStrings, Face, addface!, @styled_str, styled +using StyledStrings: StyledStrings, Face, addface!, @styled_str, styled, getface using JuliaSyntaxHighlighting: highlight, highlight! # Margin for printing in terminal. diff --git a/stdlib/Markdown/src/render/terminal/render.jl b/stdlib/Markdown/src/render/terminal/render.jl index a97d273131536..2c35d99589759 100644 --- a/stdlib/Markdown/src/render/terminal/render.jl +++ b/stdlib/Markdown/src/render/terminal/render.jl @@ -93,7 +93,7 @@ function term(io::AnnotIO, md::Header{l}, columns) where l underline = _header_underlines[l] pre = ' '^margin local line_width - with_output_annotations(io, :face => face) do io + with_output_annotations(io, :face => getface(face)) do io headline = annotprint(terminline, md.text) lines = wraplines(headline, columns - 4margin) for (i, line) in enumerate(lines) @@ -111,7 +111,7 @@ function term(io::AnnotIO, md::Header{l}, columns) where l header_width = max(0, line_width) if underline != ' ' && header_width > 0 print(io, '\n', ' '^(margin)) - with_output_annotations(io -> print(io, underline^header_width), io, :face => face) + with_output_annotations(io -> print(io, underline^header_width), io, :face => getface(face)) end end @@ -178,11 +178,11 @@ function terminline(io::IO, md::AbstractString) end function terminline(io::AnnotIO, md::Bold) - with_output_annotations(io -> terminline(io, md.text), io, :face => :bold) + with_output_annotations(io -> terminline(io, md.text), io, :face => getface(:bold)) end function terminline(io::AnnotIO, md::Italic) - with_output_annotations(io -> terminline(io, md.text), io, :face => :italic) + with_output_annotations(io -> terminline(io, md.text), io, :face => getface(:italic)) end function terminline(io::IO, md::LineBreak) @@ -199,9 +199,9 @@ end function terminline(io::AnnotIO, md::Link) annots = if occursin(r"^(https?|file)://", md.url) - (:face => :markdown_link, :link => md.url) + (:face => getface(:markdown_link), :link => md.url) else - (:face => :markdown_link,) + (:face => getface(:markdown_link),) end with_output_annotations(io -> terminline(io, md.text), io, annots...) end