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 +4 -4
- data/Rakefile +9 -5
- data/lib/pandoc_abnt/lista_filter.rb +32 -2
- data/lib/pandoc_abnt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 547042032b2c2ca7cf2d4b07f2e119a97f0c4b91
|
4
|
+
data.tar.gz: 357f6d73f47a55772d90fa3a1956b55d18442212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
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
|
data/lib/pandoc_abnt/version.rb
CHANGED