pandoc_abnt 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 972d5889d220fd4f87d60a5f8048bdf6d0ae3ba3
4
- data.tar.gz: 4ae006e7a93a4ee196aae8b7574f5cbbc0eac894
3
+ metadata.gz: ce7f9ba40dcb48bedf24b8a2dd9d4f22d2ecada5
4
+ data.tar.gz: d70bf893e2c183c68de5e35655bc71b980c9e4cb
5
5
  SHA512:
6
- metadata.gz: 12010f61efa8c7424c364d00968d02392aa013becf017507393eda521fdf41d094933a824dc852b40e6702a2d27a990d520eadfdad777509d42fa2f6701d3fb5
7
- data.tar.gz: 68cbd350ad63e1852dff61f9bc230cbdfb8dc1feac585f0a31da90045cbd45fcb796d942f4cf35aec0683033c7ac688a6a1823b00b0bc81f6e66b5ec22c2da2e
6
+ metadata.gz: f3873b2ced1f294630ba5ec7e34b486cd952b326de95a464f92777ad652c0bfe6d2b48c9c4d63749ba1b17f0c1bf9e889bdec62b727759e6950ba2cd4f7d38f4
7
+ data.tar.gz: f9eb08f9af18cb6a37c32e1eeace28876c04defcd411a6ddab172746b05c22700bdb35f5de83574b93cc33ac63389e593e8676f4e6b8f1aabed6d391c6b48b43
data/Rakefile CHANGED
@@ -4,3 +4,12 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
+
8
+ task :fixtures do
9
+ Dir.chdir("spec/fixtures/files/tabelas") do
10
+ system "pandoc -f markdown+raw_tex simple_tables-with-footnote.md -o simple_tables-with-footnote.pandoc.json"
11
+ system "pandoc -f markdown+raw_tex simple_tables-with-footnote.md -o simple_tables-with-footnote.pandoc.tex"
12
+ system "pandoc -f markdown+raw_tex simple_tables-with-footnote.abntex.tex -o simple_tables-with-footnote.abntex.json"
13
+ end
14
+
15
+ end
@@ -22,6 +22,14 @@ module PandocAbnt
22
22
  LATEX
23
23
  end
24
24
 
25
+ def reformata_tabela_latex(latex_code, fonte)
26
+ inicio = latex_code.lines[0..-2].join ""
27
+ abntex_code = <<LATEX
28
+ #{inicio}\\caption*{#{fonte.strip}}
29
+ \\end{longtable}
30
+ LATEX
31
+ end
32
+
25
33
  # Verifica se node é um parágrafo que inicia com "Fonte:"
26
34
  def fonte?(node)
27
35
  # {"t":"Para","c":[{"t":"Str","c":"Fonte:"},{"t":"Space","c":[]},{"t":"Str","c":"Autor."}]}
@@ -35,6 +43,13 @@ LATEX
35
43
  node["t"] == "Para" and node["c"][0]["t"] == "Image"
36
44
  end
37
45
 
46
+ # Verifica se node é uma tabela
47
+ def tabela?(node)
48
+ # {"t":"Table","c":[[{"t":"Str","c":"Demonstration"},{"t":"Space"},{"t":"Str","c":"of"},{"t":"Space"},{"t":"Str","c":"simple"},{"t":"Space"},{"t":"Str","c":"table"},{"t":"Space"},{"t":"Str","c":"syntax."},{"t":"Space"},{"t":"RawInline","c":["tex","\\label{mytable}"]}],[{"t":"AlignRight"},{"t":"AlignLeft"},{"t":"AlignCenter"},{"t":"AlignDefault"}],[0,0,0,0],[[{"t":"Plain","c":[{"t":"Str","c":"Right"}]}],[{"t":"Plain","c":[{"t":"Str","c":"Left"}]}],[{"t":"Plain","c":[{"t":"Str","c":"Center"}]}],[{"t":"Plain","c":[{"t":"Str","c":"Default"}]}]],[[[{"t":"Plain","c":[{"t":"Str","c":"12"}]}],[{"t":"Plain","c":[{"t":"Str","c":"12"}]}],[{"t":"Plain","c":[{"t":"Str","c":"12"}]}],[{"t":"Plain","c":[{"t":"Str","c":"12"}]}]],[[{"t":"Plain","c":[{"t":"Str","c":"123"}]}],[{"t":"Plain","c":[{"t":"Str","c":"123"}]}],[{"t":"Plain","c":[{"t":"Str","c":"123"}]}],[{"t":"Plain","c":[{"t":"Str","c":"123"}]}]],[[{"t":"Plain","c":[{"t":"Str","c":"1"}]}],[{"t":"Plain","c":[{"t":"Str","c":"1"}]}],[{"t":"Plain","c":[{"t":"Str","c":"1"}]}],[{"t":"Plain","c":[{"t":"Str","c":"1"}]}]]]]}
49
+ node["t"] == "Table"
50
+ end
51
+
52
+
38
53
  # Converte node para latex
39
54
  def convert_to_latex(node)
40
55
  latex_code = nil
@@ -72,6 +87,14 @@ LATEX
72
87
  texcode = reformata_figura_latex(imagem_latex, fonte_latex)
73
88
  raw_tex = {"t"=>"RawBlock","c"=>["latex",texcode]}
74
89
 
90
+ filtrados.pop # remote o anterior
91
+ filtrados << raw_tex
92
+ elsif (fonte?(node) and tabela?(anterior)) then
93
+ tabela_latex = convert_to_latex({"blocks"=>[anterior], "pandoc-api-version" => api, "meta" => meta})
94
+ fonte_latex = convert_to_latex({"blocks"=>[node], "pandoc-api-version" => api, "meta" => meta})
95
+ texcode = reformata_tabela_latex(tabela_latex, fonte_latex)
96
+ raw_tex = {"t"=>"RawBlock","c"=>["latex",texcode.strip]}
97
+
75
98
  filtrados.pop # remote o anterior
76
99
  filtrados << raw_tex
77
100
  else
@@ -1,3 +1,3 @@
1
1
  module PandocAbnt
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandoc_abnt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo de Santana Medeiros Alexandre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-11 00:00:00.000000000 Z
11
+ date: 2017-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler