Skip to content

Instantly share code, notes, and snippets.

@ikasoba
Last active October 27, 2023 02:04
Show Gist options
  • Save ikasoba/141ce7937caa279d23b7d90ee3faade3 to your computer and use it in GitHub Desktop.
Save ikasoba/141ce7937caa279d23b7d90ee3faade3 to your computer and use it in GitHub Desktop.
縦書きを横書きにするやつ、行はスペースで区切ること
a e k k
i o a u
u k k
i e
k
o
const translate = (text: string) => {
const res: string[] = [],
lines = text.split(/[\r\n]+/).map((x) => x.split(/ {1,2}/));
for (const line of lines) {
for (let i = 0; i < line.length; i++) {
res[i] = (res[i] ?? "") + line[i];
}
}
return res;
};
const script = await Deno.readTextFile(Deno.args[0]);
console.log(translate(script).join("\n"));
@ikasoba
Copy link
Author

ikasoba commented Oct 27, 2023

つかいた

deno install -n tate2yoko -A https://gist.githubusercontent.com/ikasoba/141ce7937caa279d23b7d90ee3faade3/raw/e911508c2ee3f20c303fae43d13404cb7636816b/tategaki.ts
$ tate2yoko ./example.txt
aiu
eo
kaki
kukeko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment