Initial checkin.
Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
commit
b8d2887e52
3 changed files with 78 additions and 0 deletions
23
lib/filters/abbreviations.rb
Normal file
23
lib/filters/abbreviations.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# abbreviations.rb
|
||||
# a nanoc filter
|
||||
# licensed as nanoc itself
|
||||
#
|
||||
# add <bbrev> tags for all known abbreviations by a
|
||||
# very naive - and time consuming - regexp matchingA
|
||||
#
|
||||
# data source: YAML file in /content/_data/abbreviations
|
||||
#
|
||||
module Nanoc::Filters
|
||||
class Abbreviations < Nanoc::Filter
|
||||
identifier :abbrev
|
||||
type :text
|
||||
|
||||
def run(content, params={})
|
||||
output = content;
|
||||
@items['/_data/abbreviations/'][:abbreviations].each do |a|
|
||||
output = output.gsub(/(\s|[-,.;:"'!?>\(\[]+)#{a[:abbrev]}(\s|[-,.;:"'!?<\)\]]+)/,'\\1<abbr title="' + a[:fulltext] + '">' + a[:abbrev]+ '</abbr>\\2')
|
||||
end
|
||||
return output
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue