pandoc_abnt 0.3.0.pre → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23b4847f2f2578c6e369c5ccb0b9f0ec646f9b42
4
- data.tar.gz: b9fc078a5dd6bffcd262815e14c340f92fb5ab62
3
+ metadata.gz: 547042032b2c2ca7cf2d4b07f2e119a97f0c4b91
4
+ data.tar.gz: 357f6d73f47a55772d90fa3a1956b55d18442212
5
5
  SHA512:
6
- metadata.gz: 0b1e3182584780632ae8d3e1094287b71118697f9ac9e5ed91588f9ea8f2c438d4a00b725b325cb503e8527ed5109b68666ee30d14218e4a2b1e0030963954ca
7
- data.tar.gz: 8e92c6e60b6c479d9bc76427e4ca1565bd9ea4caf56e1da3a48fc1d763e900cb493c5e0ab8cd793a3733c3ad1caa4e3b42da4ee91755d5197a5d0c50bdbb8ae3
6
+ metadata.gz: 0a112fbf01646ffcdd62268cb7ab73c1d97d6aa7ff0081d858f647f34b5aef18b0c2ed5f9d40c8ece41e93df4977a03189801439910e8c93186134657b623879
7
+ data.tar.gz: 99d991e279aea56c2b6b9c45cb2e6e6a3523db426bd7fbcdc4615b90c4158a31b13a69c70f33e16c817202eafbe8bc5350386a78e7288da64b4981cdbdef0c9c
data/Rakefile CHANGED
@@ -51,11 +51,15 @@ task :fixtures do
51
51
  system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
52
52
  system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
53
53
 
54
-
55
- #system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.tex')}"
56
- # criar original.ext('.pandoc-tabela.tex') : Código latex da tabela que será formatada (remove a fonte de pandoc.tex)
57
- # criar original.ext('.abntex.tex') : Código esperado para o arquivo final (inclui fonte como legenda)
58
- #system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.abntex.tex')} -o #{original.ext('.abntex.json')}"
54
+ original = "lista-maiusculo.md"
55
+ system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
56
+ system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
57
+
58
+ original = "alineas-texto-sem-indentado.md"
59
+ system "pandoc -f markdown+raw_tex --wrap=none #{original} -o #{original.ext('.pandoc.json')}"
60
+ system "pandoc -f markdown+raw_tex --wrap=none #{original.ext('.transformacao-esperada.md')} -o #{original.ext('.transformacao-esperada.json')}"
61
+
62
+
59
63
  end
60
64
 
61
65
  end
@@ -73,8 +73,17 @@ module PandocAbnt
73
73
  itens = lista["c"] if lista_nao_ordenada?(lista)
74
74
  # byebug
75
75
  itens.each do |item|
76
+
76
77
  # último item da lista
77
78
  if item == itens.last then
79
+ # troca primeira letra por minúsculo
80
+ first_token = primeiro_tolken_do_item(lista, item)
81
+ if first_token["t"] == "Str" then
82
+ first_token["c"] = first_token["c"].sub(/^[[:alpha:]]/) {|f| f.downcase }
83
+ end
84
+
85
+ next if item_solitario(itens)
86
+
78
87
  # adiciona ou troca último caracter (';') para ponto final
79
88
  last_token = ultimo_tolken_do_item(lista, item)
80
89
  next unless last_token
@@ -87,7 +96,14 @@ module PandocAbnt
87
96
  end
88
97
  end
89
98
  else
90
- # itens internos, troca . por ';'
99
+ #byebug
100
+ # troca primeira letra por minúsculo
101
+ first_token = primeiro_tolken_do_item(lista, item)
102
+ if first_token["t"] == "Str" then
103
+ first_token["c"] = first_token["c"].sub(/^[[:alpha:]]/) {|f| f.downcase }
104
+ end
105
+
106
+ # itens internos, troca . por ';'
91
107
  last_token = ultimo_tolken_do_item(lista, item)
92
108
  next unless last_token
93
109
  if last_token["t"] == "Str" then
@@ -106,10 +122,24 @@ module PandocAbnt
106
122
  end
107
123
 
108
124
 
125
+ def primeiro_tolken_do_item(lista, item)
126
+ # [{"t"=>"Plain", "c"=>[{"t"=>"Str", "c"=>"item"}, {"t"=>"Space"}, {"t"=>"Str", "c"=>"1."}]}]
127
+ if lista_ordenada?(lista) and (item[0]["t"] == "Plain" or item[0]["t"] == "Para") then
128
+ item[0]["c"].first
129
+ elsif lista_nao_ordenada?(lista)
130
+ item[0]["c"].first
131
+ else
132
+ nil
133
+ end
134
+ end
135
+
136
+ def item_solitario(itens)
137
+ itens.size == 1
138
+ end
109
139
 
110
140
  def ultimo_tolken_do_item(lista, item)
111
141
  # [{"t"=>"Plain", "c"=>[{"t"=>"Str", "c"=>"item"}, {"t"=>"Space"}, {"t"=>"Str", "c"=>"1."}]}]
112
- if lista_ordenada?(lista) and item[0]["t"] == "Plain" then
142
+ if lista_ordenada?(lista) and (item[0]["t"] == "Plain" or item[0]["t"] == "Para") then
113
143
  item[0]["c"].last
114
144
  elsif lista_nao_ordenada?(lista)
115
145
  item[0]["c"].last
@@ -1,3 +1,3 @@
1
1
  module PandocAbnt
2
- VERSION = "0.3.0.pre"
2
+ VERSION = "1.0.0.rc1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandoc_abnt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre
4
+ version: 1.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo de Santana Medeiros Alexandre