Skip to content

Commit

Permalink
Audio embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
kukimik committed Feb 6, 2023
1 parent 66dad06 commit c59826b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions default/templates/filters/embed-audio.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<audio controls preload="metadata" src="${ema:url}">
Your browser doesn't support HTML5 audio. Here is a
<a class="text-${theme}-600 hover:underline" href="${ema:url}">link to the audio</a>
instead.
</audio>
Binary file added docs/guide/markdown/cat.ogg
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/guide/markdown/embed.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ The following is the result of using `![[death-note.mp4]]` (note that `![](death

![[death-note.mp4]]

### Audio

The following is the result of using `![[cat.ogg]]` (note that `![](cat.ogg)` also works).

![[cat.ogg]]

### PDFs

Expand Down
14 changes: 14 additions & 0 deletions src/Emanote/Pandoc/Renderer/Embed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ embedStaticFileRoute model altText staticFile = do
| any (`T.isSuffixOf` toText fp) videoExts -> do
pure . runEmbedTemplate "video" $ do
"ema:url" ## HI.textSplice url
| any (`T.isSuffixOf` toText fp) audioExts -> do
pure . runEmbedTemplate "audio" $ do
"ema:url" ## HI.textSplice url
| ".pdf" `T.isSuffixOf` toText fp -> do
pure . runEmbedTemplate "pdf" $ do
"ema:url" ## HI.textSplice url
Expand All @@ -108,3 +111,14 @@ videoExts =
, ".webm"
, ".ogv"
]

audioExts :: [Text]
audioExts =
[ ".aac"
, ".caf"
, ".flac"
, ".mp3"
, ".ogg"
, ".wav"
, ".wave"
]

0 comments on commit c59826b

Please sign in to comment.