Skip to content

Commit

Permalink
bug fix: Invalid tags which begin with # are now transformed into com…
Browse files Browse the repository at this point in the history
…ment tags.
  • Loading branch information
James Robertson committed Mar 3, 2015
1 parent 787d256 commit 85632c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions lib/rowx.rb
Expand Up @@ -26,7 +26,8 @@ class RowX

def initialize(txt, level: nil)

a = LineTree.new(txt.gsub(/^-*$/m,''), level: level, ignore_blank_lines: false).to_a
a = LineTree.new(txt.gsub(/^-*$/m,''), \
level: level, ignore_blank_lines: false).to_a
keyfield = a[0][0][/\w+:/]; i = 0

# find the keyfield. if there's only 1 keyfield in all of the rows it's
Expand Down Expand Up @@ -60,9 +61,15 @@ def scan_a(row)

value, name = s.split(':',2).reverse
name ||= 'description'

children = scan_a(field[1..-1]) if field[-1] .is_a?(Array)
value = value.to_s.strip.gsub('<','&lt;').gsub('>','&gt;')
value = value.to_s.strip.gsub('<','&lt;').gsub('>','&gt;')

# it's a line which has been commented out?
if name[0] == '#' then
value = name[1..-1] + ': ' + value
name = '!-'
end

result = [name, {}, value]
result << children if children
Expand All @@ -78,4 +85,4 @@ def scan_records(row, level)

end

end
end
2 changes: 1 addition & 1 deletion lib/rowx.rb~
Expand Up @@ -78,4 +78,4 @@ class RowX

end

end
end
2 changes: 1 addition & 1 deletion rowx.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'rowx'
s.version = '0.4.0'
s.version = '0.4.1'
s.summary = 'rowx'
s.description = 'Generates XML from rows of labelled, nested, and plain text'
s.authors = ['James Robertson']
Expand Down

0 comments on commit 85632c2

Please sign in to comment.