#Japt, 182 179 bytes
Japt is a shortened version of JavaScript. InterpreterInterpreter
Ur'.+".?"pV-1 ,@A++%2?SpV-Xl)+Xw m@"„\xA1⅋,'˙¿∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Z[\\]^‾`ɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz"g(Q+"!&',.?"+65o124 m@Xd)a)bX)||X +R:X+R ###How it works
// Implicit: U = input string, V = input number, A = 10 Ur // Take U and replace each group X of: '.+".?"pV-1 // at least one char, followed by up to V-1 other chars // literally: RegExp("." + ".?".repeat(V-1)) @ // with: (@ is compiled to (X,Y,Z)=>) A++%2? // If we're on an odd row: SpV-Xl)+ // Pad it with spaces, then concatenate it with Xw m@ // X reversed, with each character X mapped to: "..."g // The character at position N in the string, where N is: (Q+"!&',.?" // Build a string from a quote mark and these chars, 65o124 m@Xd)a) // and all chars from A..z. bX) // Return the index of X in this string. ||X // or if this number is outside the string, default to the original char. +R // Either way, add a newline. :X+R // Otherwise, return the original row text plus a newline. // Implicit: output last expression There are a couple of problems, but they shouldn't affect the validity of the program:
- User @Vɪʜᴀɴ@Vɪʜᴀɴ has recently helped me implement Unicode Shortcuts, or single characters in the range 00A1-00FF that stand in for commonly-used several-char sequences. The problem with this is that it currently replaces inside strings, so we can't use ¡ directly in the string for now. The safe alternative,
\xA1, is three bytes longer. - It's currently impossible to input a double-quote character. This will be fixed shortly.
Perhaps there's a way to shorten the string. Suggestions are welcome!