hemingway 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/hemingway/block/block.rb +222 -121
- data/lib/hemingway/block/block.treetop +6 -3
- data/lib/hemingway/block/center/center.rb +134 -0
- data/lib/hemingway/block/center/center.treetop +17 -0
- data/lib/hemingway/block/center/center_nodes.rb +17 -0
- data/lib/hemingway/block/list/list.rb +30 -25
- data/lib/hemingway/block/list/list.treetop +1 -1
- data/lib/hemingway/build.rb +104 -6
- data/lib/hemingway/latex.rb +82 -15
- data/lib/hemingway/latex.treetop +4 -4
- data/lib/hemingway/latex_nodes.rb +16 -0
- data/lib/hemingway/math/math.rb +88 -4
- data/lib/hemingway/math/math.treetop +5 -1
- data/lib/hemingway/math/math_nodes.rb +14 -1
- data/lib/hemingway/special/special.rb +13 -2
- data/lib/hemingway/special/special.treetop +1 -1
- data/lib/hemingway/special/special_nodes.rb +9 -5
- data/lib/hemingway/symbol/symbol.rb +14 -2
- data/lib/hemingway/symbol/symbol.treetop +2 -1
- data/lib/hemingway/tag/tag.rb +162 -2
- data/lib/hemingway/tag/tag.treetop +6 -0
- data/lib/hemingway/tag/tag_nodes.rb +6 -0
- data/lib/hemingway/version.rb +1 -1
- data/spec/build_spec.rb +17 -0
- data/spec/nodes/block/center_spec.rb +27 -0
- data/spec/nodes/block/list_spec.rb +5 -0
- data/spec/nodes/block_spec.rb +5 -1
- data/spec/nodes/math_spec.rb +10 -0
- data/spec/nodes/special_spec.rb +6 -0
- data/spec/nodes/tag_spec.rb +9 -0
- metadata +7 -2
@@ -11,6 +11,8 @@ module Hemingway
|
|
11
11
|
tag_start hfill spaces sequence:( !newline content )* <HFillNode>
|
12
12
|
/
|
13
13
|
tag_start neatline <NeatLineNode>
|
14
|
+
/
|
15
|
+
tag_start accent "{" character:. "}" <AccentNode>
|
14
16
|
end
|
15
17
|
|
16
18
|
# All tag types will be responsible with implementing their own
|
@@ -51,6 +53,10 @@ module Hemingway
|
|
51
53
|
"neatline"
|
52
54
|
end
|
53
55
|
|
56
|
+
rule accent
|
57
|
+
'`' / "'" / '^' / '"' / "c" / "~" / "r"
|
58
|
+
end
|
59
|
+
|
54
60
|
rule tag_start
|
55
61
|
"\\"
|
56
62
|
end
|
data/lib/hemingway/version.rb
CHANGED
data/spec/build_spec.rb
CHANGED
@@ -39,6 +39,10 @@ module Hemingway
|
|
39
39
|
Build.tag(attribute, content, :id => id, :class => klass, :href => href).should == "<#{attribute} id='#{id}' class='#{klass}' href='#{href}'>#{content}</#{attribute}>"
|
40
40
|
end
|
41
41
|
|
42
|
+
it 'should generate a tag with content and a src and no closing tag' do
|
43
|
+
Build.tag("img", nil, :src => "/assets/vibes.png", :close_tag => false).should == "<img src='/assets/vibes.png'>"
|
44
|
+
end
|
45
|
+
|
42
46
|
# Can't wait for Ruby 2.0
|
43
47
|
it 'should generate a tag with content and a class and no content' do
|
44
48
|
Build.tag(attribute, nil, :class => klass).should == "<#{attribute} class='#{klass}'></#{attribute}>"
|
@@ -60,6 +64,19 @@ module Hemingway
|
|
60
64
|
|
61
65
|
end
|
62
66
|
|
67
|
+
describe "#accent" do
|
68
|
+
|
69
|
+
it 'should convert an accent and character into the html equivalent' do
|
70
|
+
Build.accent("A", "`").should == "À"
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should leave the character untouched if no equiavalent exists' do
|
74
|
+
Build.accent("G", "`").should == "G"
|
75
|
+
Build.accent("C", "~").should == "C"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
63
80
|
end
|
64
81
|
|
65
82
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Hemingway
|
4
|
+
|
5
|
+
describe Parser do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@parser = Parser.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#center" do
|
12
|
+
|
13
|
+
it 'centers text' do
|
14
|
+
html = @parser.parse("\\begin{center} So show my why you're strong. \n\n Ignore everybody else \n\n We're alone now \\end{center}").html
|
15
|
+
html.should == "<div class='entry'><p><div class='center'>So show my why you're strong. \n\n Ignore everybody else \n\n We're alone now </div></p></div>"
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'centers content too' do
|
19
|
+
html = @parser.parse("The New James Blake: \\begin{center} So show my why you're \\emph{strong}. \n\n Ignore \\textsc{everybody} else \n\n We're alone now \\end{center}").html
|
20
|
+
html.should == "<div class='entry'><p>The New James Blake: <div class='center'>So show my why you're <em>strong</em>. \n\n Ignore <span class='textsc'>everybody</span> else \n\n We're alone now </div></p></div>"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -60,6 +60,11 @@ module Hemingway
|
|
60
60
|
html.should == "<div class='entry'><p><ul><li><ul><li><ul><li>hey </li></ul> </li></ul> </li></ul></p></div>"
|
61
61
|
end
|
62
62
|
|
63
|
+
it 'allows me to created a nested list without specfying another item' do
|
64
|
+
html = @parser.parse("\\begin{itemize} \n \\item thing 1 \n \\begin{itemize} \n \\item 2 \n \\end{itemize} \n \\end{itemize}").html
|
65
|
+
html.should == "<div class='entry'><p><ul><li>thing 1 <ul><li>2 </li></ul> </li></ul></p></div>"
|
66
|
+
end
|
67
|
+
|
63
68
|
end
|
64
69
|
|
65
70
|
describe "#enumerate" do
|
data/spec/nodes/block_spec.rb
CHANGED
@@ -14,8 +14,12 @@ module Hemingway
|
|
14
14
|
@parser.parse("\\begin{itemize} \\item hey \\end{description}").should be_nil
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
it "should allow me to put blocks right after text and a newline" do
|
18
|
+
html = @parser.parse("check out this f*ckin block:\n\\begin{itemize} \\item hey \\end{itemize}").html
|
19
|
+
html.should == "<div class='entry'><p>check out this f*ckin block:<ul><li>hey </li></ul></p></div>"
|
20
|
+
end
|
18
21
|
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
data/spec/nodes/math_spec.rb
CHANGED
@@ -24,6 +24,16 @@ module Hemingway
|
|
24
24
|
html.should == "<div class='entry'><p>hello Δ</p></div>"
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'should allow me to exponentiate text' do
|
28
|
+
html = @parser.parse("December 7$^{th}$").html
|
29
|
+
html.should == "<div class='entry'><p>December 7<sup>th</sup></p></div>"
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should allow me to make a degree sign' do
|
33
|
+
html = @parser.parse("25 $^{\\circ}$ celcius").html
|
34
|
+
html.should == "<div class='entry'><p>25 ° celcius</p></div>"
|
35
|
+
end
|
36
|
+
|
27
37
|
end
|
28
38
|
|
29
39
|
end
|
data/spec/nodes/special_spec.rb
CHANGED
@@ -15,6 +15,12 @@ module Hemingway
|
|
15
15
|
html.should == "<div class='entry'><p>War & Peace</p></div>"
|
16
16
|
end
|
17
17
|
|
18
|
+
it 'should escape a special backslash character' do
|
19
|
+
html = @parser.parse("\\textbackslash{}part").html
|
20
|
+
html.should == "<div class='entry'><p>\\part</p></div>"
|
21
|
+
end
|
22
|
+
|
23
|
+
|
18
24
|
it 'should allow for special chars and tags in sequence' do
|
19
25
|
html = @parser.parse("War \\& Peace \\textbf{Tolstoy} \\#").html
|
20
26
|
html.should == "<div class='entry'><p>War & Peace <strong>Tolstoy</strong> #</p></div>"
|
data/spec/nodes/tag_spec.rb
CHANGED
@@ -93,6 +93,15 @@ module Hemingway
|
|
93
93
|
|
94
94
|
end
|
95
95
|
|
96
|
+
describe "#accents" do
|
97
|
+
|
98
|
+
it 'allows me to put accents inline with text' do
|
99
|
+
html = @parser.parse("Charm\\'{e}e de vous voir. Je suis tr\\`{e} contente de vous voir.").html
|
100
|
+
html.should == "<div class='entry'><p>Charmée de vous voir. Je suis trè contente de vous voir.</p></div>"
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
96
105
|
end
|
97
106
|
|
98
107
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hemingway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Myers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -56,6 +56,9 @@ files:
|
|
56
56
|
- lib/hemingway/block/block.rb
|
57
57
|
- lib/hemingway/block/block.treetop
|
58
58
|
- lib/hemingway/block/block_nodes.rb
|
59
|
+
- lib/hemingway/block/center/center.rb
|
60
|
+
- lib/hemingway/block/center/center.treetop
|
61
|
+
- lib/hemingway/block/center/center_nodes.rb
|
59
62
|
- lib/hemingway/block/list/list.rb
|
60
63
|
- lib/hemingway/block/list/list.treetop
|
61
64
|
- lib/hemingway/block/list/list_nodes.rb
|
@@ -91,6 +94,7 @@ files:
|
|
91
94
|
- script/build
|
92
95
|
- script/test
|
93
96
|
- spec/build_spec.rb
|
97
|
+
- spec/nodes/block/center_spec.rb
|
94
98
|
- spec/nodes/block/list_spec.rb
|
95
99
|
- spec/nodes/block/quote_spec.rb
|
96
100
|
- spec/nodes/block/verbatim_spec.rb
|
@@ -127,6 +131,7 @@ specification_version: 4
|
|
127
131
|
summary: Hemingway is a LaTeX to HTML parser.
|
128
132
|
test_files:
|
129
133
|
- spec/build_spec.rb
|
134
|
+
- spec/nodes/block/center_spec.rb
|
130
135
|
- spec/nodes/block/list_spec.rb
|
131
136
|
- spec/nodes/block/quote_spec.rb
|
132
137
|
- spec/nodes/block/verbatim_spec.rb
|