typedown 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -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!(/^-\.? /, "&#8213; ")
69
+ text.gsub!(/\s-\.? /, " &#8213; ")
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
@@ -10,7 +10,8 @@ class TestDocument < Test::Unit::TestCase
10
10
 
11
11
  should "parse with no exceptions" do
12
12
  assert_nothing_raised do
13
- Typedown::Document.new @doc
13
+ td = Typedown::Document.new @doc
14
+ puts td.to_html
14
15
  end
15
16
  end
16
17
  end
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: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
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-04 00:00:00 +02:00
18
+ date: 2010-09-05 00:00:00 +02:00
19
19
  default_executable: typedown
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency