Permalink
Browse files

sample-macruby/MarkdownViewer: Change the Markdown engine to support …

…the GitHub Flavored Markdown
  • Loading branch information...
1 parent 0fcb25e commit b6de0c1154b1b10059fa4fc863a42d0a3af146e6 @Watson1978 Watson1978 committed Apr 13, 2012
@@ -19,6 +19,7 @@
A9B47C4E14233B790094FD7E /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = A9B47C4D14233B790094FD7E /* style.css */; };
A9C6B67814238057006B2F2B /* MarkdownView.rb in Resources */ = {isa = PBXBuildFile; fileRef = A9C6B67714238057006B2F2B /* MarkdownView.rb */; };
A9CCAA0E1424D1300090EA63 /* init.html in Resources */ = {isa = PBXBuildFile; fileRef = A9CCAA0D1424D1300090EA63 /* init.html */; };
+ A9CD39711538560900E1CE8E /* Markdown.rb in Resources */ = {isa = PBXBuildFile; fileRef = A9CD39701538560900E1CE8E /* Markdown.rb */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -47,6 +48,7 @@
A9B47C4D14233B790094FD7E /* style.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = style.css; sourceTree = "<group>"; };
A9C6B67714238057006B2F2B /* MarkdownView.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = MarkdownView.rb; sourceTree = "<group>"; };
A9CCAA0D1424D1300090EA63 /* init.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = init.html; sourceTree = "<group>"; };
+ A9CD39701538560900E1CE8E /* Markdown.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = Markdown.rb; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -94,10 +96,11 @@
isa = PBXGroup;
children = (
A902D7591423102B00C55C37 /* AppDelegate.rb */,
+ A9CD39701538560900E1CE8E /* Markdown.rb */,
+ A9C6B67714238057006B2F2B /* MarkdownView.rb */,
A902D7521423102B00C55C37 /* Resources */,
A902D7561423102B00C55C37 /* Other Sources */,
A902D74A1423102B00C55C37 /* Supporting Files */,
- A9C6B67714238057006B2F2B /* MarkdownView.rb */,
);
path = MarkdownViewer;
sourceTree = "<group>";
@@ -137,7 +140,7 @@
/* Begin PBXLegacyTarget section */
A902D7461423102B00C55C37 /* Deployment */ = {
isa = PBXLegacyTarget;
- buildArgumentsString = "--compile --embed --gem rdiscount";
+ buildArgumentsString = "--compile --embed --gem redcarpet";
buildConfigurationList = A902D7601423102B00C55C37 /* Build configuration list for PBXLegacyTarget "Deployment" */;
buildPhases = (
);
@@ -209,6 +212,7 @@
A9C6B67814238057006B2F2B /* MarkdownView.rb in Resources */,
A9CCAA0E1424D1300090EA63 /* init.html in Resources */,
A92D8D1F1424D86A006F5A3A /* MarkdownViewer.icns in Resources */,
+ A9CD39711538560900E1CE8E /* Markdown.rb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4,8 +4,6 @@
#
# Created by Watson on 11/09/16.
#
-require 'rubygems'
-require 'rdiscount'
class AppDelegate
# outlet
@@ -67,7 +65,7 @@ def convert(sender)
dir = File.dirname(path) + "/"
nsurl = NSURL.URLWithString(dir)
res_path = NSBundle.mainBundle.resourcePath
- md = RDiscount.new(File.read(path))
+ string = Markdown.convert(File.read(path))
html =<<"EOS"
<html>
@@ -76,7 +74,7 @@ def convert(sender)
<link rel="stylesheet" type="text/css" href="#{res_path}/style.css">
</head>
<body>
-#{md.to_html}
+#{string}
</body>
</html>
EOS
@@ -0,0 +1,26 @@
+#
+# AppDelegate.rb
+# MarkdownViewer
+#
+# Created by Watson on 12/04/13.
+#
+require 'rubygems'
+require 'redcarpet'
+
+module Markdown
+ module_function
+
+ def convert(string)
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::SmartyHTML,
+ :fenced_code_blocks => true,
+ :no_intra_emphasis => true,
+ :autolink => true,
+ :strikethrough => true,
+ :lax_html_blocks => true,
+ :superscript => true,
+ :hard_wrap => true,
+ :tables => true,
+ :xhtml => true)
+ markdown.render(string)
+ end
+end
@@ -4,10 +4,10 @@
<style type="text/css">
body {
font-size: 12pt;
- background-color: #666;
+ background-color: #fff;
}
div {
- width: 180px;
+ width: 300px;
margin: 0 auto;
}
div.vertical {
@@ -17,13 +17,15 @@
}
div.box {
display:table-cell;
- height: 150px;
+ font-family: "Cochin", sans-serif;
+ font-size: 28pt;
+ height: 240px;
vertical-align:middle;
text-align:center;
- color: #ccc;
- background-color: #333;
+ border-style: dotted;
+ border-color: #444;
+ border-width: 5px;
-webkit-border-radius: 10px;
- -webkit-box-shadow: 1px 1px 15px 1px #333;
}
</style>
</head>
@@ -3,6 +3,6 @@ MarkdownViewer
## Requirement
-- Rubygems of [rdiscount](https://github.com/rtomayko/rdiscount)
+- Rubygems of [redcarpet](https://github.com/tanoku/redcarpet)
-Please type in Terminal.app: `sudo macgem install rdiscount`
+Please type in Terminal.app: `sudo macgem install redcarpet`

0 comments on commit b6de0c1

Please sign in to comment.