String
.
redef fun strip_id(txt) do
# strip id
var b = new FlatBuffer
for c in txt do
if c == ' ' then
b.add '_'
else
if not c.is_letter and
not c.is_digit and
not allowed_id_chars.has(c) then continue
b.add c
end
end
var res = b.to_s
var key = res
# check for multiple id definitions
if headlines.has_key(key) then
var i = 1
key = "{res}_{i}"
while headlines.has_key(key) do
i += 1
key = "{res}_{i}"
end
end
return key
end
lib/markdown/decorators.nit:159,2--184,4
redef fun strip_id(txt) do
# strip id
var b = new FlatBuffer
for c in txt do
if c == ' ' then
b.add '_'
else
if not c.is_letter and
not c.is_digit and
not allowed_id_chars.has(c) then continue
b.add c
end
end
var res = b.to_s
var key = res
# check for multiple id definitions
if headlines.has_key(key) then
var i = 1
key = "{res}_{i}"
while headlines.has_key(key) do
i += 1
key = "{res}_{i}"
end
end
return key
end
lib/markdown/markdown.nit:891,2--916,4