File: xmlcomments.rb

package info (click to toggle)
libxml-parser-ruby 0.5.16-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 596 kB
  • ctags: 702
  • sloc: ruby: 4,474; ansic: 1,254; xml: 542; makefile: 53
file content (30 lines) | stat: -rwxr-xr-x 521 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /usr/local/bin/ruby

## Ruby version of xmlcomments
## 1998 by yoshidam
##
## This sample comes from Clark Cooper's sample of  Perl extension
## module XML::Parser.
##   (http://www.netheaven.com/~coopercc/xmlparser/samples/xmlcomments)

require 'xmlparser'

$count = 0

p = XMLParser.new

def p.character(data)
end

def p.default(data)
  if data =~ /^<!--/
    line = self.line
    data.gsub!(/\n/, "\n\t");
    print "#{line}:\t#{data}\n";
    $count += 1
  end
end

p.parse($<)

print "Found #{$count} comments.\n"