hamdown_core 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +513 -0
- data/.rspec +2 -0
- data/.rubocop.yml +59 -0
- data/.rubocop_todo.yml +261 -0
- data/.ruby-version +1 -0
- data/.travis.yml +0 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +109 -0
- data/LICENSE.txt +22 -0
- data/README.md +64 -0
- data/Rakefile +28 -0
- data/bin/console +15 -0
- data/bin/hamdown_compiler +13 -0
- data/bin/hamdown_parser +10 -0
- data/bin/hamdown_transformer +12 -0
- data/bin/setup +7 -0
- data/exe/hamdown_core +7 -0
- data/hamdown_core.gemspec +33 -0
- data/input.hd +30 -0
- data/lib/hamdown_core/ast.rb +179 -0
- data/lib/hamdown_core/cli.rb +23 -0
- data/lib/hamdown_core/compiler.rb +95 -0
- data/lib/hamdown_core/element_parser.rb +243 -0
- data/lib/hamdown_core/engine.rb +14 -0
- data/lib/hamdown_core/error.rb +11 -0
- data/lib/hamdown_core/filter_parser.rb +57 -0
- data/lib/hamdown_core/indent_tracker.rb +117 -0
- data/lib/hamdown_core/line_parser.rb +68 -0
- data/lib/hamdown_core/parser.rb +298 -0
- data/lib/hamdown_core/ruby_multiline.rb +24 -0
- data/lib/hamdown_core/script_parser.rb +106 -0
- data/lib/hamdown_core/transformer.rb +52 -0
- data/lib/hamdown_core/utils.rb +18 -0
- data/lib/hamdown_core/version.rb +4 -0
- data/lib/hamdown_core.rb +8 -0
- metadata +222 -0
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,261 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-03-09 17:41:12 +0300 using RuboCop version 0.63.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Include.
|
11
|
+
# Include: **/*.gemspec
|
12
|
+
Gemspec/RequiredRubyVersion:
|
13
|
+
Exclude:
|
14
|
+
- 'hamdown_core.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 5
|
17
|
+
# Cop supports --auto-correct.
|
18
|
+
Layout/EmptyLineAfterGuardClause:
|
19
|
+
Exclude:
|
20
|
+
- 'lib/hamdown_core/element_parser.rb'
|
21
|
+
- 'lib/hamdown_core/indent_tracker.rb'
|
22
|
+
|
23
|
+
# Offense count: 31
|
24
|
+
# Cop supports --auto-correct.
|
25
|
+
Layout/EmptyLineAfterMagicComment:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
# Offense count: 38
|
29
|
+
# Cop supports --auto-correct.
|
30
|
+
# Configuration parameters: EnforcedStyle.
|
31
|
+
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
32
|
+
Layout/IndentHeredoc:
|
33
|
+
Exclude:
|
34
|
+
- 'spec/attribute_spec.rb'
|
35
|
+
- 'spec/comment_spec.rb'
|
36
|
+
- 'spec/doctype_spec.rb'
|
37
|
+
- 'spec/element_spec.rb'
|
38
|
+
- 'spec/filter_spec.rb'
|
39
|
+
- 'spec/haml_comment_spec.rb'
|
40
|
+
- 'spec/html_style_attribute_spec.rb'
|
41
|
+
- 'spec/indent_spec.rb'
|
42
|
+
- 'spec/multiline_spec.rb'
|
43
|
+
- 'spec/plain_spec.rb'
|
44
|
+
- 'spec/script_spec.rb'
|
45
|
+
- 'spec/silent_script_spec.rb'
|
46
|
+
- 'spec/whitespace_spec.rb'
|
47
|
+
|
48
|
+
# Offense count: 1
|
49
|
+
# Cop supports --auto-correct.
|
50
|
+
Layout/SpaceAfterComma:
|
51
|
+
Exclude:
|
52
|
+
- 'lib/hamdown_compiler.rb'
|
53
|
+
|
54
|
+
# Offense count: 1
|
55
|
+
# Cop supports --auto-correct.
|
56
|
+
# Configuration parameters: EnforcedStyle.
|
57
|
+
# SupportedStyles: final_newline, final_blank_line
|
58
|
+
Layout/TrailingBlankLines:
|
59
|
+
Exclude:
|
60
|
+
- 'lib/hamdown_compiler.rb'
|
61
|
+
|
62
|
+
# Offense count: 11
|
63
|
+
Lint/InterpolationCheck:
|
64
|
+
Exclude:
|
65
|
+
- 'spec/attribute_spec.rb'
|
66
|
+
- 'spec/element_spec.rb'
|
67
|
+
- 'spec/html_style_attribute_spec.rb'
|
68
|
+
- 'spec/script_spec.rb'
|
69
|
+
|
70
|
+
# Offense count: 1
|
71
|
+
# Cop supports --auto-correct.
|
72
|
+
Lint/ScriptPermission:
|
73
|
+
Exclude:
|
74
|
+
- 'benchmark/parse.rb'
|
75
|
+
|
76
|
+
# Offense count: 2
|
77
|
+
Lint/ShadowingOuterLocalVariable:
|
78
|
+
Exclude:
|
79
|
+
- 'lib/hamdown_compiler.rb'
|
80
|
+
|
81
|
+
# Offense count: 1
|
82
|
+
Lint/UselessAssignment:
|
83
|
+
Exclude:
|
84
|
+
- 'lib/hamdown_compiler.rb'
|
85
|
+
|
86
|
+
# Offense count: 13
|
87
|
+
Metrics/AbcSize:
|
88
|
+
Max: 80
|
89
|
+
|
90
|
+
# Offense count: 20
|
91
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
92
|
+
# ExcludedMethods: refine
|
93
|
+
Metrics/BlockLength:
|
94
|
+
Max: 171
|
95
|
+
|
96
|
+
# Offense count: 2
|
97
|
+
# Configuration parameters: CountComments.
|
98
|
+
Metrics/ClassLength:
|
99
|
+
Max: 247
|
100
|
+
|
101
|
+
# Offense count: 7
|
102
|
+
Metrics/CyclomaticComplexity:
|
103
|
+
Max: 17
|
104
|
+
|
105
|
+
# Offense count: 21
|
106
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
107
|
+
Metrics/MethodLength:
|
108
|
+
Max: 67
|
109
|
+
|
110
|
+
# Offense count: 1
|
111
|
+
# Configuration parameters: CountComments.
|
112
|
+
Metrics/ModuleLength:
|
113
|
+
Max: 129
|
114
|
+
|
115
|
+
# Offense count: 3
|
116
|
+
Metrics/PerceivedComplexity:
|
117
|
+
Max: 13
|
118
|
+
|
119
|
+
# Offense count: 3
|
120
|
+
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
|
121
|
+
# NamePrefix: is_, has_, have_
|
122
|
+
# NamePrefixBlacklist: is_, has_, have_
|
123
|
+
# NameWhitelist: is_a?
|
124
|
+
# MethodDefinitionMacros: define_method, define_singleton_method
|
125
|
+
Naming/PredicateName:
|
126
|
+
Exclude:
|
127
|
+
- 'spec/**/*'
|
128
|
+
- 'lib/hamdown_core/line_parser.rb'
|
129
|
+
- 'lib/hamdown_core/ruby_multiline.rb'
|
130
|
+
|
131
|
+
# Offense count: 1
|
132
|
+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
133
|
+
# AllowedNames: io, id, to, by, on, in, at, ip, db
|
134
|
+
Naming/UncommunicativeMethodParamName:
|
135
|
+
Exclude:
|
136
|
+
- 'lib/hamdown_core/parser.rb'
|
137
|
+
|
138
|
+
# Offense count: 3
|
139
|
+
# Cop supports --auto-correct.
|
140
|
+
Performance/StringReplacement:
|
141
|
+
Exclude:
|
142
|
+
- 'lib/hamdown_compiler.rb'
|
143
|
+
|
144
|
+
# Offense count: 3
|
145
|
+
# Cop supports --auto-correct.
|
146
|
+
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
147
|
+
# SupportedStyles: assign_to_condition, assign_inside_condition
|
148
|
+
Style/ConditionalAssignment:
|
149
|
+
Exclude:
|
150
|
+
- 'lib/hamdown_compiler.rb'
|
151
|
+
- 'lib/hamdown_core/parser.rb'
|
152
|
+
|
153
|
+
# Offense count: 17
|
154
|
+
Style/Documentation:
|
155
|
+
Exclude:
|
156
|
+
- 'spec/**/*'
|
157
|
+
- 'test/**/*'
|
158
|
+
- 'lib/hamdown_compiler.rb'
|
159
|
+
- 'lib/hamdown_core.rb'
|
160
|
+
- 'lib/hamdown_core/ast.rb'
|
161
|
+
- 'lib/hamdown_core/cli.rb'
|
162
|
+
- 'lib/hamdown_core/element_parser.rb'
|
163
|
+
- 'lib/hamdown_core/error.rb'
|
164
|
+
- 'lib/hamdown_core/filter_parser.rb'
|
165
|
+
- 'lib/hamdown_core/indent_tracker.rb'
|
166
|
+
- 'lib/hamdown_core/line_parser.rb'
|
167
|
+
- 'lib/hamdown_core/parser.rb'
|
168
|
+
- 'lib/hamdown_core/ruby_multiline.rb'
|
169
|
+
- 'lib/hamdown_core/script_parser.rb'
|
170
|
+
- 'lib/hamdown_core/utils.rb'
|
171
|
+
- 'lib/hamdown_transformer.rb'
|
172
|
+
|
173
|
+
# Offense count: 1
|
174
|
+
# Cop supports --auto-correct.
|
175
|
+
Style/Encoding:
|
176
|
+
Exclude:
|
177
|
+
- 'hamdown_core.gemspec'
|
178
|
+
|
179
|
+
# Offense count: 1
|
180
|
+
# Cop supports --auto-correct.
|
181
|
+
Style/ExpandPathArguments:
|
182
|
+
Exclude:
|
183
|
+
- 'hamdown_core.gemspec'
|
184
|
+
|
185
|
+
# Offense count: 6
|
186
|
+
# Cop supports --auto-correct.
|
187
|
+
Style/MutableConstant:
|
188
|
+
Exclude:
|
189
|
+
- 'lib/hamdown_core/element_parser.rb'
|
190
|
+
- 'lib/hamdown_core/line_parser.rb'
|
191
|
+
- 'lib/hamdown_core/parser.rb'
|
192
|
+
|
193
|
+
# Offense count: 3
|
194
|
+
# Cop supports --auto-correct.
|
195
|
+
# Configuration parameters: EnforcedStyle.
|
196
|
+
# SupportedStyles: both, prefix, postfix
|
197
|
+
Style/NegatedIf:
|
198
|
+
Exclude:
|
199
|
+
- 'lib/hamdown_compiler.rb'
|
200
|
+
|
201
|
+
# Offense count: 11
|
202
|
+
# Cop supports --auto-correct.
|
203
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
204
|
+
# SupportedStyles: predicate, comparison
|
205
|
+
Style/NumericPredicate:
|
206
|
+
Exclude:
|
207
|
+
- 'spec/**/*'
|
208
|
+
- 'lib/hamdown_compiler.rb'
|
209
|
+
- 'lib/hamdown_core/element_parser.rb'
|
210
|
+
- 'lib/hamdown_core/parser.rb'
|
211
|
+
- 'lib/hamdown_core/utils.rb'
|
212
|
+
- 'lib/hamdown_transformer.rb'
|
213
|
+
|
214
|
+
# Offense count: 2
|
215
|
+
# Cop supports --auto-correct.
|
216
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist.
|
217
|
+
# Whitelist: present?, blank?, presence, try, try!
|
218
|
+
Style/SafeNavigation:
|
219
|
+
Exclude:
|
220
|
+
- 'lib/hamdown_core/ast.rb'
|
221
|
+
- 'lib/hamdown_core/script_parser.rb'
|
222
|
+
|
223
|
+
# Offense count: 2
|
224
|
+
# Cop supports --auto-correct.
|
225
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
226
|
+
# SupportedStyles: single_quotes, double_quotes
|
227
|
+
Style/StringLiterals:
|
228
|
+
Exclude:
|
229
|
+
- 'lib/hamdown_compiler.rb'
|
230
|
+
|
231
|
+
# Offense count: 1
|
232
|
+
# Cop supports --auto-correct.
|
233
|
+
# Configuration parameters: MinSize.
|
234
|
+
# SupportedStyles: percent, brackets
|
235
|
+
Style/SymbolArray:
|
236
|
+
EnforcedStyle: brackets
|
237
|
+
|
238
|
+
# Offense count: 1
|
239
|
+
# Cop supports --auto-correct.
|
240
|
+
Style/UnneededInterpolation:
|
241
|
+
Exclude:
|
242
|
+
- 'lib/hamdown_compiler.rb'
|
243
|
+
|
244
|
+
# Offense count: 1
|
245
|
+
# Cop supports --auto-correct.
|
246
|
+
Style/WhileUntilModifier:
|
247
|
+
Exclude:
|
248
|
+
- 'lib/hamdown_core/parser.rb'
|
249
|
+
|
250
|
+
# Offense count: 6
|
251
|
+
# Cop supports --auto-correct.
|
252
|
+
Style/ZeroLengthPredicate:
|
253
|
+
Exclude:
|
254
|
+
- 'lib/hamdown_compiler.rb'
|
255
|
+
- 'lib/hamdown_transformer.rb'
|
256
|
+
|
257
|
+
# Offense count: 31
|
258
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
259
|
+
# URISchemes: http, https
|
260
|
+
Metrics/LineLength:
|
261
|
+
Max: 168
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.5.0
|
data/.travis.yml
ADDED
File without changes
|
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hamdown_core (0.5.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
backport (0.3.0)
|
11
|
+
benchmark-ips (2.7.2)
|
12
|
+
coderay (1.1.2)
|
13
|
+
coveralls (0.8.22)
|
14
|
+
json (>= 1.8, < 3)
|
15
|
+
simplecov (~> 0.16.1)
|
16
|
+
term-ansicolor (~> 1.3)
|
17
|
+
thor (~> 0.19.4)
|
18
|
+
tins (~> 1.6)
|
19
|
+
diff-lcs (1.3)
|
20
|
+
docile (1.3.1)
|
21
|
+
haml (5.0.4)
|
22
|
+
temple (>= 0.8.0)
|
23
|
+
tilt
|
24
|
+
htmlentities (4.3.4)
|
25
|
+
jaro_winkler (1.5.2)
|
26
|
+
json (2.2.0)
|
27
|
+
kramdown (1.17.0)
|
28
|
+
method_source (0.9.2)
|
29
|
+
mini_portile2 (2.4.0)
|
30
|
+
nokogiri (1.10.1)
|
31
|
+
mini_portile2 (~> 2.4.0)
|
32
|
+
parallel (1.14.0)
|
33
|
+
parser (2.6.0.0)
|
34
|
+
ast (~> 2.4.0)
|
35
|
+
powerpack (0.1.2)
|
36
|
+
pry (0.12.2)
|
37
|
+
coderay (~> 1.1.0)
|
38
|
+
method_source (~> 0.9.0)
|
39
|
+
psych (3.1.0)
|
40
|
+
rainbow (3.0.0)
|
41
|
+
rake (12.3.2)
|
42
|
+
reverse_markdown (1.1.0)
|
43
|
+
nokogiri
|
44
|
+
rspec (3.8.0)
|
45
|
+
rspec-core (~> 3.8.0)
|
46
|
+
rspec-expectations (~> 3.8.0)
|
47
|
+
rspec-mocks (~> 3.8.0)
|
48
|
+
rspec-core (3.8.0)
|
49
|
+
rspec-support (~> 3.8.0)
|
50
|
+
rspec-expectations (3.8.2)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.8.0)
|
53
|
+
rspec-mocks (3.8.0)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.8.0)
|
56
|
+
rspec-support (3.8.0)
|
57
|
+
rubocop (0.65.0)
|
58
|
+
jaro_winkler (~> 1.5.1)
|
59
|
+
parallel (~> 1.10)
|
60
|
+
parser (>= 2.5, != 2.5.1.1)
|
61
|
+
powerpack (~> 0.1)
|
62
|
+
psych (>= 3.1.0)
|
63
|
+
rainbow (>= 2.2.2, < 4.0)
|
64
|
+
ruby-progressbar (~> 1.7)
|
65
|
+
unicode-display_width (~> 1.4.0)
|
66
|
+
ruby-progressbar (1.10.0)
|
67
|
+
simplecov (0.16.1)
|
68
|
+
docile (~> 1.1)
|
69
|
+
json (>= 1.8, < 3)
|
70
|
+
simplecov-html (~> 0.10.0)
|
71
|
+
simplecov-html (0.10.2)
|
72
|
+
solargraph (0.31.3)
|
73
|
+
backport (~> 0.3)
|
74
|
+
htmlentities (~> 4.3, >= 4.3.4)
|
75
|
+
jaro_winkler (~> 1.5)
|
76
|
+
kramdown (~> 1.16)
|
77
|
+
parser (~> 2.3)
|
78
|
+
reverse_markdown (~> 1.0, >= 1.0.5)
|
79
|
+
rubocop (~> 0.52)
|
80
|
+
thor (~> 0.19, >= 0.19.4)
|
81
|
+
tilt (~> 2.0)
|
82
|
+
yard (~> 0.9)
|
83
|
+
temple (0.8.1)
|
84
|
+
term-ansicolor (1.7.1)
|
85
|
+
tins (~> 1.0)
|
86
|
+
thor (0.19.4)
|
87
|
+
tilt (2.0.9)
|
88
|
+
tins (1.20.2)
|
89
|
+
unicode-display_width (1.4.1)
|
90
|
+
yard (0.9.18)
|
91
|
+
|
92
|
+
PLATFORMS
|
93
|
+
ruby
|
94
|
+
|
95
|
+
DEPENDENCIES
|
96
|
+
benchmark-ips
|
97
|
+
bundler
|
98
|
+
coveralls
|
99
|
+
hamdown_core!
|
100
|
+
haml
|
101
|
+
pry
|
102
|
+
rake
|
103
|
+
rspec (>= 3.3.0)
|
104
|
+
rubocop
|
105
|
+
simplecov
|
106
|
+
solargraph
|
107
|
+
|
108
|
+
BUNDLED WITH
|
109
|
+
1.16.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Kohei Suzuki
|
4
|
+
Copyright (c) 2019 Kopylov Vladislav
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# HamdownCore
|
2
|
+
|
3
|
+
Core compiler Hamdown into Haml
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'hamdown_core'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install hamdown_core
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```bash
|
24
|
+
./exe/hamdown_core input.hd
|
25
|
+
```
|
26
|
+
|
27
|
+
## Debuging
|
28
|
+
|
29
|
+
parse
|
30
|
+
|
31
|
+
```bash
|
32
|
+
./exe/hamdown_parser input.hd
|
33
|
+
```
|
34
|
+
|
35
|
+
transformer
|
36
|
+
|
37
|
+
```bash
|
38
|
+
./exe/hamdown_transformer input.hd
|
39
|
+
```
|
40
|
+
|
41
|
+
compiler
|
42
|
+
|
43
|
+
```bash
|
44
|
+
./exe/hamdown_compiler input.hd
|
45
|
+
```
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
|
+
|
51
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kopylovvlad/hamdown_core.
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
60
|
+
|
61
|
+
## TODO
|
62
|
+
|
63
|
+
- Fix code by Rubocop
|
64
|
+
- To write tests
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
task :default => [:spec, :rubocop]
|
5
|
+
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
require 'rubocop/rake_task'
|
10
|
+
RuboCop::RakeTask.new(:rubocop)
|
11
|
+
|
12
|
+
desc 'Run all benchmarks'
|
13
|
+
task :benchmark => ['benchmark:sample', 'benchmark:haml']
|
14
|
+
|
15
|
+
namespace :benchmark do
|
16
|
+
desc "Run benchmark with hamdown_core's sample"
|
17
|
+
task :sample do
|
18
|
+
sample_haml_path = File.join(__dir__, 'spec', 'fixtures', 'sample.haml')
|
19
|
+
sh 'ruby', 'benchmark/parse.rb', sample_haml_path
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Run benchmark with haml's sample"
|
23
|
+
task :haml do
|
24
|
+
haml_gem = Gem::Specification.find_by_name('haml')
|
25
|
+
standard_haml_path = File.join(haml_gem.gem_dir, 'test', 'templates', 'standard.haml')
|
26
|
+
sh 'ruby', 'benchmark/parse.rb', standard_haml_path
|
27
|
+
end
|
28
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'hamdown_core'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative '../lib/hamdown_core/parser'
|
6
|
+
require_relative '../lib/hamdown_core/transformer'
|
7
|
+
require_relative '../lib/hamdown_core/compiler'
|
8
|
+
require 'pp'
|
9
|
+
|
10
|
+
parser = HamdownCore::Parser.new(filename: 'input.haml')
|
11
|
+
ast = parser.call(File.read('input.haml'))
|
12
|
+
transformed_ast = HamdownCore::Transformer.call(ast)
|
13
|
+
puts HamdownCore::Compiler.call(transformed_ast)
|
data/bin/hamdown_parser
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative '../lib/hamdown_core/parser'
|
6
|
+
require_relative '../lib/hamdown_core/transformer'
|
7
|
+
require 'pp'
|
8
|
+
|
9
|
+
parser = HamdownCore::Parser.new(filename: 'input.haml')
|
10
|
+
ast = parser.call(File.read('input.haml'))
|
11
|
+
transformed_ast = HamdownCore::Transformer.call(ast)
|
12
|
+
pp transformed_ast
|
data/bin/setup
ADDED
data/exe/hamdown_core
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require './lib/hamdown_core/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.specification_version = 2 if spec.respond_to? :specification_version=
|
6
|
+
spec.required_rubygems_version = Gem::Requirement.new(">= 0") if spec.respond_to? :required_rubygems_version=
|
7
|
+
spec.name = 'hamdown_core'
|
8
|
+
spec.version = HamdownCore::VERSION
|
9
|
+
spec.authors = ['Kohei Suzuki', 'Kopylov Vladislav']
|
10
|
+
spec.email = ['kopylov.vlad@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Parser of Hamlit template language'
|
13
|
+
spec.description = 'Parser of Hamlit template language'
|
14
|
+
spec.homepage = 'https://github.com/kopylovvlad/hamdown_core'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|benchmark)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
spec.required_ruby_version = '>= 2.0.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'benchmark-ips'
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'coveralls'
|
26
|
+
spec.add_development_dependency 'haml'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
spec.add_development_dependency 'rake'
|
29
|
+
spec.add_development_dependency 'rspec', '>= 3.3.0'
|
30
|
+
spec.add_development_dependency 'rubocop'
|
31
|
+
spec.add_development_dependency 'simplecov'
|
32
|
+
spec.add_development_dependency 'solargraph'
|
33
|
+
end
|
data/input.hd
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
%div.container
|
2
|
+
= "first"
|
3
|
+
# HamdownCore or hamdown_core
|
4
|
+
|
5
|
+
%div.container2
|
6
|
+
= "first.2"
|
7
|
+
# Helo sdf sdf
|
8
|
+
sdf sdf sdfs df %sd sdf %sdfsdfs
|
9
|
+
asd sdf sdf sdf sdfs dfsf
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
= "second"
|
14
|
+
<!--This means we can use HTML elements in Markdown, such as the comment
|
15
|
+
element, and they won't be affected by a markdown parser. However, if you
|
16
|
+
create an HTML element in your markdown file, you cannot use markdown syntax
|
17
|
+
within that element's contents.-->
|
18
|
+
|
19
|
+
= "third"
|
20
|
+
# This is an <h1>
|
21
|
+
|
22
|
+
## This is an <h2>
|
23
|
+
|
24
|
+
= 'and just test'
|
25
|
+
hello it is just text
|
26
|
+
|
27
|
+
text text text
|
28
|
+
text text
|
29
|
+
|
30
|
+
lololo
|