pandoc_abnt 1.1.2 → 2.0.0
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 +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +2 -2
- data/README.md +3 -2
- data/Rakefile +13 -21
- data/lib/pandoc_abnt/figura_filter.rb +76 -24
- data/lib/pandoc_abnt/version.rb +1 -1
- data/pandoc_abnt.gemspec +5 -3
- metadata +39 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 85a0181f4da40a6c26fa02f60032936447f1999c49c4d551d6f48988d2681531
|
4
|
+
data.tar.gz: 1b80e9cd885fc4764d5c9790f7a275f32a2a465aa0ebc4362676e358d8b8902b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0423eac8601751c0ce0078c12870f42994aaa09dab7d3436d1f7acc25cf3327a30dd8386b087860d0d8e077d5f7ace0614586d8b38b42478f10a98b4547d56fb
|
7
|
+
data.tar.gz: ca0f4ba09096bba18ee6ffa70673a1b5d34defad25c1994127fda8a186abcabd68c98c47acee9314683a827209233af16b91757002da1311fcbe8e9cbeab767b
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -4,6 +4,6 @@ language: ruby
|
|
4
4
|
rvm:
|
5
5
|
- 2.3.1
|
6
6
|
before_install:
|
7
|
-
- gem install bundler -v 1.
|
7
|
+
- gem install bundler -v 1.16.6
|
8
8
|
- sudo apt-get update -qq
|
9
|
-
- wget https://github.com/jgm/pandoc/releases/download/
|
9
|
+
- wget https://github.com/jgm/pandoc/releases/download/2.3.1/pandoc-2.3.1-1-amd64.deb && sudo dpkg -i pandoc-*.deb
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ O pandoc_abnt foi elaborado para ser utilizado com o [limarka](https://github.co
|
|
33
33
|
|
34
34
|
### Fonte de Figuras e Tabelas
|
35
35
|
|
36
|
-
Para adicionar uma fonte a figura ou tabela, basta adicionar no parágrafo seguinte: `Fonte: texto da fonte`.
|
36
|
+
Para adicionar uma fonte a figura ou tabela, basta adicionar no parágrafo seguinte: `Fonte: texto da fonte`.
|
37
37
|
|
38
38
|
Exemplo de Figura:
|
39
39
|
|
@@ -171,6 +171,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
171
171
|
|
172
172
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
173
173
|
|
174
|
+
A documentação é elaborada através das [features do cucumber](https://relishapp.com/relish/relish/docs/quick-start-guide).
|
175
|
+
|
174
176
|
## Contributing
|
175
177
|
|
176
178
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pandoc_abnt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
@@ -179,4 +181,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
|
179
181
|
## License
|
180
182
|
|
181
183
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
182
|
-
|
data/Rakefile
CHANGED
@@ -1,23 +1,18 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require "cucumber/rake/task"
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
Cucumber::Rake::Task.new do |t|
|
7
|
+
t.cucumber_opts = %w{--format progress}
|
8
|
+
end
|
5
9
|
|
6
|
-
task :default => :spec
|
10
|
+
task :default => [:spec, :cucumber]
|
7
11
|
|
8
12
|
desc "Cria/recria as fixtures"
|
9
13
|
task :fixtures do
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
#originais = ["p-fig-caption-largura-p-fonte.md"]
|
14
|
-
#originais.each do |original|
|
15
|
-
#system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
|
16
|
-
#system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
|
17
|
-
#end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
15
|
+
#FIXME remover original
|
21
16
|
|
22
17
|
Dir.chdir("spec/fixtures/files/tabelas") do
|
23
18
|
|
@@ -32,17 +27,17 @@ task :fixtures do
|
|
32
27
|
# criar original.ext('.abntex.tex') : Código esperado para o arquivo final (inclui fonte como legenda)
|
33
28
|
system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.abntex.tex')} -o #{original.ext('.abntex.json')}"
|
34
29
|
end
|
35
|
-
|
30
|
+
|
36
31
|
Dir.chdir("spec/fixtures/files/listas") do
|
37
32
|
original = "lista-letras-termiando-com-ponto.md"
|
38
33
|
system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
|
39
34
|
system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
|
40
|
-
|
35
|
+
|
41
36
|
original = "lista-letras-termiando-com-ponto-e-virgula.md"
|
42
37
|
system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
|
43
38
|
system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
|
44
39
|
|
45
|
-
|
40
|
+
|
46
41
|
original = "lista-letras-termiando-com-ponto-e-virgula-mix.md"
|
47
42
|
system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
|
48
43
|
system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
|
@@ -58,7 +53,7 @@ task :fixtures do
|
|
58
53
|
original = "lista-nao-ordenada-mix.md"
|
59
54
|
system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
|
60
55
|
system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
|
61
|
-
|
56
|
+
|
62
57
|
original = "lista-nao-ordenada-terminando-com-letra-mix.md"
|
63
58
|
system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
|
64
59
|
system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
|
@@ -71,17 +66,14 @@ task :fixtures do
|
|
71
66
|
system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
|
72
67
|
system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
|
73
68
|
end
|
74
|
-
|
69
|
+
|
75
70
|
Dir.chdir("spec/fixtures/files/quadros") do
|
76
71
|
original = "quadro-com-id-titulo-e-fonte.md"
|
77
72
|
system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
|
78
73
|
#system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}" # removido pq não funciona mais o parse com código fore do begin e and longtable.
|
79
|
-
|
74
|
+
|
80
75
|
system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.apenas-tabela.md')} -o #{original.ext('.apenas-tabela.json')}"
|
81
76
|
system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.apenas-tabela.md')} -o #{original.ext('.apenas-tabela.tex')}"
|
82
|
-
|
83
|
-
|
84
|
-
|
85
77
|
end
|
86
|
-
|
78
|
+
|
87
79
|
end
|
@@ -3,25 +3,77 @@ require 'open3'
|
|
3
3
|
|
4
4
|
module PandocAbnt
|
5
5
|
|
6
|
-
# Essa classe é responsável por
|
6
|
+
# Essa classe é responsável por alterar a área sintática
|
7
|
+
# dos nós de imagem para um nó raw_tex com imgagem
|
8
|
+
# no formato do abntex2.
|
7
9
|
# @see Trabalho#configuracao
|
8
10
|
class FiguraFilter
|
9
11
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def ler_escala(image_node)
|
13
|
+
# {"t"=>"Para", "c"=>[{"t"=>"Image", "c"=>[["id", [], [["escala", "30%"]]], [{"t"=>"Str", "c"=>"Título"}], ["imagem.png", "fig:"]]}]}
|
14
|
+
if image_node["c"][0]["c"][0][2].empty?
|
15
|
+
nil
|
16
|
+
else
|
17
|
+
if image_node["c"][0]["c"][0][2][0][0] == "escala"
|
18
|
+
image_node["c"][0]["c"][0][2][0][1]
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def atualiza_includegraphics(includegraphics, image_node)
|
25
|
+
# "\\includegraphics{imagem.png}"
|
26
|
+
escala = ler_escala(image_node)
|
27
|
+
result = nil
|
28
|
+
if escala
|
29
|
+
result = "\\includegraphics[scale=#{escala}]{#{includegraphics.split("{")[1]}"
|
30
|
+
else
|
31
|
+
result = includegraphics
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def reformata_figura_latex(latex_code, fonte, image_node)
|
36
|
+
image_regex = /\\includegraphics.*/
|
37
|
+
caption_regex = /\\caption.*/
|
38
|
+
hypertarget_regex = /\\hypertarget.*/
|
39
|
+
includegraphics = atualiza_includegraphics("#{latex_code.match(image_regex)}", image_node)
|
40
|
+
|
41
|
+
=begin
|
42
|
+
Como vem:
|
43
|
+
\begin{figure}
|
44
|
+
\hypertarget{arquitetura}{%
|
45
|
+
\centering
|
46
|
+
\includegraphics{limarka-arquitetura.jpg}
|
47
|
+
\caption{Arquitetura do Limarka}\label{arquitetura}
|
48
|
+
}
|
49
|
+
\end{figure}
|
50
|
+
|
51
|
+
Como deve ser:
|
52
|
+
|
53
|
+
\begin{figure}[htbp]
|
54
|
+
\hypertarget{arquitetura}{%
|
55
|
+
\caption{Arquitetura do Limarka}\label{arquitetura}
|
56
|
+
\begin{center}
|
57
|
+
\includegraphics[scale=0.4]{limarka-arquitetura.jpg}
|
58
|
+
\end{center}
|
59
|
+
}
|
60
|
+
\legend{Fonte: Autor.}
|
61
|
+
\end{figure}
|
62
|
+
"""
|
63
|
+
=end
|
64
|
+
figura_abntex = <<-LATEX
|
15
65
|
\\begin{figure}[htbp]
|
66
|
+
#{latex_code.match hypertarget_regex}
|
16
67
|
#{latex_code.match caption_regex}
|
17
68
|
\\begin{center}
|
18
|
-
#{
|
69
|
+
#{includegraphics}
|
19
70
|
\\end{center}
|
71
|
+
}
|
20
72
|
\\legend{#{fonte.strip}}
|
21
73
|
\\end{figure}
|
22
74
|
LATEX
|
23
75
|
end
|
24
|
-
|
76
|
+
|
25
77
|
def reformata_tabela_latex(latex_code, fonte)
|
26
78
|
inicio = latex_code.lines[0..-2].join ""
|
27
79
|
abntex_code = <<LATEX
|
@@ -29,13 +81,13 @@ LATEX
|
|
29
81
|
\\end{longtable}
|
30
82
|
LATEX
|
31
83
|
end
|
32
|
-
|
84
|
+
|
33
85
|
# Verifica se node é um parágrafo que inicia com "Fonte:"
|
34
86
|
def fonte?(node)
|
35
87
|
# {"t":"Para","c":[{"t":"Str","c":"Fonte:"},{"t":"Space","c":[]},{"t":"Str","c":"Autor."}]}
|
36
88
|
node["t"] == "Para" and node["c"][0]["c"] == "Fonte:"
|
37
89
|
end
|
38
|
-
|
90
|
+
|
39
91
|
# Verifica se node contém apenas uma imagem
|
40
92
|
def imagem?(node)
|
41
93
|
# {"t":"Para","c":[{"t":"Image","c":[["id",[],[["width","30%"]]],[{"t":"Str","c":"Título"}],["imagem.png","fig:"]]}]}
|
@@ -84,46 +136,46 @@ LATEX
|
|
84
136
|
meta = tree["meta"]
|
85
137
|
blocks = tree["blocks"]
|
86
138
|
api = tree["pandoc-api-version"]
|
87
|
-
|
139
|
+
|
88
140
|
filtrados = []
|
89
141
|
anterior = nil
|
90
|
-
|
142
|
+
|
91
143
|
if not blocks
|
92
144
|
raise ArgumentError, "Problema no argumento passado: #{pandoc_json_tree}"
|
93
145
|
end
|
94
|
-
|
146
|
+
|
95
147
|
blocks.each do |node|
|
96
|
-
|
148
|
+
|
97
149
|
if (fonte?(node) and imagem?(anterior)) then
|
98
150
|
image_node = atualiza_imagem_width(anterior)
|
99
151
|
imagem_latex = convert_to_latex({"blocks"=>[image_node], "pandoc-api-version" => api, "meta" => meta})
|
100
152
|
fonte_latex = convert_to_latex({"blocks"=>[node], "pandoc-api-version" => api, "meta" => meta})
|
101
|
-
texcode = reformata_figura_latex(imagem_latex, fonte_latex)
|
102
|
-
raw_tex = {"t"=>"RawBlock","c"=>["
|
103
|
-
|
153
|
+
texcode = reformata_figura_latex(imagem_latex, fonte_latex, image_node)
|
154
|
+
raw_tex = {"t"=>"RawBlock","c"=>["tex",texcode.strip]}
|
155
|
+
|
104
156
|
filtrados.pop # remote o anterior
|
105
157
|
filtrados << raw_tex
|
106
158
|
elsif (fonte?(node) and tabela?(anterior)) then
|
107
159
|
tabela_latex = convert_to_latex({"blocks"=>[anterior], "pandoc-api-version" => api, "meta" => meta})
|
108
160
|
fonte_latex = convert_to_latex({"blocks"=>[node], "pandoc-api-version" => api, "meta" => meta})
|
109
161
|
texcode = reformata_tabela_latex(tabela_latex, fonte_latex)
|
110
|
-
raw_tex = {"t"=>"RawBlock","c"=>["
|
111
|
-
|
162
|
+
raw_tex = {"t"=>"RawBlock","c"=>["tex",texcode.strip]}
|
163
|
+
|
112
164
|
filtrados.pop # remote o anterior
|
113
165
|
filtrados << raw_tex
|
114
166
|
else
|
115
167
|
filtrados << node
|
116
168
|
end
|
117
|
-
|
169
|
+
|
118
170
|
anterior = node
|
119
171
|
end
|
120
|
-
|
172
|
+
|
121
173
|
JSON.generate({"blocks"=>filtrados, "pandoc-api-version" => api, "meta" => meta})
|
122
|
-
|
123
|
-
|
174
|
+
|
175
|
+
|
124
176
|
# result = <<-LATEX [{"unMeta":{}},[{"t":"RawBlock","c":["latex","\\begin{figure}[htbp]\n\\caption{Legenda da figura}\\label{id}\n\\begin{center}\n\\includegraphics[width=0.30000\\textwidth]{imagem.png}\n\\end{center}\n\\legend{Fonte: Autor.}\n\\end{figure}"]}]]
|
125
177
|
|
126
178
|
end
|
127
|
-
|
179
|
+
|
128
180
|
end
|
129
181
|
end
|
data/lib/pandoc_abnt/version.rb
CHANGED
data/pandoc_abnt.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
ATENÇÃO:
|
25
25
|
Para utilização de Quadros é necessário que o modelo utilizado seja versão >= 0.4.1.
|
26
26
|
|
27
|
-
A última versão do modelo pode ser baixada em:
|
27
|
+
A última versão do modelo pode ser baixada em:
|
28
28
|
https://github.com/abntex/trabalho-academico-limarka/releases/latest
|
29
29
|
---------------------------------------------------------------------
|
30
30
|
MSG
|
@@ -34,6 +34,8 @@ MSG
|
|
34
34
|
spec.add_development_dependency "rspec", "~> 3.5"
|
35
35
|
spec.add_development_dependency "byebug"
|
36
36
|
spec.add_development_dependency "github_changelog_generator"
|
37
|
-
|
38
|
-
|
37
|
+
spec.add_development_dependency "cucumber"
|
38
|
+
spec.add_development_dependency "aruba"
|
39
|
+
|
40
|
+
|
39
41
|
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:
|
4
|
+
version: 2.0.0
|
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:
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: cucumber
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: aruba
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
description: Adiciona fontes à Imagens e Tabelas.
|
84
112
|
email:
|
85
113
|
- eduardo.ufpb@gmail.com
|
@@ -109,9 +137,14 @@ homepage: https://github.com/edusantana/pandoc_abnt
|
|
109
137
|
licenses:
|
110
138
|
- MIT
|
111
139
|
metadata: {}
|
112
|
-
post_install_message:
|
113
|
-
|
114
|
-
|
140
|
+
post_install_message: |
|
141
|
+
---------------------------------------------------------------------
|
142
|
+
ATENÇÃO:
|
143
|
+
Para utilização de Quadros é necessário que o modelo utilizado seja versão >= 0.4.1.
|
144
|
+
|
145
|
+
A última versão do modelo pode ser baixada em:
|
146
|
+
https://github.com/abntex/trabalho-academico-limarka/releases/latest
|
147
|
+
---------------------------------------------------------------------
|
115
148
|
rdoc_options: []
|
116
149
|
require_paths:
|
117
150
|
- lib
|
@@ -127,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
160
|
version: '0'
|
128
161
|
requirements: []
|
129
162
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.7.6
|
131
164
|
signing_key:
|
132
165
|
specification_version: 4
|
133
166
|
summary: Filtro pandoc para converter conteúdos para as Normas da ABNT
|