rp 0.1.2 → 0.1.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.
- data/README.md +108 -36
- data/lib/rp.rb +8 -3
- data/lib/rp/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
|
@@ -18,52 +18,124 @@ Or install it yourself as:
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
```
|
|
21
|
+
```haml
|
|
22
22
|
html!
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
head
|
|
24
|
+
script type: "text/javascript", src: "http://slkdfksja.js"
|
|
25
|
+
body
|
|
26
|
+
div#content data_para: "hello world"
|
|
27
|
+
p.first "first p"
|
|
28
|
+
p.second-p#special-p
|
|
29
|
+
"special p"
|
|
30
|
+
-- a = "username"
|
|
31
|
+
p
|
|
32
|
+
-- b = "<b>---------------x--------------</b>"
|
|
33
|
+
== b
|
|
34
|
+
-- a.split("").each do |x|
|
|
35
|
+
font x
|
|
36
|
+
-- end
|
|
37
|
+
p
|
|
38
|
+
"helloworld"
|
|
39
|
+
div.comments.hahaha
|
|
40
|
+
p.a-comment#no-comment "no comments yet!"
|
|
33
41
|
```
|
|
34
42
|
|
|
35
|
-
|
|
43
|
+
**FIRST, converted to ruby code**
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
html! do
|
|
47
|
+
head do
|
|
48
|
+
script type: "text/javascript", src: "http://slkdfksja.js"
|
|
49
|
+
end
|
|
50
|
+
body do
|
|
51
|
+
@id = 'content'
|
|
52
|
+
div data_para: "hello world" do
|
|
53
|
+
@cls = 'first'
|
|
54
|
+
p "first p"
|
|
55
|
+
@cls = 'second-p'
|
|
56
|
+
@id = 'special-p'
|
|
57
|
+
p do
|
|
58
|
+
"special p"
|
|
59
|
+
end
|
|
60
|
+
a = "username"
|
|
61
|
+
p do
|
|
62
|
+
b = "<b>---------------x--------------</b>"
|
|
63
|
+
self.== b
|
|
64
|
+
a.split("").each do |x|
|
|
65
|
+
font x
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
p do
|
|
69
|
+
"helloworld"
|
|
70
|
+
end
|
|
71
|
+
@cls = 'comments hahaha'
|
|
72
|
+
div do
|
|
73
|
+
@cls = 'a-comment'
|
|
74
|
+
@id = 'no-comment'
|
|
75
|
+
p "no comments yet!"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**OUTPUT html**
|
|
36
83
|
|
|
37
84
|
```html
|
|
38
85
|
<html>
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
86
|
+
<head>
|
|
87
|
+
<script type='text/javascript' src='http://slkdfksja.js'>
|
|
88
|
+
</script>
|
|
89
|
+
</head>
|
|
90
|
+
<body>
|
|
91
|
+
<div data-para='hello world' id='content'>
|
|
92
|
+
<p class='first'>
|
|
93
|
+
first p
|
|
94
|
+
</p>
|
|
95
|
+
<p class='second-p' id='special-p'>
|
|
96
|
+
special p
|
|
97
|
+
</p>
|
|
98
|
+
<p>
|
|
99
|
+
<b>---------------x--------------</b>
|
|
100
|
+
<font>
|
|
101
|
+
u
|
|
102
|
+
</font>
|
|
103
|
+
<font>
|
|
104
|
+
s
|
|
105
|
+
</font>
|
|
106
|
+
<font>
|
|
107
|
+
e
|
|
108
|
+
</font>
|
|
109
|
+
<font>
|
|
110
|
+
r
|
|
111
|
+
</font>
|
|
112
|
+
<font>
|
|
113
|
+
n
|
|
114
|
+
</font>
|
|
115
|
+
<font>
|
|
116
|
+
a
|
|
117
|
+
</font>
|
|
118
|
+
<font>
|
|
119
|
+
m
|
|
120
|
+
</font>
|
|
121
|
+
<font>
|
|
122
|
+
e
|
|
123
|
+
</font>
|
|
124
|
+
</p>
|
|
125
|
+
<p>
|
|
126
|
+
helloworld
|
|
127
|
+
</p>
|
|
128
|
+
<div class='comments hahaha'>
|
|
129
|
+
<p class='a-comment' id='no-comment'>
|
|
130
|
+
no comments yet!
|
|
131
|
+
</p>
|
|
132
|
+
</div>
|
|
51
133
|
</div>
|
|
52
|
-
|
|
53
|
-
hell world again again again
|
|
54
|
-
</div>
|
|
55
|
-
<div>
|
|
56
|
-
hell world again again again again
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
<div class='nothing'>
|
|
60
|
-
</div>
|
|
61
|
-
<p>
|
|
62
|
-
done
|
|
63
|
-
</p>
|
|
134
|
+
</body>
|
|
64
135
|
</html>
|
|
65
136
|
```
|
|
66
137
|
|
|
138
|
+
|
|
67
139
|
## Contributing
|
|
68
140
|
|
|
69
141
|
1. Fork it
|
data/lib/rp.rb
CHANGED
|
@@ -7,7 +7,8 @@ module Rp
|
|
|
7
7
|
|
|
8
8
|
INDENT_SIZE = 2
|
|
9
9
|
INDENT = " " * INDENT_SIZE
|
|
10
|
-
CODE_MARK = "
|
|
10
|
+
CODE_MARK = "--"
|
|
11
|
+
CODE_MARK_SIZE = CODE_MARK.size
|
|
11
12
|
|
|
12
13
|
def indent(line)
|
|
13
14
|
(line.size - line.lstrip.size)/INDENT_SIZE
|
|
@@ -68,19 +69,23 @@ module Rp
|
|
|
68
69
|
def parse(lines)
|
|
69
70
|
@doc = ""
|
|
70
71
|
@indent = 0
|
|
72
|
+
|
|
71
73
|
lines.each do |l|
|
|
72
74
|
i = indent l
|
|
73
75
|
l.strip!
|
|
74
76
|
next if l.empty?
|
|
75
77
|
|
|
76
|
-
if l[0
|
|
77
|
-
l
|
|
78
|
+
if l[0...CODE_MARK_SIZE] == CODE_MARK
|
|
79
|
+
l = INDENT*i << l[CODE_MARK_SIZE..-1].lstrip
|
|
80
|
+
elsif l[0..1] == "=="
|
|
81
|
+
l = INDENT*i << "self." << l
|
|
78
82
|
else
|
|
79
83
|
l = class_and_id l, i
|
|
80
84
|
end
|
|
81
85
|
|
|
82
86
|
indent_line l,i
|
|
83
87
|
end
|
|
88
|
+
|
|
84
89
|
ends(@indent-1, @indent)
|
|
85
90
|
@doc
|
|
86
91
|
end
|
data/lib/rp/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-07-
|
|
12
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|