Skip to content

Commit 5a00771

Browse files
committed
Revert "Styled markdown, with a few tweaks (#51928)
1 parent bec6efd commit 5a00771

File tree

14 files changed

+153
-233
lines changed

14 files changed

+153
-233
lines changed

doc/Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
148148
version = "1.11.0"
149149

150150
[[deps.Markdown]]
151-
deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"]
151+
deps = ["Base64"]
152152
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
153153
version = "1.11.0"
154154

stdlib/Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ uuid = "3a97d323-0669-5f0c-9066-3539efd106a3"
139139
version = "4.2.1+1"
140140

141141
[[deps.Markdown]]
142-
deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"]
142+
deps = ["Base64"]
143143
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
144144
version = "1.11.0"
145145

stdlib/Markdown/Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ version = "1.11.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
7-
JuliaSyntaxHighlighting = "ac6e5ff7-fb65-4e79-a425-ec3bc9c03011"
8-
StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
97

108
[extras]
119
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

stdlib/Markdown/src/Common/block.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ end
3939
# Headers
4040
# –––––––
4141

42-
mutable struct Header{level} <: MarkdownElement
42+
mutable struct Header{level}
4343
text
4444
end
4545

stdlib/Markdown/src/Common/inline.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Emphasis
55
# ––––––––
66

7-
mutable struct Italic <: MarkdownElement
7+
mutable struct Italic
88
text
99
end
1010

@@ -20,7 +20,7 @@ function underscore_italic(stream::IO, md::MD)
2020
return result === nothing ? nothing : Italic(parseinline(result, md))
2121
end
2222

23-
mutable struct Bold <: MarkdownElement
23+
mutable struct Bold
2424
text
2525
end
2626

@@ -66,7 +66,7 @@ end
6666
# Images & Links
6767
# ––––––––––––––
6868

69-
mutable struct Image <: MarkdownElement
69+
mutable struct Image
7070
url::String
7171
alt::String
7272
end
@@ -85,7 +85,7 @@ function image(stream::IO, md::MD)
8585
end
8686
end
8787

88-
mutable struct Link <: MarkdownElement
88+
mutable struct Link
8989
text
9090
url::String
9191
end
@@ -156,7 +156,7 @@ end
156156
# Punctuation
157157
# –––––––––––
158158

159-
mutable struct LineBreak <: MarkdownElement end
159+
mutable struct LineBreak end
160160

161161
@trigger '\\' ->
162162
function linebreak(stream::IO, md::MD)

stdlib/Markdown/src/GitHub/table.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ end
140140

141141
function term(io::IO, md::Table, columns)
142142
margin_str = " "^margin
143-
cells = mapmap(x -> annotprint(terminline, x), md.rows)
144-
padcells!(cells, md.align, len = textwidth)
143+
cells = mapmap(x -> terminline_string(io, x), md.rows)
144+
padcells!(cells, md.align, len = ansi_length)
145145
for i = 1:length(cells)
146146
print(io, margin_str)
147147
join(io, cells[i], " ")
148148
if i == 1
149149
println(io)
150150
print(io, margin_str)
151-
join(io, [""^textwidth(cells[i][j]) for j = 1:length(cells[1])], " ")
151+
join(io, [""^ansi_length(cells[i][j]) for j = 1:length(cells[1])], " ")
152152
end
153153
i < length(cells) && println(io)
154154
end

stdlib/Markdown/src/Markdown.jl

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ literals `md"..."` and `doc"..."`.
99
"""
1010
module Markdown
1111

12-
import Base: AnnotatedString, AnnotatedIOBuffer, show, ==, with_output_color, mapany
12+
import Base: show, ==, with_output_color, mapany
1313
using Base64: stringmime
1414

15-
using StyledStrings: StyledStrings, Face, addface!, @styled_str, styled
16-
using JuliaSyntaxHighlighting: highlight, highlight!
17-
1815
# Margin for printing in terminal.
1916
const margin = 2
2017

@@ -37,26 +34,6 @@ export @md_str, @doc_str
3734

3835
public MD, parse
3936

40-
const MARKDOWN_FACES = [
41-
:markdown_header => Face(weight=:bold),
42-
:markdown_h1 => Face(height=1.25, inherit=:markdown_header),
43-
:markdown_h2 => Face(height=1.20, inherit=:markdown_header),
44-
:markdown_h3 => Face(height=1.15, inherit=:markdown_header),
45-
:markdown_h4 => Face(height=1.12, inherit=:markdown_header),
46-
:markdown_h5 => Face(height=1.08, inherit=:markdown_header),
47-
:markdown_h6 => Face(height=1.05, inherit=:markdown_header),
48-
:markdown_admonition => Face(weight=:bold),
49-
:markdown_code => Face(inherit=:code),
50-
:markdown_footnote => Face(inherit=:bright_yellow),
51-
:markdown_hrule => Face(inherit=:shadow),
52-
:markdown_inlinecode => Face(inherit=:markdown_code),
53-
:markdown_latex => Face(inherit=:magenta),
54-
:markdown_link => Face(underline=:bright_blue),
55-
:markdown_list => Face(foreground=:blue),
56-
]
57-
58-
__init__() = foreach(addface!, MARKDOWN_FACES)
59-
6037
parse(markdown::String; flavor = julia) = parse(IOBuffer(markdown), flavor = flavor)
6138

6239
"""

stdlib/Markdown/src/render/html.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ end
6767

6868
function html(io::IO, code::Code)
6969
withtag(io, :pre) do
70-
if code.language == "styled"
71-
code = Code("", String(styled(code.code)))
72-
end
7370
maybe_lang = !isempty(code.language) ? Any[:class=>"language-$(code.language)"] : []
7471
withtag(io, :code, maybe_lang...) do
7572
htmlesc(io, code.code)
@@ -137,9 +134,6 @@ function htmlinline(io::IO, content::Vector)
137134
end
138135

139136
function htmlinline(io::IO, code::Code)
140-
if code.language == "styled"
141-
code = Code("", String(styled(code.code)))
142-
end
143137
withtag(io, :code) do
144138
htmlesc(io, code.code)
145139
end

stdlib/Markdown/src/render/latex.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ function latex(io::IO, header::Header{l}) where l
3333
end
3434

3535
function latex(io::IO, code::Code)
36-
if code.language == "styled"
37-
code = Code("", String(styled(code.code)))
38-
end
3936
occursin("\\end{verbatim}", code.code) && error("Cannot include \"\\end{verbatim}\" in a latex code block")
4037
wrapblock(io, "verbatim") do
4138
println(io, code.code)

stdlib/Markdown/src/render/rst.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,10 @@ end
2323
function rst(io::IO, code::Code)
2424
if code.language == "jldoctest"
2525
println(io, ".. doctest::\n")
26-
elseif code.language in ("", "julia", "julia-repl")
26+
elseif code.language != "rst"
2727
println(io, ".. code-block:: julia\n")
28-
elseif code.language == "rst"
29-
elseif code.language == "styled"
30-
code = Code("", String(styled(code.code)))
31-
println(io, "::\n")
32-
else
33-
println(io, "::\n")
3428
end
35-
for l in eachsplit(code.code, '\n')
29+
for l in lines(code.code)
3630
println(io, " ", l)
3731
end
3832
end
@@ -96,7 +90,7 @@ end
9690

9791
function rst(io::IO, l::LaTeX)
9892
println(io, ".. math::\n")
99-
for line in eachsplit(l.formula, '\n')
93+
for line in lines(l.formula)
10094
println(io, " ", line)
10195
end
10296
end

0 commit comments

Comments
 (0)