coatless-quarto / embedio Goto Github PK
View Code? Open in Web Editor NEWQuarto extension for Embedding HTML Documents and Presentations
Home Page: http://quarto.thecoatlessprofessor.com/embedio/
Quarto extension for Embedding HTML Documents and Presentations
Home Page: http://quarto.thecoatlessprofessor.com/embedio/
Proposed shortcode:
{{< embed-pdf file="my-document.pdf" >>
Expands to:
<object data="my-document.pdf" type="application/pdf" width="100%" height="600px">
<p>Unable to display PDF file. <a href="my-document.pdf">Download</a> instead.</p>
</object>
Sketch lua:
return {
["embed-pdf"] = function(args, kwargs, meta)
-- Supported options for now
local pdf_file_name = pandoc.utils.stringify(kwargs["file"])
local height = pandoc.utils.stringify(kwargs["height"]) or "600px"
local width = pandoc.utils.stringify(kwargs["height"]) or "100%"
-- HTML block
local template_pdf = [[
<object data=%q type="application/pdf" width=%q height=%q>
<p>Unable to display PDF file. <a href=%q>Download</a> instead.</p>
</object>
]]
-- Substitute values
local combined_str = string.format(template_pdf, pdf_file_name, width, height, pdf_file_name)
-- Return as HTML block
return pandoc.RawBlock('html', combined_str)
end
}
Note: string.format()
is similar to the printf("format",...)
with the additional option of %q
for quoted strings.
%s
gives a string like hello
%q
gives a quoted string like "hello"
This would be similar to {{< include >}}
shortcode, e.g. {{< include _content.qmd >}}
; but maybe work inside of a markdown structure?
This isn't quite a situation where I want the official {quarto-ext/include-code-files}
extension as that would require:
```{.r include="script.r"}
```
Instead, I'm looking for something more actionable for custom code cells.
```{shinylive-r}
#| standalone: true
#| viewerHeight: 600
{{<embed-code file="path/to/shiny/app/" >}}
```
This is to tide over the request in quarto-ext/shinylive#37
Proposed shortcode:
{{< embed-revealjs file="path/to/my-slides.revealjs" >>
Expands to:
````html
<style>
.slide-deck {
border: 3px solid #dee2e6;
width: 100%;
}
</style>
<div>
```{=html}
<iframe class="slide-deck" src="path/to/presentation/"></iframe>
```
</div>
````
Sketch lua:
-- Avoid duplicate class definitions
local initializedSlideCSS = false
-- Load CSS into header once
local ensureSlideCSSPresent function()
if initializedSlideCSS then
return
end
initializedSlideCSS = true
-- Default CSS class
local slideCSS = [[
<style>
.slide-deck {
border: 3px solid #dee2e6;
width: 100%;
}
</style>
]]
-- Inject into the header
quarto.doc.include_text("in-header", slideCSS)
end
return {
["embed-revealjs"] = function(args, kwargs, meta , raw_args)
-- Supported options for now
local slide_file_name = pandoc.utils.stringify(kwargs["file"])
local height = pandoc.utils.stringify(kwargs["height"]) or "475px"
-- HTML block
local template_revealjs = [[
<div>
<iframe class="slide-deck" src=%q height=%q></iframe>
</div>
]]
-- Substitute values
local combined_str = string.format(template_revealjs, slide_file_name, height)
-- Return as HTML block
return pandoc.RawBlock('html', combined_str)
end
}
Shortcode:
{{< audio file="" >}}
Expands to:
<figure class="%s">
<figcaption>%s</figcaption>
<audio controls preload="%s">
<source src="%s" type="audio/%s">
Your browser does not support the audio tag.
</audio>
<a href="%s"> Download audio </a>
</figure>
Needs the audio
tag, c.f.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.