pandoc_abnt 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed0ca0841ad3c94b17d78663d29bcba077d94aa7
4
+ data.tar.gz: 89bbca9c5362e2e948f4f7aa70d82b9b8ab3c27e
5
+ SHA512:
6
+ metadata.gz: c9f05066027304378b64cb8ef3fea96df75385ad67975041cb07e9445ae9971483b573160602dc1a11c40770afb0b6713e2e904c147bb2af0f2c1d5611af1e2d
7
+ data.tar.gz: 2dd4b6f44accdd90a3582f6c256edaa892705b1a462d2ecdcc2513610c2dacc0ebb6b38408dc780c1f3dc800d1ce40dbad72eba0d26eced2d8c4f86635797e90
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.2
@@ -0,0 +1,71 @@
1
+ # Código de Conduta para Colaboradores
2
+
3
+ ## Nossa promessa
4
+
5
+ Com o interesse de fomentar uma comunidade aberta e acolhedora,
6
+ nós, como colaboradores e administradores deste projeto, comprometemo-nos
7
+ a fazer a participação deste projeto uma experiência livre de assédio
8
+ para todos, independentemente da aparência pessoal, deficiência,
9
+ diferença corporal, etnia, gênero, idade, identidade ou expressão
10
+ de gênero, identidade ou orientação sexual, nacionalidade, nível de
11
+ experiência, raça ou religião.
12
+
13
+ ## Nossos padrões
14
+
15
+ Exemplos de comportamentos que contribuem a criar um ambiente positivo incluem:
16
+
17
+ * Usar linguagem acolhedora e inclusiva
18
+ * Respeitar pontos de vista e experiencias diferentes
19
+ * Aceitar crítica construtíva com graça
20
+ * Focar no que é melhor para a comunidade
21
+ * Mostrar empatia com outros membros da comunidade
22
+
23
+ Exemplos de comportamentos inaceitáveis por parte dos participantes incluem:
24
+
25
+ * Uso de linguagem ou imagens sexuais e atenção ou avanço sexual indesejada
26
+ * Comentários insultuosos e/ou depreciativos e ataques pessoais ou políticos (*Trolling*)
27
+ * Assédio público ou privado
28
+ * Publicar informação pessoal de outros sem permissão explícita, como, por exemplo, um endereço eletrônico ou residencial
29
+ * Qualquer outra forma de conduta que pode ser razoavelmente considerada inapropriada num ambiente profissional
30
+
31
+ ## Nossas responsibilidades
32
+
33
+ Os administradores do projeto são responsáveis por esclareçer os padrões de
34
+ comportamento e deverão tomar ação corretiva apropriada e justa em resposta
35
+ a qualquer instância de comportamento inaceitável.
36
+
37
+ Os administradores do projeto têm o direito e a responsabilidade de
38
+ remover, editar ou rejeitar comentários, commits, código, edições
39
+ na wiki, erros ou outras formas de contribuição que não estejam de
40
+ acordo com este Código de Conduta, bem como banir temporariamente ou
41
+ permanentemente qualquer colaborador por qualquer outro comportamento
42
+ que se considere impróprio, perigoso, ofensivo ou problemático.
43
+
44
+ ## Escopo
45
+
46
+ Este Código de Conduta aplica-se dentro dos espaços do projeto ou
47
+ qualquer espaço público onde alguém represente o mesmo ou a sua
48
+ comunidade. Exemplos de representação do projeto ou comunidade incluem
49
+ usar um endereço de email oficial do projeto, postar por uma conta de
50
+ mídia social oficial, ou agir como um representante designado num evento
51
+ online ou offline. A representação de um projeto pode ser ainda definida e
52
+ esclarecida pelos administradores do projeto.
53
+
54
+ ## Aplicação
55
+
56
+ Comportamento abusivo, de assédio ou de outros tipos pode ser
57
+ comunicados contatando a equipe do projeto (https://www.facebook.com/eduardosantanamedeiros).
58
+ Todas as queixas serão revistas e investigadas e
59
+ resultarão numa resposta necessária e apropriada à situação.
60
+ A equipe é obrigada a manter a confidencialidade em relação
61
+ ao elemento que reportou o incidente. Demais detalhes de
62
+ políticas de aplicação podem ser postadas separadamente.
63
+
64
+ Administradores do projeto que não sigam ou não mantenham o Código
65
+ de Conduta em boa fé podem enfrentar repercussões temporárias ou permanentes
66
+ determinadas por outros membros da liderança do projeto.
67
+
68
+ ## Atribuição
69
+
70
+ Este Código de Conduta é adaptado do [Contributor Covenant](http://contributor-covenant.org),
71
+ versão 1.4, disponível em [http://contributor-covenant.org/version/1/4/pt_br/](http://contributor-covenant.org/version/1/4/pt_br/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pandoc_abnt.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Eduardo de Santana Medeiros Alexandre
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # pandoc_abnt
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pandoc_abnt`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ Filtro pandoc para elaborar documentos de acordo com as normas da abnt.
6
+
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'pandoc_abnt'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install pandoc_abnt
23
+
24
+ ## Usage
25
+
26
+ TODO: Write usage instructions here
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ 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).
33
+
34
+ ## Contributing
35
+
36
+ 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.
37
+
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
42
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pandoc_abnt"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exec/pandoc_abnt ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Para corrigir os problemas de codificação no Windows #98
4
+ Encoding.default_external = Encoding::UTF_8
5
+ Encoding.default_internal = Encoding::UTF_8
6
+
7
+
8
+ require 'json'
9
+
10
+ data = JSON.parse(STDIN.read)
11
+
12
+ ff = PandocAbnt::FiguraFilter.new
13
+
14
+ $stdout << ff.filtra_json(data)
15
+
@@ -0,0 +1,83 @@
1
+ require 'json'
2
+
3
+ module PandocAbnt
4
+
5
+ # Essa classe é responsável por
6
+ # @see Trabalho#configuracao
7
+ class FiguraFilter
8
+
9
+ def reformata_figura_latex(latex_code, fonte)
10
+
11
+ image_regex = /\\includegraphics.*/
12
+ caption_regex = /\\caption.*/
13
+
14
+
15
+ figura_abntex = <<LATEX
16
+ \\begin{figure}[htbp]
17
+ #{latex_code.match caption_regex}
18
+ \\begin{center}
19
+ #{latex_code.match image_regex}
20
+ \\end{center}
21
+ \\legend{#{fonte}}
22
+ \\end{figure}
23
+ LATEX
24
+ end
25
+
26
+ # Verifica se node é um parágrafo que inicia com "Fonte:"
27
+ def fonte?(node)
28
+ # {"t":"Para","c":[{"t":"Str","c":"Fonte:"},{"t":"Space","c":[]},{"t":"Str","c":"Autor."}]}
29
+ node["t"] == "Para" and node["c"][0]["c"] == "Fonte:"
30
+ end
31
+
32
+ # Verifica se node contém apenas uma imagem
33
+ def imagem?(node)
34
+ # {"t":"Para","c":[{"t":"Image","c":[["id",[],[["width","30%"]]],[{"t":"Str","c":"Título"}],["imagem.png","fig:"]]}]}
35
+
36
+ node["t"] == "Para" and node["c"][0]["t"] == "Image"
37
+ end
38
+
39
+ def convert_to_latex(node)
40
+ end
41
+
42
+ def filtra_json(pandoc_json_tree)
43
+ # Exemplo de código:
44
+ # [{"unMeta":{}},[{"t":"Para","c":[{"t":"Image","c":[["id",[],[["width","30%"]]],[{"t":"Str","c":"Título"}],["imagem.png","fig:"]]}]},{"t":"Para","c":[{"t":"Str","c":"Fonte:"},{"t":"Space","c":[]},{"t":"Str","c":"Autor."}]}]]
45
+ tree = JSON.parse(pandoc_json_tree)
46
+ meta = tree[0]
47
+
48
+ filtrados = []
49
+ anterior = nil
50
+ tree[1].each do |node|
51
+
52
+ if (fonte?(node) and imagem?(anterior)) then
53
+ imagem_latex = convert_to_latex(anterior)
54
+ fonte_latex = convert_to_latex(node)
55
+ texcode = <<TEX
56
+ \\begin{figure}[htbp]
57
+ \\caption{Legenda da figura}\\label{id}
58
+ \\begin{center}
59
+ \\includegraphics[width=0.30000\\textwidth]{imagem.png}
60
+ \\end{center}
61
+ \\legend{Fonte: Autor}
62
+ \\end{figure}
63
+ TEX
64
+ raw_tex = {"t"=>"RawBlock","c"=>["latex",texcode]}
65
+
66
+ filtrados.pop # remote o anterior
67
+ filtrados << raw_tex
68
+ else
69
+ filtrados << node
70
+ end
71
+
72
+ anterior = node
73
+ end
74
+
75
+ JSON.generate([meta,filtrados])
76
+
77
+
78
+ # 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}"]}]]
79
+
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,3 @@
1
+ module PandocAbnt
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "pandoc_abnt/version"
2
+ require "pandoc_abnt/figura_filter"
3
+
4
+ module PandocAbnt
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pandoc_abnt/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pandoc_abnt"
8
+ spec.version = PandocAbnt::VERSION
9
+ spec.authors = ["Eduardo de Santana Medeiros Alexandre"]
10
+ spec.email = ["eduardo.ufpb@gmail.com"]
11
+
12
+ spec.summary = %q{Filtro pandoc para converter conteúdos para as Normas da ABNT}
13
+ spec.description = %q{Adiciona fontes à Imagens e Tabelas.}
14
+ spec.homepage = "https://github.com/edusantana/pandoc_abnt"
15
+ spec.license = "MIT"
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.13"
24
+ spec.add_development_dependency "rake", "~> 11.0"
25
+ spec.add_development_dependency "rspec", "~> 3.5"
26
+ spec.add_development_dependency "byebug"
27
+ spec.add_development_dependency "github_changelog_generator"
28
+
29
+
30
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pandoc_abnt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eduardo de Santana Medeiros Alexandre
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: github_changelog_generator
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Adiciona fontes à Imagens e Tabelas.
84
+ email:
85
+ - eduardo.ufpb@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - exec/pandoc_abnt
101
+ - lib/pandoc_abnt.rb
102
+ - lib/pandoc_abnt/figura_filter.rb
103
+ - lib/pandoc_abnt/version.rb
104
+ - pandoc_abnt.gemspec
105
+ homepage: https://github.com/edusantana/pandoc_abnt
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.5.1
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Filtro pandoc para converter conteúdos para as Normas da ABNT
129
+ test_files: []