Skip to content

Commit

Permalink
Add support for embedded pdf (#341)
Browse files Browse the repository at this point in the history
Co-authored-by: Sridhar Ratnakumar <[email protected]>
  • Loading branch information
mnaoumov and srid authored Sep 17, 2022
1 parent 40c4791 commit 61fd13f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions default/templates/filters/embed-pdf.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<object class="mb-3 embedded-pdf w-full" type="application/pdf" data="${ema:url}"
style="height: 800px">
<a href="${ema:url}">Open pdf</a>
</object>
7 changes: 7 additions & 0 deletions docs/demo/embed.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@ It is also posible to add images inline (example, here's the site favicon: [![[f
The following is the result of using `![[death-note.mp4]]`.

![[death-note.mp4]]


### PDFs

PDFs can be embedded using the same syntax; ie. `![[git-cheat-sheet-education.pdf]]` will show:

![[git-cheat-sheet-education.pdf]]
Binary file added docs/demo/git-cheat-sheet-education.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion emanote.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: emanote
version: 0.7.8.2
version: 0.7.9.0
license: AGPL-3.0-only
copyright: 2021 Sridhar Ratnakumar
maintainer: [email protected]
Expand Down
3 changes: 3 additions & 0 deletions src/Emanote/Pandoc/Renderer/Embed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ embedStaticFileRoute model wl staticFile = do
| any (`T.isSuffixOf` toText fp) videoExts -> do
pure . runEmbedTemplate "video" $ do
"ema:url" ## HI.textSplice url
| ".pdf" `T.isSuffixOf` toText fp -> do
pure . runEmbedTemplate "pdf" $ do
"ema:url" ## HI.textSplice url
| otherwise -> Nothing

imageExts :: [Text]
Expand Down

0 comments on commit 61fd13f

Please sign in to comment.