File: langfilter.rb

package info (click to toggle)
docdiff 0.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 960 kB
  • sloc: ruby: 13,872; makefile: 92; lisp: 33; sh: 26
file content (10 lines) | stat: -rw-r--r-- 322 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/ruby
# language filter
# usage: langfilter.rb --en <infile >outfile

lang_to_include = ARGV.shift.gsub(/-+/, "")
lang_to_exclude = {"en"=>"ja", "ja"=>"en"}[lang_to_include]
re = /<([a-z]+) +(?:(?:lang|title)="#{lang_to_exclude}").*?>.*?<\/\1>[\r\n]?/m

ARGF.set_encoding("UTF-8")
ARGF.read.gsub(re, "").display