Sha256: cfd9ace098ff6818d05b7a8ef245797f6ed7d2d8841d9be9f9ff1c07d3951c50

Contents?: true

Size: 732 Bytes

Versions: 1

Compression:

Stored size: 732 Bytes

Contents

#!/usr/bin/env ruby

require "redcarpet"

LAYOUT = File.read("./docs/layout.html")

def markdown(text)
  options = {
    autolink: true,
    fenced_code_blocks: true,
    tables: true
  }

  renderer = Redcarpet::Render::HTML.new
  markdown = Redcarpet::Markdown.new(renderer, options)

  return markdown.render(text)
end

def title(content)
  return content.match(/<h1>(.*)<\/h1>/)[1]
end

def render(content)
  markdown = markdown(content)
  title = title(markdown)

  return sprintf(LAYOUT, content: markdown, title: title)
end

Dir["./docs/**/*.md"].each do |file|
  _, name = file.split("./docs")

  name = name.sub(".md", ".html")
  output = File.join("./docs/public", name)

  File.write(output, render(File.read(file)))
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tynn-0.0.4 docs/bin/build