Skip to content

Commit

Permalink
Insert video HTML tag for embedded images with a video file ext
Browse files Browse the repository at this point in the history
Markdown image elements like `![Alt video text](dir/video.webm)` will be
rendered with a video HTML element in a similar way to Gitlab markdown.
  • Loading branch information
Richard Palethorpe committed Jun 13, 2019
1 parent 6e35c14 commit e08ddd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions assets/html/documenter.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ img {
max-width: 100%;
}

video {
max-width: 100%;
}

table {
border-collapse: collapse;
margin: 1em 0;
Expand Down
12 changes: 11 additions & 1 deletion src/Writers/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,17 @@ mdconvert(h::Markdown.Header{N}, parent; kwargs...) where {N} = DOM.Tag(Symbol("

mdconvert(::Markdown.HorizontalRule, parent; kwargs...) = Tag(:hr)()

mdconvert(i::Markdown.Image, parent; kwargs...) = Tag(:img)[:src => i.url, :alt => i.alt]
function mdconvert(i::Markdown.Image, parent; kwargs...)
@tags video img a

if occursin(r"(.webm|.mp4|.ogg|.ogm|.ogv|.avi)$", i.url)
video[:src => i.url, :controls => "true", :title => i.alt](
a[:href => i.url](i.alt)
)
else
img[:src => i.url, :alt => i.alt]
end
end

mdconvert(i::Markdown.Italic, parent; kwargs...) = Tag(:em)(mdconvert(i.text, i; kwargs...))

Expand Down

0 comments on commit e08ddd2

Please sign in to comment.