maruku-ext-ltsv_table 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,7 +18,19 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Just load.
22
+
23
+ require 'maruku'
24
+ require 'maruku/ext/ltsv_table'
25
+
26
+ html = Maruku.new("
27
+ 1:a\t2:b
28
+ 1:c\t2:d
29
+ ").to_html
30
+
31
+ When using maruku command, pass by `--ext` option.
32
+
33
+ $ maruku --ext ltsv_table a.md
22
34
 
23
35
  ## Contributing
24
36
 
data/TODO.md CHANGED
@@ -1,2 +1,2 @@
1
+ * handle continuous tab(null value case).
1
2
  * spec! spec! spec!
2
- * write `README.md`.
@@ -0,0 +1,40 @@
1
+ # encode: utf-8
2
+
3
+ require 'maruku'
4
+
5
+ module MaRuKu
6
+ module Ext
7
+ module LtsvTable
8
+ Regexp = /(?:[^:]+:[^\t]\t?)+/
9
+ Handler = lambda do |doc, src, context|
10
+ lines = []
11
+ labels = []
12
+ while src.cur_line =~ Regexp
13
+ lines.push(line = src.shift_line)
14
+ line.split("\t").map {|lv| lv.split(":")}.each {|l, v|
15
+ labels.push(l) unless labels.include?(l)
16
+ }
17
+ end
18
+ head, *rows = lines
19
+ to_md_el = lambda do |lines, el_sym|
20
+ lines.map {|line|
21
+ hash = {}
22
+ labels.each {|l| hash[l] = doc.md_el(el_sym, doc.parse_span_better('')) }
23
+ line.split("\t").map {|lv| lv.split(":")}.each {|l, v|
24
+ hash[l] = doc.md_el(el_sym, doc.parse_span_better(v))
25
+ }
26
+ labels.map {|l| hash[l]}
27
+ }
28
+ end
29
+ children = (to_md_el.call([head], :head_cell) + to_md_el.call(rows, :cell)).flatten
30
+ align = labels.map{|_| :left}
31
+ context.push doc.md_el(:table, children, { :align => align })
32
+ true
33
+ end
34
+ end
35
+ end
36
+ end
37
+ MaRuKu::In::Markdown.register_block_extension(
38
+ :regexp => MaRuKu::Ext::LtsvTable::Regexp,
39
+ :handler => MaRuKu::Ext::LtsvTable::Handler
40
+ )
@@ -1,7 +1,7 @@
1
1
  module MaRuKu
2
2
  module Ext
3
3
  module LtsvTable
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -1,40 +1,3 @@
1
1
  # encode: utf-8
2
2
 
3
- require 'maruku'
4
-
5
- module MaRuKu
6
- module Ext
7
- module LtsvTable
8
- Regexp = /(?:[^:]+:[^\t]\t?)+/
9
- Handler = lambda do |doc, src, context|
10
- lines = []
11
- labels = []
12
- while src.cur_line =~ Regexp
13
- lines.push(line = src.shift_line)
14
- line.split("\t").map {|lv| lv.split(":")}.each {|l, v|
15
- labels.push(l) unless labels.include?(l)
16
- }
17
- end
18
- head, *rows = lines
19
- to_md_el = lambda do |lines, el_sym|
20
- lines.map {|line|
21
- hash = {}
22
- labels.each {|l| hash[l] = doc.md_el(el_sym, doc.parse_span_better('')) }
23
- line.split("\t").map {|lv| lv.split(":")}.each {|l, v|
24
- hash[l] = doc.md_el(el_sym, doc.parse_span_better(v))
25
- }
26
- labels.map {|l| hash[l]}
27
- }
28
- end
29
- children = (to_md_el.call([head], :head_cell) + to_md_el.call(rows, :cell)).flatten
30
- align = labels.map{|_| :left}
31
- context.push doc.md_el(:table, children, { :align => align })
32
- true
33
- end
34
- end
35
- end
36
- end
37
- MaRuKu::In::Markdown.register_block_extension(
38
- :regexp => MaRuKu::Ext::LtsvTable::Regexp,
39
- :handler => MaRuKu::Ext::LtsvTable::Handler
40
- )
3
+ require 'maruku/ext/ltsv_table'
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["kozy4324@gmail.com"]
11
11
  gem.description = %q{Maruku extension for table written by ltsv format.}
12
12
  gem.summary = %q{Maruku extension for table written by ltsv format.}
13
- gem.homepage = ""
13
+ gem.homepage = "https://github.com/kozy4324/maruku-ext-ltsv_table"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,7 +1,6 @@
1
1
  # encode: utf-8
2
2
 
3
- require 'maruku'
4
- require 'maruku-ext-ltsv_table'
3
+ require 'maruku/ext/ltsv_table'
5
4
 
6
5
  describe "parse_ltsv" do
7
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maruku-ext-ltsv_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-04-08 00:00:00.000000000 Z
12
+ date: 2013-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: maruku
@@ -58,9 +58,10 @@ files:
58
58
  - TODO.md
59
59
  - lib/maruku-ext-ltsv_table.rb
60
60
  - lib/maruku-ext-ltsv_table/version.rb
61
+ - lib/maruku/ext/ltsv_table.rb
61
62
  - maruku-ext-ltsv_table.gemspec
62
63
  - spec/parse_ltsv_spec.rb
63
- homepage: ''
64
+ homepage: https://github.com/kozy4324/maruku-ext-ltsv_table
64
65
  licenses: []
65
66
  post_install_message:
66
67
  rdoc_options: []