Class: JekyllJupyterNotebook::Converter

Inherits:
Jekyll::Converter
  • Object
show all
Defined in:
lib/jekyll-jupyter-notebook/converter.rb

Instance Method Summary collapse

Instance Method Details

#convert(content) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jekyll-jupyter-notebook/converter.rb', line 25

def convert(content)
  config = @config["jupyter_notebook"] || {}

  html = convert_notebook(content, config)
  html.sub!(/<link.+?href="custom.css">/, "")
  case config["content"] || "html"
  when "html"
  when "body"
    html.sub!(/\A.*?<\/title>/m, "")
    html.sub!(/<\/head>/, "")
    html.sub!(/<body>/, "")
    html.sub!(/<\/body>.*?\z/m, "")
  when "body-without-style"
    html.sub!(/\A.*?<body>/m, "")
    html.sub!(/<\/body>.*?\z/m, "")
  end
  html
end

#matches(ext) ⇒ Object



17
18
19
# File 'lib/jekyll-jupyter-notebook/converter.rb', line 17

def matches(ext)
  ext == ".ipynb"
end

#output_ext(ext) ⇒ Object



21
22
23
# File 'lib/jekyll-jupyter-notebook/converter.rb', line 21

def output_ext(ext)
  ".html"
end