Skip to content
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

Open
ccoupe opened this issue Nov 25, 2016 · 2 comments
Open

shoes to markdown #2

ccoupe opened this issue Nov 25, 2016 · 2 comments
Milestone

Comments

@ccoupe
Copy link
Member

ccoupe commented Nov 25, 2016

@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,

@IanTrudel IanTrudel added this to the 1.0.0 milestone Nov 25, 2016
@passenger94
Copy link

passenger94 commented Nov 25, 2016

# 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

@ccoupe
Copy link
Member Author

ccoupe commented Nov 26, 2016

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants