Skip to content

Instantly share code, notes, and snippets.

@higuma
Last active August 26, 2022 02:40
Show Gist options
  • Save higuma/15de141310855a8f654792046dca5c50 to your computer and use it in GitHub Desktop.
Save higuma/15de141310855a8f654792046dca5c50 to your computer and use it in GitHub Desktop.
Backslash escapes in GitHub Markdown (source code)
# Render markdown-escapes.md
N_COL = 16
puts "# Backslash escapes in Markdown"
puts
puts "Backslash escape effects for all ASCII printable characters (→ [source](https://gist.github.com/higuma/15de141310855a8f654792046dca5c50))"
puts
puts "| U+ |" + (0...N_COL).inject('') {|row, col| row + sprintf(" %X |", col) }
puts (0..N_COL).inject('|') {|row, _| row + ' :-: |' }
printables = (0x20..0x7E).to_a
until printables.empty?
chars = printables.shift(N_COL)
puts sprintf("| %04X |", chars[0]) +
chars.inject('') {|row, c| row + sprintf(" `` \\%s ``&NoBreak;<br>\\%s |", c.chr, c.chr) }
end
# Result -> https://gist.github.com/higuma/8bab4e3f79105907797cdfe243f19033
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment