typedown 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/typedown/document.rb +46 -0
- data/test/test_document.rb +2 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.9
|
data/lib/typedown/document.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#require 'rubygems'
|
2
2
|
#require 'kramdown'
|
3
3
|
require 'bluecloth'
|
4
|
+
#require 'redcloth'
|
4
5
|
|
5
6
|
module Typedown
|
6
7
|
class Document < String
|
@@ -52,11 +53,56 @@ module Typedown
|
|
52
53
|
end
|
53
54
|
|
54
55
|
|
56
|
+
def to_textile
|
57
|
+
text = self
|
58
|
+
|
59
|
+
# Translate '! headings' to '# headings'
|
60
|
+
text.gsub!(/^! /, "h1. ")
|
61
|
+
text.gsub!(/^!! /, "h2. ")
|
62
|
+
text.gsub!(/^!!! /, "h3. ")
|
63
|
+
text.gsub!(/^!!!! /, "h4. ")
|
64
|
+
text.gsub!(/^!!!!! /, "h5. ")
|
65
|
+
text.gsub!(/^!!!!!! /, "h6. ")
|
66
|
+
|
67
|
+
# Dialogue dashes
|
68
|
+
text.gsub!(/^-\.? /, "― ")
|
69
|
+
text.gsub!(/\s-\.? /, " ― ")
|
70
|
+
|
71
|
+
# Insert placeholders around lead in
|
72
|
+
text.gsub!(/^\. (( *[^\n].+\n)*)/, "! x!\\1!x-!\n")
|
73
|
+
# Remove placeholders while using them to remove whitespace
|
74
|
+
text.gsub!(/^! x!\s*/, "*")
|
75
|
+
text.gsub!(/\s*!x-!$/, "*")
|
76
|
+
|
77
|
+
|
78
|
+
# Insert placeholders around lead in
|
79
|
+
text.gsub!(/^\/\/\. (( *[^\n].+\n)*)/, "! x!\\1!x-!\n")
|
80
|
+
# Remove placeholders while using them to remove whitespace
|
81
|
+
text.gsub!(/^! x!\s*/, "*")
|
82
|
+
text.gsub!(/\s*!x-!$/, "*")
|
83
|
+
|
84
|
+
|
85
|
+
# Insert placeholders around lead in
|
86
|
+
text.gsub!(/^\/\. (( *[^\n].+\n)*)/, "! x!\\1!x-!\n")
|
87
|
+
# Remove placeholders while using them to remove whitespace
|
88
|
+
text.gsub!(/^! x!\s*/, "_")
|
89
|
+
text.gsub!(/\s*!x-!$/, "_")
|
90
|
+
|
91
|
+
# Slash for _
|
92
|
+
text.gsub!(/(\s)\/(\S+)\/(\s)[\.\,\?\!]?/, "\\1_\\2_\\3")
|
93
|
+
text.gsub!(/(\s)\/\/(\S+)\/\/[\.\,\?\!]?(\s)/, "\\1*\\2*\\3")
|
94
|
+
text.gsub!(/(\s)\/\/\/(\S+)\/\/\/[\.\,\?\!]?(\s)/, "\\1*_\\2_*\\3")
|
95
|
+
text
|
96
|
+
end
|
97
|
+
|
98
|
+
|
55
99
|
def to_html
|
56
100
|
#kramdown = Kramdown::Document.new to_markdown
|
57
101
|
#kramdown.to_html
|
58
102
|
bluecloth = BlueCloth::new( to_markdown )
|
59
103
|
bluecloth.to_html
|
104
|
+
#redcloth = RedCloth.new( to_textile )
|
105
|
+
#redcloth.to_html
|
60
106
|
end
|
61
107
|
end
|
62
108
|
end
|
data/test/test_document.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typedown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 9
|
10
|
+
version: 0.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- wrimle
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-05 00:00:00 +02:00
|
19
19
|
default_executable: typedown
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|