GithubHelp home page GithubHelp logo

coatless-quarto / embedio Goto Github PK

View Code? Open in Web Editor NEW
39.0 0.0 2.0 3.39 MB

Quarto extension for Embedding HTML Documents and Presentations

Home Page: http://quarto.thecoatlessprofessor.com/embedio/

Lua 90.94% Makefile 9.06%
embed-files quarto quarto-extension quarto-shortcode

embedio's People

Contributors

coatless avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

embedio's Issues

Add ability to embed PDF

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"

Explore/Add ability to inject code into a custom code cell

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

Add ability to include HTML/revealjs slide decks

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
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.