pseudohikiparser 0.0.0.9.develop → 0.0.0.10.develop
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 +14 -1
- data/lib/pseudohiki/blockparser.rb +18 -7
- data/lib/pseudohiki/htmlformat.rb +5 -1
- data/lib/pseudohiki/htmlplugin.rb +1 -1
- data/lib/pseudohiki/version.rb +1 -1
- data/test/test_blockparser.rb +15 -0
- data/test/test_htmlformat.rb +31 -0
- data/test/test_htmlplugin.rb +12 -0
- metadata +36 -28
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -49,6 +49,7 @@ pseudohiki2html.rb <<TEXT
|
|
49
49
|
The first paragraph
|
50
50
|
TEXT
|
51
51
|
```
|
52
|
+
|
52
53
|
will return the following result to stdout:
|
53
54
|
|
54
55
|
```html
|
@@ -116,6 +117,7 @@ tree = PseudoHiki::BlockParser.parse(plain.lines.to_a)
|
|
116
117
|
html = PseudoHiki::HtmlFormat.format(tree)
|
117
118
|
puts html
|
118
119
|
```
|
120
|
+
|
119
121
|
you will get the following output:
|
120
122
|
|
121
123
|
```html
|
@@ -152,8 +154,11 @@ Other than PseudoHiki::HtmlFormat, you can choose PseudoHiki::XhtmlFormat, Pseud
|
|
152
154
|
* Plugins - Not supported (and will not be compatible with the original one)
|
153
155
|
|
154
156
|
## Additional Features
|
157
|
+
|
155
158
|
### Already Implemented
|
159
|
+
|
156
160
|
#### Assigning ids
|
161
|
+
|
157
162
|
If you add [name_of_id], just after the marks that denote heading or list type items, it becomes the id attribute of resulting html elements. Below is an example.
|
158
163
|
|
159
164
|
```
|
@@ -176,7 +181,9 @@ will be rendered as
|
|
176
181
|
```
|
177
182
|
|
178
183
|
### Partly Implemented
|
184
|
+
|
179
185
|
#### A visitor that removes markups and returns plain texts
|
186
|
+
|
180
187
|
The visitor, [PlainTextFormat](https://github.com/nico-hn/PseudoHikiParser/blob/develop/lib/pseudohiki/plaintextformat.rb) is currently available only in the [develop branch](https://github.com/nico-hn/PseudoHikiParser/tree/develop). Below are examples
|
181
188
|
|
182
189
|
```
|
@@ -184,6 +191,7 @@ The visitor, [PlainTextFormat](https://github.com/nico-hn/PseudoHikiParser/blob/
|
|
184
191
|
::03-yyyy-yyyy
|
185
192
|
:fax:03-xxxx-xxxx
|
186
193
|
```
|
194
|
+
|
187
195
|
will be rendered as
|
188
196
|
|
189
197
|
```
|
@@ -200,6 +208,7 @@ And
|
|
200
208
|
||cell 3-1||cell 3-4||cell 3-5
|
201
209
|
||cell 4-1||cell 4-2||cell 4-3||cell 4-4||cell 4-5
|
202
210
|
```
|
211
|
+
|
203
212
|
will be rendered as
|
204
213
|
|
205
214
|
```
|
@@ -208,8 +217,10 @@ cell 2-1 cell 2-2,3 3-2,3 == cell 2-4 cell 2-5
|
|
208
217
|
cell 3-1 || || cell 3-4 cell 3-5
|
209
218
|
cell 4-1 cell 4-2 cell 4-3 cell 4-4 cell 4-5
|
210
219
|
```
|
220
|
+
|
211
221
|
#### A visitor for HTML5
|
212
|
-
|
222
|
+
|
223
|
+
The visitor, [Xhtml5Format](https://github.com/nico-hn/PseudoHikiParser/blob/develop/lib/pseudohiki/htmlformat.rb#L239) is currently available only in the [develop branch](https://github.com/nico-hn/PseudoHikiParser/tree/develop).
|
213
224
|
|
214
225
|
#### A visitor for (Git Flavored) Markdown
|
215
226
|
|
@@ -282,4 +293,6 @@ For example, '' or == can be escaped.
|
|
282
293
|
And {{ and }} sould be rendered as two left curly braces and two right curly braces respectively.
|
283
294
|
```
|
284
295
|
|
296
|
+
|
285
297
|
### Not Implemented Yet
|
298
|
+
|
@@ -166,14 +166,16 @@ module PseudoHiki
|
|
166
166
|
end
|
167
167
|
|
168
168
|
def add_leaf(line, blockparser)
|
169
|
-
|
170
|
-
return blockparser.stack.push BlockElement::VerbatimNode.new.tap {|node| node.in_block_tag = true }
|
171
|
-
end
|
172
|
-
line = tagfy_link(line) unless BlockElement::VerbatimLeaf.head_re =~ line
|
173
|
-
leaf = blockparser.select_leaf_type(line).create(line)
|
169
|
+
leaf = create_leaf(line, blockparser)
|
174
170
|
blockparser.stack.pop while blockparser.breakable?(leaf)
|
175
171
|
blockparser.stack.push leaf
|
176
172
|
end
|
173
|
+
|
174
|
+
def create_leaf(line, blockparser)
|
175
|
+
return BlockElement::VerbatimLeaf.create("", true) if LINE_PAT::VERBATIM_BEGIN =~ line
|
176
|
+
line = tagfy_link(line) unless BlockElement::VerbatimLeaf.head_re =~ line
|
177
|
+
blockparser.select_leaf_type(line).create(line)
|
178
|
+
end
|
177
179
|
end
|
178
180
|
|
179
181
|
class NonNestedBlockNode < BlockNode
|
@@ -218,7 +220,7 @@ module PseudoHiki
|
|
218
220
|
end
|
219
221
|
|
220
222
|
class BlockElement::VerbatimNode
|
221
|
-
|
223
|
+
attr_accessor :in_block_tag
|
222
224
|
|
223
225
|
def add_leaf(line, blockparser)
|
224
226
|
return @stack.pop if LINE_PAT::VERBATIM_END =~ line
|
@@ -241,9 +243,18 @@ module PseudoHiki
|
|
241
243
|
end
|
242
244
|
|
243
245
|
class BlockElement::VerbatimLeaf
|
246
|
+
attr_accessor :in_block_tag
|
247
|
+
|
244
248
|
def self.create(line, in_block_tag=nil)
|
245
249
|
line.sub!(self.head_re, "") if self.head_re and not in_block_tag
|
246
|
-
self.new.tap
|
250
|
+
self.new.tap do |leaf|
|
251
|
+
leaf.push line
|
252
|
+
leaf.in_block_tag = in_block_tag
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def push_block(stack)
|
257
|
+
stack.push(block.new.tap {|n| n.in_block_tag = @in_block_tag })
|
247
258
|
end
|
248
259
|
end
|
249
260
|
|
@@ -116,10 +116,14 @@ module PseudoHiki
|
|
116
116
|
|
117
117
|
class << Formatter[PluginNode]
|
118
118
|
def visit(tree)
|
119
|
+
escape_inline_tags(tree) { super(tree) }
|
120
|
+
end
|
121
|
+
|
122
|
+
def escape_inline_tags(tree)
|
119
123
|
str = tree.join
|
120
124
|
return str if InlineParser::HEAD[str] or InlineParser::TAIL[str]
|
121
125
|
return str.strip * 2 if str == ' {' or str == '} '
|
122
|
-
|
126
|
+
yield
|
123
127
|
end
|
124
128
|
end
|
125
129
|
|
data/lib/pseudohiki/version.rb
CHANGED
data/test/test_blockparser.rb
CHANGED
@@ -310,4 +310,19 @@ TEXT
|
|
310
310
|
parsed = PseudoHiki::BlockParser.parse(text2.split(/\r?\n/o))
|
311
311
|
assert_equal([[[["heading"]]]],parsed)
|
312
312
|
end
|
313
|
+
|
314
|
+
def test_comment_out_followed_by_a_verbatim_block
|
315
|
+
text = <<TEXT
|
316
|
+
the first paragraph
|
317
|
+
|
318
|
+
//a comment
|
319
|
+
<<<
|
320
|
+
the first verbatim line
|
321
|
+
the second verbatim line
|
322
|
+
>>>
|
323
|
+
TEXT
|
324
|
+
|
325
|
+
parsed = PseudoHiki::BlockParser.parse(text.split(/\r?\n/o))
|
326
|
+
assert_equal([[[["the first paragraph"]]], [[["a comment"]]], [[""], ["the first verbatim line"], ["the second verbatim line"]]],parsed)
|
327
|
+
end
|
313
328
|
end
|
data/test/test_htmlformat.rb
CHANGED
@@ -667,4 +667,35 @@ HTML
|
|
667
667
|
tree = BlockParser.parse(text.lines.to_a)
|
668
668
|
assert_equal(xhtml, XhtmlFormat.format(tree).to_s)
|
669
669
|
end
|
670
|
+
|
671
|
+
def test_comment_out_followed_by_a_verbatim_block
|
672
|
+
text = <<TEXT
|
673
|
+
the first paragraph
|
674
|
+
|
675
|
+
//a comment
|
676
|
+
the second paragraph
|
677
|
+
|
678
|
+
//a comment
|
679
|
+
<<<
|
680
|
+
the first verbatim line
|
681
|
+
the second verbatim line
|
682
|
+
>>>
|
683
|
+
TEXT
|
684
|
+
|
685
|
+
xhtml = <<HTML
|
686
|
+
<p>
|
687
|
+
the first paragraph
|
688
|
+
</p>
|
689
|
+
<p>
|
690
|
+
the second paragraph
|
691
|
+
</p>
|
692
|
+
<pre>
|
693
|
+
the first verbatim line
|
694
|
+
the second verbatim line
|
695
|
+
</pre>
|
696
|
+
HTML
|
697
|
+
|
698
|
+
tree = BlockParser.parse(text.lines.to_a)
|
699
|
+
assert_equal(xhtml, XhtmlFormat.format(tree).to_s)
|
700
|
+
end
|
670
701
|
end
|
data/test/test_htmlplugin.rb
CHANGED
@@ -11,4 +11,16 @@ class TC_HtmlPlugin < MiniTest::Unit::TestCase
|
|
11
11
|
tree = InlineParser.new("{{co2}} represents the carbon dioxide.").parse.tree
|
12
12
|
assert_equal("CO<sub>2</sub> represents the carbon dioxide.",tree.accept(formatter).to_s)
|
13
13
|
end
|
14
|
+
|
15
|
+
def test_escape_inline_tags
|
16
|
+
formatter = HtmlFormat.get_plain
|
17
|
+
tree = InlineParser.new("a line with an inline tag such as {{''}}").parse.tree
|
18
|
+
assert_equal("a line with an inline tag such as ''",tree.accept(formatter).to_s)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_html_plugin
|
22
|
+
formatter = HtmlFormat.get_plain
|
23
|
+
tree = InlineParser.new("you can directly embed a snippet of html code like '{{html(<i>italic</i>)}}'.").parse.tree
|
24
|
+
assert_equal("you can directly embed a snippet of html code like '<i>italic</i>'.",tree.accept(formatter).to_s)
|
25
|
+
end
|
14
26
|
end
|
metadata
CHANGED
@@ -1,55 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pseudohikiparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.
|
4
|
+
version: 0.0.0.10.develop
|
5
|
+
prerelease: 9
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- HASHIMOTO, Naoki
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-23 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '1.3'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.3'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: minitest
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
description: PseudoHikiParser is a parser of texts written in a Hiki like notation,
|
@@ -61,53 +68,54 @@ executables:
|
|
61
68
|
extensions: []
|
62
69
|
extra_rdoc_files: []
|
63
70
|
files:
|
64
|
-
- LICENSE
|
65
71
|
- README.md
|
66
|
-
-
|
67
|
-
- lib/
|
68
|
-
- lib/
|
72
|
+
- LICENSE
|
73
|
+
- lib/pseudohikiparser.rb
|
74
|
+
- lib/pseudohiki/treestack.rb
|
75
|
+
- lib/pseudohiki/inlineparser.rb
|
69
76
|
- lib/pseudohiki/blockparser.rb
|
70
77
|
- lib/pseudohiki/htmlformat.rb
|
71
|
-
- lib/pseudohiki/htmlplugin.rb
|
72
|
-
- lib/pseudohiki/inlineparser.rb
|
73
|
-
- lib/pseudohiki/markdownformat.rb
|
74
78
|
- lib/pseudohiki/plaintextformat.rb
|
75
|
-
- lib/pseudohiki/
|
79
|
+
- lib/pseudohiki/markdownformat.rb
|
76
80
|
- lib/pseudohiki/version.rb
|
77
|
-
- lib/
|
81
|
+
- lib/pseudohiki/htmlplugin.rb
|
82
|
+
- lib/htmlelement.rb
|
83
|
+
- lib/htmlelement/htmltemplate.rb
|
84
|
+
- test/test_htmltemplate.rb
|
78
85
|
- test/test_blockparser.rb
|
86
|
+
- test/test_plaintextformat.rb
|
79
87
|
- test/test_htmlelement.rb
|
80
|
-
- test/
|
81
|
-
- test/test_htmlplugin.rb
|
82
|
-
- test/test_htmltemplate.rb
|
88
|
+
- test/test_treestack.rb
|
83
89
|
- test/test_inlineparser.rb
|
84
90
|
- test/test_markdownformat.rb
|
85
|
-
- test/
|
86
|
-
- test/
|
91
|
+
- test/test_htmlformat.rb
|
92
|
+
- test/test_htmlplugin.rb
|
93
|
+
- bin/pseudohiki2html.rb
|
87
94
|
homepage: https://github.com/nico-hn/PseudoHikiParser/wiki
|
88
95
|
licenses:
|
89
96
|
- BSD 2-Clause license
|
90
|
-
metadata: {}
|
91
97
|
post_install_message:
|
92
98
|
rdoc_options: []
|
93
99
|
require_paths:
|
94
100
|
- lib
|
95
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
96
103
|
requirements:
|
97
|
-
- -
|
104
|
+
- - ! '>='
|
98
105
|
- !ruby/object:Gem::Version
|
99
106
|
version: 1.8.7
|
100
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
101
109
|
requirements:
|
102
|
-
- -
|
110
|
+
- - ! '>'
|
103
111
|
- !ruby/object:Gem::Version
|
104
112
|
version: 1.3.1
|
105
113
|
requirements: []
|
106
114
|
rubyforge_project:
|
107
|
-
rubygems_version:
|
115
|
+
rubygems_version: 1.8.23
|
108
116
|
signing_key:
|
109
|
-
specification_version:
|
110
|
-
summary: 'PseudoHikiParser: a parser of texts in a Hiki like notation.'
|
117
|
+
specification_version: 3
|
118
|
+
summary: ! 'PseudoHikiParser: a parser of texts in a Hiki like notation.'
|
111
119
|
test_files:
|
112
120
|
- test/test_htmltemplate.rb
|
113
121
|
- test/test_blockparser.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 8c837bd7cafbfe2ca4d3356d41d419f058f80bdb
|
4
|
-
data.tar.gz: 6db584032f8226011930cc326d6b4c792df73fa8
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 153e09b4d391c0d2c74262b9ccd2c41285686415e435c8e3bae1c4d3aacfc18916462c6f53543f81b9ce773fd985e0cb7154abfd6b759930b83cd5e6d4ae172a
|
7
|
-
data.tar.gz: 82c96e88ad295a05092d6f06ad68f6c17919aeacae58d247e6ee4d6feb9913d3575d569ed47401f90ce68ee6e1c784c6a46af11cfcebb35c2fdd28a7520db71b
|