pseudohikiparser 0.0.0.7.develop → 0.0.0.8.develop

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac5860d6ae01c25224992ed3bdaeb09080446bab
4
- data.tar.gz: fce47183ada974d2416789045023fe0b31e9f4a0
3
+ metadata.gz: fa62b3cd074b8968534000434a99e4e4fb4c3e45
4
+ data.tar.gz: b3abcdf01e6251091283d33afd0ba5510046a1ec
5
5
  SHA512:
6
- metadata.gz: de7070b265af53ea7fbcfe1bb09bb5d0c0cc0256e41e7074b712ada33483d0f913fea346c0ae4f5aaf2d961fbfb778b652a385b4621a02934f90d272517f8332
7
- data.tar.gz: 897b062e0a00e9f3064d1237d1731dfba42934888997b0bbe4b0b08467000ef67dbb01e228c2c995cba5f90c48956050f88a188277093e93a67daf3c80cf6c9c
6
+ metadata.gz: 831925761d0de0186705d7f12b1cf24a87cc2688e7dd9c9ebab31723e235d825818c06021d440596f3cfeb4404fc271dfdab942c0cafc353498cb20e0bb24ef3
7
+ data.tar.gz: c059dd1b7498bef0d24b739f2b164b2b11aa4f9912be8c620f24296ed96b308ca9190a1f25dde75345ace899371c02f5a9ef1b528dc106d054c83191de9d0042
data/README.md CHANGED
@@ -199,11 +199,11 @@ cell 4-1 cell 4-2 cell 4-3 cell 4-4 cell 4-5
199
199
  #### A visitor for HTML5
200
200
  The visitor, [Xhtml5Format](https://github.com/nico-hn/PseudoHikiParser/blob/develop/lib/pseudohiki/htmlformat.rb#L222) is currently available only in the [develop branch](https://github.com/nico-hn/PseudoHikiParser/tree/develop).
201
201
 
202
- #### A vistor for (Git Flavored) Markdown
202
+ #### A visitor for (Git Flavored) Markdown
203
203
 
204
204
  The visitor, [MarkDownFormat](https://github.com/nico-hn/PseudoHikiParser/blob/develop/lib/pseudohiki/markdownformat.rb) too, is currently available only in the [develop branch](https://github.com/nico-hn/PseudoHikiParser/blob/develop/).
205
205
 
206
- It's just in experimental stage. For example, it cannot properly convert html elements appeared in hiki notation text yet.
206
+ It's just in experimental stage.
207
207
 
208
208
  The following are a sample script and its output:
209
209
 
@@ -114,7 +114,14 @@ module PseudoHiki
114
114
 
115
115
  class InlineLeafFormatter < self
116
116
  def visit(leaf)
117
- leaf.map {|str| str.gsub(/([_*])/o, "\\\\\\1") }
117
+ leaf.map do |str|
118
+ escaped_str = str.gsub(/([_*])/o, "\\\\\\1")
119
+ if @options.gfm_style
120
+ escaped_str.gsub(/([&<>])/o, "\\\\\\1")
121
+ else
122
+ HtmlElement.escape(escaped_str)
123
+ end
124
+ end
118
125
  end
119
126
  end
120
127
 
@@ -200,7 +207,9 @@ module PseudoHiki
200
207
  # class EnumLeafFormatter < self; end
201
208
  class DescNodeFormatter < self
202
209
  def visit(tree)
203
- desc_list = HtmlFormat.format(tree)
210
+ desc_list = HtmlElement.create("dl").tap do |element|
211
+ element.push HtmlFormat.format(tree)
212
+ end
204
213
  remove_trailing_newlines_in_html_element(desc_list)
205
214
  end
206
215
  end
@@ -1,3 +1,3 @@
1
1
  module PseudoHiki
2
- VERSION = "0.0.0.7.develop"
2
+ VERSION = "0.0.0.8.develop"
3
3
  end
@@ -68,10 +68,12 @@ IMAGE
68
68
  TEXT
69
69
 
70
70
  html = <<HTML
71
+ <dl>
71
72
  <dt>word 1</dt>
72
73
  <dd>description of word 1</dd>
73
74
  <dt>word 2</dt>
74
75
  <dd>description of word 2</dd>
76
+ </dl>
75
77
 
76
78
  HTML
77
79
 
@@ -375,11 +377,13 @@ TEXT
375
377
  end
376
378
 
377
379
  def test_escape
378
- text = "test string with *asterisk and _underscore"
379
- md_text = "test string with \\*asterisk and \\_underscore#{$/}"
380
+ text = "test string with *asterisk, _underscore and a html tag <h1>"
381
+ md_text = "test string with \\*asterisk, \\_underscore and a html tag &lt;h1&gt;#{$/}"
382
+ gfm_text = "test string with \\*asterisk, \\_underscore and a html tag \\<h1\\>#{$/}"
380
383
 
381
384
  tree = BlockParser.parse(text.lines.to_a)
382
385
  assert_equal(md_text, @formatter.format(tree).to_s)
386
+ assert_equal(gfm_text, @gfm_formatter.format(tree).to_s)
383
387
  end
384
388
 
385
389
  def test_not_escaped
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pseudohikiparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.7.develop
4
+ version: 0.0.0.8.develop
5
5
  platform: ruby
6
6
  authors:
7
7
  - HASHIMOTO, Naoki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-16 00:00:00.000000000 Z
11
+ date: 2014-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler