Class: JekyllJupyterNotebook::Tag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-jupyter-notebook/tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, parse_context) ⇒ Tag

Returns a new instance of Tag.



19
20
21
# File 'lib/jekyll-jupyter-notebook/tag.rb', line 19

def initialize(tag_name, markup, parse_context)
  super
end

Instance Method Details

#render(context) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/jekyll-jupyter-notebook/tag.rb', line 27

def render(context)
  variable = Liquid::Variable.new(@markup, @parse_context)
  notebook_path = variable.render(context)
  if notebook_path.nil?
    Jekyll.logger.warn("Warning:",
                       "Jupyter Notebook path be string literal: " +
                       "<#{@markup.strip.inspect}>")
    notebook_path = @markup.strip # For backward compatibility
  end
  notebook_html_path = "#{notebook_path}.html"
  <<-HTML
<div
  class="jupyter-notebook"
  style="position: relative; width: 100%; margin: 0 auto;">
  <div class="jupyter-notebook-iframe-container">
<iframe
  src="#{CGI.escapeHTML(notebook_html_path)}"
  style="position: absolute; top: 0; left: 0; border-style: none;"
  width="100%"
  height="100%"
  onload="this.parentElement.style.paddingBottom = (this.contentWindow.document.documentElement.scrollHeight + 10) + 'px'"></iframe>
  </div>
</div>
  HTML
end

#syntax_exampleObject



23
24
25
# File 'lib/jekyll-jupyter-notebook/tag.rb', line 23

def syntax_example
  "{% #{@tag_name} \"filename.ipynb\" %}"
end