call.respondText(TylanAlphabet.tylanToFontAlphabet(call.receiveText()))
}
+ post("/pokhwal-lang") {
+ call.respondText(PokhwalishAlphabet.pokhwalToFontAlphabet(call.receiveText()))
+ }
+
post("/preview-comment") {
call.respondText(
text = TextParserState.parseText(call.receiveText(), TextParserCommentTags.asTags, Unit),
--- /dev/null
+package info.mechyrdia.lore
+
+object TylanAlphabet {
+ private val allowedTranslitCharacters = setOf(
+ ' ', '\r', '\n', '\t',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'y',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '~', '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+',
+ '[', '{', '}', ']', '\\', '|', '/', '<',
+ '.', ',', ':', ';', '\'', '"', '?', '>',
+ )
+
+ private val replacements = listOf(
+ Regex("([0-9xy]+)(?![\\s0-9xy])") to "$1 ",
+ Regex("(?<![\\s0-9xy])([0-9xy]+)") to " $1",
+
+ Regex("([a-pr-v'])m(?![\\w'])") to "$1A",
+ Regex("([a-pr-v'])n(?![\\w'])") to "$1E",
+ Regex("([a-ps-v'])r(?![\\w'])") to "$1H",
+ Regex("([ac-fh-jl-or-v'])s(?![\\w'])") to "$1I",
+ Regex("([a-pr-v'])t(?![\\w'])") to "$1Q",
+
+ Regex("x") to "M",
+ Regex("y") to "N",
+ Regex("[qw-z]") to "",
+
+ Regex("ch") to "C",
+ Regex("dh") to "D",
+ Regex("sh") to "S",
+ Regex("th") to "T",
+
+ Regex("bs") to "B",
+ Regex("gs") to "G",
+ Regex("ks") to "K",
+ Regex("ps") to "P",
+
+ Regex("b'([Is])") to "b$1",
+ Regex("g'([Is])") to "g$1",
+ Regex("k'([Is])") to "k$1",
+ Regex("p'([Is])") to "p$1",
+
+ Regex("ff") to "F",
+ Regex("fv") to "V",
+ Regex("hj") to "J",
+ Regex("lh") to "L",
+ Regex("ll") to "L",
+ Regex("hl") to "L",
+ Regex("rh") to "R",
+ Regex("rr") to "R",
+ Regex("hr") to "R",
+ Regex("d'h") to "dh",
+ Regex("l'h") to "lh",
+ Regex("l'J") to "lJ",
+ Regex("r'h") to "rh",
+ Regex("r'J") to "rJ",
+ Regex("s'h") to "sh",
+ Regex("t'h") to "th",
+ Regex("h'l") to "hl",
+ Regex("h'r") to "hr",
+ Regex("B'h") to "Bh",
+ Regex("G'h") to "Gh",
+ Regex("K'h") to "Kh",
+ Regex("P'h") to "Ph",
+ Regex("c(?!h)") to "",
+
+ Regex("ae") to "W",
+ Regex("au") to "X",
+ Regex("ea") to "Y",
+ Regex("ei") to "Z",
+ Regex("eo") to "w",
+ Regex("eu") to "x",
+ Regex("oa") to "y",
+ Regex("ou") to "z",
+ Regex("oe") to "O",
+ Regex("ui") to "U",
+
+ Regex("i([aeiouOUw-zW-Z])") to "ij$1",
+ Regex("^([aeiouOUw-zW-Z])") to "'$1",
+ Regex("([^'BCDFGJKLPR-TVbdf-hj-npr-tv])([aeiouOUw-zW-Z])") to "$1'$2",
+ Regex("([aeiouOUw-zW-Z])([aeiouOUw-zW-Z])") to "$1'$2",
+ )
+
+ fun tylanToFontAlphabet(tylan: String) = replacements.fold(tylan.lowercase().filter { it in allowedTranslitCharacters }) { partial, (regex, replacement) ->
+ partial.replace(regex, replacement)
+ }
+}
+
+object PokhwalishAlphabet {
+ private val allowedTranslitCharacters = setOf(
+ ' ', '\r', '\n', '\t',
+ 'a', 'b', 'c', 'd', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'y', 'z',
+ '.', ',', '\'', '?', '!',
+ )
+
+ private val replacements = listOf(
+ // Vowels
+ Regex("aa") to "A",
+ Regex("ae") to "A",
+ Regex("ee") to "E",
+ Regex("ei") to "E",
+ Regex("ey") to "E",
+ Regex("ie") to "I",
+ Regex("ii") to "I",
+ Regex("iy") to "I",
+ Regex("ao") to "O",
+ Regex("au") to "O",
+ Regex("oo") to "O",
+ Regex("ou") to "U",
+ Regex("uu") to "U",
+ // Consonants
+ Regex("tz") to "C",
+ Regex("hh") to "K",
+ Regex("kh") to "K",
+ Regex("gh") to "G",
+ Regex("ng(?![aeiouAEIOU])") to "N",
+ Regex("n'g") to "ng",
+ Regex("qh") to "Q",
+ Regex("th") to "T",
+
+ Regex("ck") to "q",
+ Regex("k") to "q",
+ )
+
+ fun pokhwalToFontAlphabet(pokhwal: String) = replacements.fold(pokhwal.lowercase().filter { it in allowedTranslitCharacters }) { partial, (regex, replacement) ->
+ partial.replace(regex, replacement)
+ }
+}
"<span class=\"lang-tylan\">$recensored</span>"
} else if (tagParam?.equals("thedish", ignoreCase = true) == true)
"<span class=\"lang-thedish\">$content</span>"
- else if (tagParam?.equals("gothic", ignoreCase = true) == true)
+ else if (tagParam?.equals("pokhval", ignoreCase = true) == true || tagParam?.equals("pokhwal", ignoreCase = true) == true) {
+ val uncensored = TextParserState.uncensorText(content)
+ val pokhwal = PokhwalishAlphabet.pokhwalToFontAlphabet(uncensored)
+ val recensored = TextParserState.censorText(pokhwal)
+ "<span class=\"lang-pokhwal\">$recensored</span>"
+ } else if (tagParam?.equals("gothic", ignoreCase = true) == true)
"<span class=\"lang-gothic\">$content</span>"
else content
}
|<textarea class="output-box lang-thedish" readonly></textarea>
|</div>
""".trimMargin()
- } else content
+ } else if (content.equals("pokhval", ignoreCase = true) || content.equals("pokhwal", ignoreCase = true)) {
+ """
+ |<div class="pokhwal-alphabet-box">
+ |<p>Latin Alphabet:</p>
+ |<textarea class="input-box" spellcheck="false"></textarea>
+ |<p>Pokhwalish Alphabet:</p>
+ |<textarea class="output-box lang-pokhwal" readonly></textarea>
+ |</div>
+ """.trimMargin()
+ } else ""
}
),
;
+++ /dev/null
-package info.mechyrdia.lore
-
-object TylanAlphabet {
- private val allowedTranslitCharacters = setOf(
- ' ', '\r', '\n', '\t',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'y',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- '~', '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+',
- '[', '{', '}', ']', '\\', '|', '/', '<',
- '.', ',', ':', ';', '\'', '"', '?', '>',
- )
-
- private val replacements = listOf(
- Regex("([0-9xy]+)(?![\\s0-9xy])") to "$1 ",
- Regex("(?<![\\s0-9xy])([0-9xy]+)") to " $1",
-
- Regex("([a-pr-v'])m(?![\\w'])") to "$1A",
- Regex("([a-pr-v'])n(?![\\w'])") to "$1E",
- Regex("([a-ps-v'])r(?![\\w'])") to "$1H",
- Regex("([ac-fh-jl-or-v'])s(?![\\w'])") to "$1I",
- Regex("([a-pr-v'])t(?![\\w'])") to "$1Q",
-
- Regex("x") to "M",
- Regex("y") to "N",
- Regex("[qw-z]") to "",
-
- Regex("ch") to "C",
- Regex("dh") to "D",
- Regex("sh") to "S",
- Regex("th") to "T",
-
- Regex("bs") to "B",
- Regex("gs") to "G",
- Regex("ks") to "K",
- Regex("ps") to "P",
-
- Regex("b'([Is])") to "b$1",
- Regex("g'([Is])") to "g$1",
- Regex("k'([Is])") to "k$1",
- Regex("p'([Is])") to "p$1",
-
- Regex("ff") to "F",
- Regex("fv") to "V",
- Regex("hj") to "J",
- Regex("lh") to "L",
- Regex("ll") to "L",
- Regex("hl") to "L",
- Regex("rh") to "R",
- Regex("rr") to "R",
- Regex("hr") to "R",
- Regex("d'h") to "dh",
- Regex("l'h") to "lh",
- Regex("l'J") to "lJ",
- Regex("r'h") to "rh",
- Regex("r'J") to "rJ",
- Regex("s'h") to "sh",
- Regex("t'h") to "th",
- Regex("h'l") to "hl",
- Regex("h'r") to "hr",
- Regex("B'h") to "Bh",
- Regex("G'h") to "Gh",
- Regex("K'h") to "Kh",
- Regex("P'h") to "Ph",
- Regex("c(?!h)") to "",
-
- Regex("ae") to "W",
- Regex("au") to "X",
- Regex("ea") to "Y",
- Regex("ei") to "Z",
- Regex("eo") to "w",
- Regex("eu") to "x",
- Regex("oa") to "y",
- Regex("ou") to "z",
- Regex("oe") to "O",
- Regex("ui") to "U",
-
- Regex("i([aeiouOUw-zW-Z])") to "ij$1",
- Regex("^([aeiouOUw-zW-Z])") to "'$1",
- Regex("([^'BCDFGJKLPR-TVbdf-hj-npr-tv])([aeiouOUw-zW-Z])") to "$1'$2",
- Regex("([aeiouOUw-zW-Z])([aeiouOUw-zW-Z])") to "$1'$2",
- )
-
- fun tylanToFontAlphabet(tylan: String) = replacements.fold(tylan.lowercase().filter { it in allowedTranslitCharacters }) { partial, (regex, replacement) ->
- partial.replace(regex, replacement)
- }
-}
}
});
+ window.addEventListener("load", function () {
+ // Pokhwalish alphabet
+ async function pokhwalToFont(input, output) {
+ const inText = input.value;
+ const outText = await (await fetch('/pokhwal-lang', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'text/plain',
+ },
+ body: inText,
+ })).text();
+
+ if (inText === input.value)
+ output.value = outText;
+ }
+
+ const pokhwalAlphabetBoxes = document.getElementsByClassName("pokhwal-alphabet-box");
+ for (const pokhwalAlphabetBox of pokhwalAlphabetBoxes) {
+ const inputBox = pokhwalAlphabetBox.getElementsByClassName("input-box")[0];
+ const outputBox = pokhwalAlphabetBox.getElementsByClassName("output-box")[0];
+
+ inputBox.addEventListener("input", () => pokhwalToFont(inputBox, outputBox));
+ }
+ });
+
window.addEventListener("load", function () {
// Preview themes
const themeChoices = document.getElementsByName("theme");
line-height: 1.0;
}
+@font-face {
+ font-family: 'Pochvalsk';
+ src: url(/static/font/pokhval-alphabet.woff) format('woff');
+}
+
+.lang-pokhwal {
+ font-family: Pochvalsk, monospace;
+ font-size: 1em;
+ line-height: 1.0;
+ font-variant: normal !important;
+}
+
+textarea.lang-pokhwal {
+ font-family: Pochvalsk, monospace;
+ font-size: 2em;
+ line-height: 1.0;
+}
+
#thumb-view {
display: none;
}