Skip to content

Commit e5d74ad

Browse files
committed
formatting and utf-8 directive
1 parent a264247 commit e5d74ad

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

original_repo/ja/convert_html.rb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#encoding: utf-8
12
# This script automatically converts the HTML pages
23
# of the Ruby Hacking Guide to the textile-based text
34
# format used for the translation.
@@ -31,7 +32,7 @@
3132
end
3233
end
3334
end
34-
35+
3536
# different types of list
3637
list_type = nil
3738
data.gsub!(/<(ul|ol|li)>/) do |m|
@@ -44,17 +45,17 @@
4445
end
4546

4647
[
47-
[ /.*?<body>(.*?)<\/body>.*/m, '\1' ], # we only want the body
48-
[ /<\/?(table|p( class=".+?")?)>|<\/(li|h\d|ol|ul)>/, '' ], # remove useless tags
49-
[ /▼/, '▼ ' ], # just add a space after the arrow
50-
[ /<h(\d)>/, 'h\1. ' ], # headers
51-
[ /<a href="(.+?)">(.+?)<\/a>/m, '"\2":\1' ], # images
52-
[ /<tr><td>|<td><td>|<td><\/tr>/, '|' ], # tables
53-
[ /<img src="(.+?)" alt=".+?"><br>\n\d+: (.*)/, '!\1(\2)!' ], # images and captions
54-
[ /[ \t]+$/, '' ], # trims line ends
55-
[ /\A\n+|\n+\Z/, '' ], # remove beginning and ending empty lines
56-
[ /\n\n+/, "\n\n" ], # succession of empty lines
57-
].each { |re, str| data.gsub!(re, str) }
58-
48+
[ /.*?<body>(.*?)<\/body>.*/m , '\1' ] , # we only want the body
49+
[ /<\/?(table|p( class=".+?")?)>|<\/(li|h\d|ol|ul)>/ , '' ] , # remove useless tags
50+
[ /▼/ , '▼ ' ] , # just add a space after the arrow
51+
[ /<h(\d)>/ , 'h\1. ' ] , # headers
52+
[ /<a href="(.+?)">(.+?)<\/a>/m , '"\2":\1' ] , # images
53+
[ /<tr><td>|<td><td>|<td><\/tr>/ , '|' ] , # tables
54+
[ /<img src="(.+?)" alt=".+?"><br>\n\d+: (.*)/ , '!\1(\2)!' ] , # images and captions
55+
[ /[ \t]+$/ , '' ] , # trims line ends
56+
[ /\A\n+|\n+\Z/ , '' ] , # remove beginning and ending empty lines
57+
[ /\n\n+/ , "\n\n" ] , # succession of empty lines
58+
].each { |re, str| data.gsub!(re , str) }
59+
5960
output.puts(data)
6061
end

0 commit comments

Comments
 (0)