Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add make-process to create HTML files
The markdown files are converted to Markdown via kramdown, using a GitHub-like CSS. The resulting HTML files are placed under ./articles-html
- Loading branch information
Jonas Mueller
committed
Oct 31, 2014
1 parent
b17ad0d
commit 76c4675
Showing
6 changed files
with
465 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
articles-html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
gem "rake" | ||
gem "kramdown" | ||
gem "coderay" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
GEM | ||
specs: | ||
coderay (1.1.0) | ||
kramdown (1.4.2) | ||
rake (10.3.2) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
coderay | ||
kramdown | ||
rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "kramdown" | ||
require "coderay" | ||
require "fileutils" | ||
|
||
MARKDOWN_FILES = Dir.glob("#{__dir__}/articles/**/*.md") | ||
|
||
task default: :html_files | ||
|
||
desc "Generate HTML files from markdown articles" | ||
task :html_files do | ||
MARKDOWN_FILES.each do |markdown_file| | ||
html_path = markdown_file.sub("/articles/", "/articles-html/").sub(/\.md$/, ".html") | ||
puts "Generating #{html_path}" | ||
FileUtils.mkdir_p(File.dirname(html_path)) | ||
File.open(html_path, "w") do |html_file| | ||
filecontent = File.read(markdown_file) | ||
filecontent = filecontent.gsub("\`\`\`", "~~~") | ||
filecontent = Kramdown::Document.new(filecontent, template: "#{__dir__}/templates/default.html.erb") | ||
html_file.write(filecontent.to_html) | ||
end | ||
end | ||
end | ||
|
||
desc "Delete all generated HTML files" | ||
task :clean do | ||
FileUtils.rm_rf("#{__dir__}/articles-html") | ||
end |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.