Skip to content

Commit

Permalink
Insert video HTML tag for embedded images with a video file ext (#1034)
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 (rpalethorpe) authored and mortenpi committed Jun 16, 2019
1 parent 3e77205 commit 2bc7ffa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

* ![Enhancement][badge-enhancement] Minor changes to how doctesting errors are printed. ([#1028][github-1028])

* ![Enhancement][badge-enhancement] Videos can now be included in the HTML output using the image syntax (`![]()`) if the file extension matches a known format (`.webm`, `.mp4`, `.ogg`, `.ogm`, `.ogv`, `.avi`). ([#1034][github-1034])

* ![Experimental][badge-experimental] ![Feature][badge-feature] The current working directory when evaluating `@repl` and `@example` blocks can now be set to a fixed directory by passing the `workdir` keyword to `makedocs`. _The new keyword and its behaviour are experimental and not part of the public API._ ([#1013][github-1013], [#1025][github-1025])

## Version `v0.22.4`
Expand Down Expand Up @@ -336,6 +338,7 @@
[github-1027]: https://github.com/JuliaDocs/Documenter.jl/issues/1027
[github-1028]: https://github.com/JuliaDocs/Documenter.jl/pull/1028
[github-1029]: https://github.com/JuliaDocs/Documenter.jl/pull/1029
[github-1034]: https://github.com/JuliaDocs/Documenter.jl/pull/1034

[documenterlatex]: https://github.com/JuliaDocs/DocumenterLaTeX.jl
[documentermarkdown]: https://github.com/JuliaDocs/DocumenterMarkdown.jl
Expand Down
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 2bc7ffa

Please sign in to comment.