Skip to content

Instantly share code, notes, and snippets.

@reitzig
Created February 6, 2018 13:13
Show Gist options
  • Save reitzig/5b7bf7934b827594273850bdfa6a1d32 to your computer and use it in GitHub Desktop.
Save reitzig/5b7bf7934b827594273850bdfa6a1d32 to your computer and use it in GitHub Desktop.
Transforms a (long) string into a Swift multi-line string literal
#!/usr/bin/ruby
if ARGV.count < 2
puts "Usage: swift-mlsl.rb line-length string"
Process.exit(0)
end
blocksize = ARGV[0].to_i
parts = ARGV[1].scan(/.{1,#{blocksize}}/)
puts "\"\"\"\n" + parts.join("\\\n") + "\n\"\"\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment