-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerator.rb
More file actions
executable file
·28 lines (21 loc) · 897 Bytes
/
generator.rb
File metadata and controls
executable file
·28 lines (21 loc) · 897 Bytes
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
#!/usr/bin/env ruby
# This is a helper script that converts Android values into Markdown
require "nokogiri"
if ARGV.length != 1
STDERR.puts "Specify a file to process, like `./generator.rb strings.xml`"
exit(1)
end
strings = Nokogiri::XML(File.read("strings.xml")).css("string").map do |str|
[str[:name], str.children.to_s]
end.to_h
strings.select { |(k, _)| k.start_with?("section_") }.keys.each do |section|
puts "---\n\n## #{strings[section]}\n\n"
number = section.match(/\d+$/).to_s
section_titles = strings.select { |(k, _)| k.start_with?("fallacies_titles_#{number}_") }.keys
section_titles.each do |section_title|
number = section_title.match(/\d+_\d+$/).to_s
puts "### #{strings["fallacies_titles_#{number}"]}\n\n"
puts "#{strings["fallacies_descs_#{number}"]}\n\n"
puts "> #{strings["fallacies_examples_#{number}"]}\n\n"
end
end