pandoc_abnt 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -0
- data/lib/pandoc_abnt/figura_filter.rb +23 -0
- data/lib/pandoc_abnt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce7f9ba40dcb48bedf24b8a2dd9d4f22d2ecada5
|
4
|
+
data.tar.gz: d70bf893e2c183c68de5e35655bc71b980c9e4cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/pandoc_abnt/version.rb
CHANGED
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.
|
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
|
+
date: 2017-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|