-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shoes to markdown #2
Milestone
Comments
# encoding: UTF-8
require 'redcarpet'
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, fenced_code_blocks: true,
no_intra_emphasis: true,
autolink: true)
TOPDIR = "path/to/shoes/topdir"
body_html = body_mrkdown = ""
File.open("#{TOPDIR}/static/manual-en.txt", 'r') { |f|
body_mrkdown = f.read.gsub(/`([\w\-\.\?;=⌘\/]+)`/, '<span style="color:red">\\1</span>') # word red
.gsub(/\{{3}(?:\s*\#![^\n]+)?(.+?)\}{3}/m, "```ruby\\1```") # code
.gsub(/\^(.+?)\^/m, '\\1').gsub(/\[\[BR\]\]/i, "\n") # ^....^
.gsub(/'''(.+)'''/, '**\\1**') # bold
.gsub(/\[\[(\S+?)\]\]/, '<span style="color:blue">\\1</span>') # internal link TODO
.gsub(/\[\[(\S+?) (.+?)\]\]/, '[\\2](\\1)') # external link
.gsub(/\!(\{([^}\n]+)\})?([^!\n]+\.\w+)\!/, "![\\2](#{TOPDIR}static/\\3)") # image
.gsub(/={4}/, '####').gsub(/={3}/, '###').gsub(/={2}/, '##').gsub(/={1} (.+) ={1}/, '#\\1#') # titles
body_html = markdown.render(body_mrkdown)
}
# body_mrkdown = f.read.gsub(/`{1}(.+)`{1}/, '<span style="color:red">\\1</span>') # word red
html = <<-EOH
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Shoes Manual's red carpet</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
#{body_html}
</body>
</html>
EOH
File.open("#{TOPDIR}/shoesManual_redcarpet01.md", 'w') { |f|
f << body_mrkdown.gsub("#{TOPDIR}/dist/static", '/static')
}
File.open("#{TOPDIR}/shoesManual_redcarpet01.html", 'w') { |f|
f << html
} Markdown is here : https://github.com/passenger94/shoes3/blob/manual_mardown/shoesManual_redcarpet01.md |
Thank you. |
ccoupe
pushed a commit
that referenced
this issue
Jan 2, 2017
* very simple documents like README.md should be handled yaml `have_nav: false` * add icon setting * add font choice * WIP. just checkpointing the current state.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@passenger94 , Do you still have the script to convert the Shoes manual to redcloth md?. For the manual, I see a two stage conversion '.funky_shoes' ->.md and then we can feed that to our kramdown -> ebook thing,
The text was updated successfully, but these errors were encountered: