Last active
August 26, 2022 02:40
-
-
Save higuma/15de141310855a8f654792046dca5c50 to your computer and use it in GitHub Desktop.
Backslash escapes in GitHub Markdown (source code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 ``⁠<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