pink_shirt 0.0.1

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.
@@ -0,0 +1,125 @@
1
+ Strong importance:
2
+ Strong importance:
3
+ desc: Strong importance can be given to the text by surrounding it with asterisks. The
4
+ strong text is commonly styled as **bold**.
5
+ input: Don't *ever* pull this lever.
6
+ output: <p>Don&#8217;t <strong>ever</strong> pull this lever.</p>
7
+ Stress emphasis:
8
+ Stress emphasis:
9
+ desc: To add emphasis to a stressed word or phrase, surround it with underscores. Emphasized
10
+ text is typically styled as __italics__.
11
+ input: You didn't actually _believe_ her, did you?
12
+ output: <p>You didn&#8217;t actually <em>believe</em> her, did you?</p>
13
+ # Stylistic offset:
14
+ # Stylistic offset:
15
+ # desc: To stylistically differentiate a word or phrase from the surrounding text
16
+ # *without conveying any extra importance*, place two asterisks on either side. Uses
17
+ # are key words in a document abstract, product names in a review, or other
18
+ # spans of text whose typical typographic presentation is boldened.
19
+ # input: |-
20
+ # Search results for **Textile**:
21
+
22
+ # h4. ["**Textile** (markup language) - Wikipedia":http://en.wikipedia.org/wiki/Textile_(markup_language)]
23
+
24
+ # **Textile** is a lightweight markup language originally developed by Dean Allen and billed as a "humane Web text generator". **Textile** converts its marked-up text ...
25
+ # output: |-
26
+ # <p>Search results for <b>Textile</b>:</p>
27
+ # <h4><a href="http://en.wikipedia.org/wiki/Textile_(markup_language)"><b>Textile</b> (markup language) &#8211; Wikipedia</a></h4>
28
+ # <p><b>Textile</b> is a lightweight markup language originally developed by Dean Allen and billed as a &#8220;humane Web text generator&#8221;. <b>Textile</b> converts its marked-up text &#8230;</p>
29
+ Stylistic offset:
30
+ Stylistic offset:
31
+ desc: To stylistically differentiate a word or phrase from the surrounding text
32
+ *without conveying any extra importance*, place two asterisks on either side. Uses
33
+ are key words in a document abstract, product names in a review, or other
34
+ spans of text whose typical typographic presentation is boldened.
35
+ input: |-
36
+ **Textile** is a lightweight markup language originally developed by Dean Allen and billed as a "humane Web text generator". **Textile** converts its marked-up text ...
37
+ output: |-
38
+ <p><b>Textile</b> is a lightweight markup language originally developed by Dean Allen and billed as a &#8220;humane Web text generator&#8221;. <b>Textile</b> converts its marked-up text &#8230;</p>
39
+ Alternate voice:
40
+ Alternate voice:
41
+ desc: Double underscores surround a span of text in an alternate mood or voice,
42
+ a technical term, an idiomatic phrase from another language, a thought, a
43
+ ship name, or some other prose whose typical typographic presentation is italicized.
44
+ input: I just got the weirdest feeling of __déjà vu__.
45
+ output: <p>I just got the weirdest feeling of <i>déjà vu</i>.</p>
46
+ Citation:
47
+ Citation:
48
+ desc: Cite the title of a work (e.g. a book, paper, essay, poem, score, song,
49
+ script, film, TV show, game, sculpture, painting, theater production, play,
50
+ opera, musical, exhibition, or anything other work whose title is italicized
51
+ in traditional style guides) by surrounding it with two question marks on
52
+ either side. This can be a work that is being quoted or referenced in detail
53
+ (i.e. a citation), or it can just be a work that is mentioned in passing.
54
+ input: My wife's favorite book is ??The Count of Monte Cristo?? by Dumas.
55
+ output: <p>My wife&#8217;s favorite book is <cite>The Count of Monte Cristo</cite>
56
+ by Dumas.</p>
57
+ Insertions and deletions:
58
+ Insertions and deletions:
59
+ desc: To indicate a passage which has been deleted, surround it with minuses. To
60
+ indicate an insertion, use pluses.
61
+ input: The news networks declared -Al Gore- +George W. Bush+ the winner in Florida.
62
+ output: <p>The news networks declared <del>Al Gore</del> <ins>George W. Bush</ins>
63
+ the winner in Florida.</p>
64
+ # Explicit insertion and deletion:
65
+ # desc: If your insertion or deletion isn't being recognized or is being confused
66
+ # with another modifier, you can make it more explicit by surrounding it with
67
+ # square brackets.
68
+ # input: '[-this was deleted-][+this was added+] to the paragraph'
69
+ # output: <p><del>this was deleted</del><ins>this was added</ins> to the paragraph</p>
70
+ Superscript and subscript:
71
+ Superscript and subscript:
72
+ desc: Superscript and subscript phrases are surrounded with caret and tilde
73
+ characters, respectively.
74
+ input: "f(x, n) = log ~4~ x ^n^"
75
+ output: <p>f(x, n) = log <sub>4</sub> x <sup>n</sup></p>
76
+ # Tight superscript and subscript:
77
+ # desc: If you want it without spaces around the super- and subscripted text,
78
+ # use square brackets.
79
+ # input: f(x, n) = log[~4~]x[^n^]
80
+ # output: <p>f(x, n) = log<sub>4</sub>x<sup>n</sup></p>
81
+ Links:
82
+ Links:
83
+ desc: Links have the text of the link in quotes, followed by a colon and the
84
+ URL.
85
+ input: Learn more "about the company":/about and our "board of directors":../about#board.
86
+ output: <p>Learn more <a href="/about">about the company</a> and our <a href="../about#board">board
87
+ of directors</a>.</p>
88
+ Link title:
89
+ desc: |-
90
+ A title may be placed in parentheses at the end of the link text. Link titles help users predict where they are going. "Jakob Nielsen(Nielsen's guidelines for link titles)":http://www.useit.com/alertbox/980111.html recommends you use them sparingly and not assume the user will see them at all.
91
+ input: Visit our "parent company (Example Corporation)":http://example.com.
92
+ output: <p>Visit our <a href="http://example.com" title="Example Corporation">parent
93
+ company</a>.</p>
94
+ # Bracketed link:
95
+ # desc: When the link isn't surrounded by spaces or punctuation, or when the URL
96
+ # ending may be ambiguous, surround the link with square brackets.
97
+ # input: This is a link to a ["Wikipedia article about Textile":http://en.wikipedia.org/wiki/Textile_(markup_language)].
98
+ # output: <p>This is a link to a <a href="http://en.wikipedia.org/wiki/Textile_(markup_language)">Wikipedia
99
+ # article about Textile</a>.</p>
100
+ # Link alias:
101
+ # desc: If you link to a URL repeatedly, you can replace the URL with a link alias
102
+ # defined elsewhere in the Textile document.
103
+ # input: |-
104
+ # I'm really excited about "Textile":textile. I love it so much, I think I'll name my first child "Tex":textile.
105
+
106
+ # [textile]http://textileit.com
107
+ # output: <p>I&#8217;m really excited about <a href="http://textileit.com">Textile</a>. I love it so much, I think I&#8217;ll name my first child <a href="http://textileit.com">Tex</a>.</p>
108
+ Link attributes:
109
+ desc: Link "attributes":../attributes can be specified at the beginning of the
110
+ link text followed by a period and space.
111
+ input: '"(my-class). This is a link with class":http://textileit.com'
112
+ output: <p><a href="http://textileit.com" class="my-class">This is a link with
113
+ class</a></p>
114
+ Images:
115
+ Images:
116
+ desc: Include an image by surrounding its URL with exclamation marks. Alt text
117
+ can be provided in parentheses.
118
+ input: '!http://www.w3.org/Icons/valid-html401(This page is valid HTML)!'
119
+ output: <p><img src="http://www.w3.org/Icons/valid-html401" title="This page
120
+ is valid HTML" alt="This page is valid HTML" /></p>
121
+ Image links:
122
+ desc: Images can be linked by putting a colon and the link URL after the image.
123
+ input: "\"!http://www.w3.org/Icons/valid-html401!\":http://validator.w3.org/check?uri=referer"
124
+ output: <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401"
125
+ alt="" /></a></p>
@@ -0,0 +1,113 @@
1
+ #read-specs.rb
2
+ require 'yaml'
3
+ require 'redcloth'
4
+
5
+ # TextileSpec
6
+ # =============
7
+ # the textile spec
8
+ # from
9
+ class TextileSpec
10
+ SPECS_PATH = "./spec/textile-spec/"
11
+ def initialize(subset = nil)
12
+ @subset = subset
13
+ @specs_path ||= SPECS_PATH
14
+ end
15
+ def index
16
+ @index ||= TextileSpec::Index.new
17
+ end
18
+
19
+ def get_spec(name)
20
+ file_name = index.list[name]['file']
21
+ spec = TextileSpec::Spec.new(@specs_path + file_name)
22
+ spec
23
+ end
24
+
25
+ def to_hash
26
+ return @hash if @hash
27
+
28
+ @hash = {}
29
+
30
+ if @subset
31
+ names = [@subset]
32
+ else
33
+ names = index.names
34
+ end
35
+ names.each {|name|
36
+ @hash[name] = get_spec(name).spec
37
+ }
38
+ @hash
39
+ end
40
+
41
+ def flat
42
+ TextileSpec::Flattener.new(to_hash).flat
43
+ end
44
+ end
45
+
46
+ # TextileSpec::Index
47
+ # ==================
48
+ # functions for loading the index file of the textile spec
49
+ class TextileSpec::Index
50
+
51
+ INDEX_FILE = "index.yaml"
52
+
53
+ attr_accessor :version
54
+
55
+ def initialize(specs_path = nil, index_file = nil)
56
+ @specs_path = specs_path || TextileSpec::SPECS_PATH
57
+ @index_file = index_file || INDEX_FILE
58
+ @version = contents[:version]
59
+
60
+ end
61
+ def list
62
+ @list ||= contents[:specs]
63
+ end
64
+ def contents
65
+ return @contents if @contents
66
+
67
+ index_file = File.read(@specs_path + @index_file)
68
+ @contents = YAML::load(index_file)
69
+
70
+ return @contents
71
+ end
72
+
73
+ def names
74
+ list.keys
75
+ end
76
+
77
+ end
78
+
79
+ class TextileSpec::Flattener
80
+ attr_accessor :flat
81
+ def initialize(hash)
82
+ @flat = []
83
+ @trail = []
84
+ dive(hash)
85
+
86
+ end
87
+ def dive(hash)
88
+ if hash['desc']
89
+ name = @trail.join(" | ")
90
+ @flat << hash.merge({:name => name})
91
+ @trail = []
92
+ else
93
+
94
+ hash.each{|k, v|
95
+ @trail << k
96
+ dive(v)
97
+ }
98
+ end
99
+ end
100
+ end
101
+
102
+ class TextileSpec::Spec
103
+ attr_accessor :spec
104
+ def initialize(file_name)
105
+ @file_name = file_name
106
+ @spec = parse_file
107
+ end
108
+ def parse_file
109
+ spec_file = File.read @file_name
110
+ YAML::load(spec_file)
111
+ end
112
+ end
113
+
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pink_shirt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Graeme Worthy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: RedCloth
16
+ requirement: &70119661660080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70119661660080
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70119661659440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70119661659440
36
+ - !ruby/object:Gem::Dependency
37
+ name: nokogiri
38
+ requirement: &70119661658480 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70119661658480
47
+ description: Converts Html to Textile, or as some say 'html2textile', it's built on
48
+ nokogiri''
49
+ email:
50
+ - graemeworthy@gmail.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - Rakefile
58
+ - Readme.txt
59
+ - lib/pink_shirt.rb
60
+ - lib/pink_shirt/attributes.rb
61
+ - lib/pink_shirt/entities.rb
62
+ - lib/pink_shirt/flags.rb
63
+ - lib/pink_shirt/output.rb
64
+ - lib/pink_shirt/sax.rb
65
+ - lib/pink_shirt/sax/acronym.rb
66
+ - lib/pink_shirt/sax/base.rb
67
+ - lib/pink_shirt/sax/basic.rb
68
+ - lib/pink_shirt/sax/block_level.rb
69
+ - lib/pink_shirt/sax/boiler_plate.rb
70
+ - lib/pink_shirt/sax/images.rb
71
+ - lib/pink_shirt/sax/links.rb
72
+ - lib/pink_shirt/sax/lists.rb
73
+ - lib/pink_shirt/sax/preformatted.rb
74
+ - lib/pink_shirt/sax/script.rb
75
+ - lib/pink_shirt/sax/tables.rb
76
+ - lib/pink_shirt/version.rb
77
+ - pink_shirt.gemspec
78
+ - spec/basics_spec.rb
79
+ - spec/examples/basics.yaml
80
+ - spec/reverse_redcloth_spec.rb
81
+ - spec/reverse_textile_spec.rb
82
+ - spec/spec_helper.rb
83
+ - spec/textile-spec/CHANGELOG
84
+ - spec/textile-spec/README.textile
85
+ - spec/textile-spec/attributes.yaml
86
+ - spec/textile-spec/html.yaml
87
+ - spec/textile-spec/index.yaml
88
+ - spec/textile-spec/page_layout.yaml
89
+ - spec/textile-spec/paragraph_text.yaml
90
+ - spec/textile-spec/phrase_modifiers.yaml
91
+ - spec/textile_spec.rb
92
+ homepage: ''
93
+ licenses: []
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project: pink_shirt
112
+ rubygems_version: 1.8.17
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: An Html to Textile Converter
116
+ test_files:
117
+ - spec/basics_spec.rb
118
+ - spec/examples/basics.yaml
119
+ - spec/reverse_redcloth_spec.rb
120
+ - spec/reverse_textile_spec.rb
121
+ - spec/spec_helper.rb
122
+ - spec/textile-spec/CHANGELOG
123
+ - spec/textile-spec/README.textile
124
+ - spec/textile-spec/attributes.yaml
125
+ - spec/textile-spec/html.yaml
126
+ - spec/textile-spec/index.yaml
127
+ - spec/textile-spec/page_layout.yaml
128
+ - spec/textile-spec/paragraph_text.yaml
129
+ - spec/textile-spec/phrase_modifiers.yaml
130
+ - spec/textile_spec.rb