Skip to content

Commit

Permalink
ms bing
Browse files Browse the repository at this point in the history
  • Loading branch information
phineas-pta committed Sep 8, 2023
1 parent a1b65ce commit 3160728
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
1 change: 1 addition & 0 deletions _includes/header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" /><!-- typical mobile-optimized site -->
<meta http-equiv="Permissions-Policy" content="interest-cohort=()" /><!-- because of Chrome vs GitHub Pages -->
<meta name="google-site-verification" content="vCTcDhJZfixdl9M1bHZeg1214kmgM14IGKdNmk4jGkU" /><!-- set up Google Search Console -->
<meta name="msvalidate.01" content="B3C8A36A4C9EF4C4BEA476E0D0EA0812" /><!-- set up Microsoft Bing Webmaster -->
<meta name="theme-color" content="#BF8F00" /><!-- for PWA -->
<link rel="manifest" href="{{ site.baseurl }}/site.webmanifest" /><!-- for PWA -->
<link rel="icon" href="{{ site.baseurl }}/assets/images/favicon.ico" />
Expand Down
1 change: 1 addition & 0 deletions _includes/kinhJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,6 @@ function replaceHTML(txt) { // don’t use document.write() coz doesn’t trigge
var htmlDoc = parser.parseFromString(txt, "text/html");
document.head.innerHTML = htmlDoc.head.innerHTML;
document.body.innerHTML = htmlDoc.body.innerHTML;
window.scrollTo(0, 0); // reset scroll position
window.onload(); // trigger rendering
}
31 changes: 14 additions & 17 deletions assets/aide_de_camp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# -*- coding: utf-8 -*-

"""stupid helper script"""
"""
stupid helper script
how to use:
from aide_de_camp import toSiddham, combo, verse_HanViet
while True: print(toSiddham(input("text IAST: ")), "\n")
while True: print(combo(input("text Hant: "), input("text Viet: "), printed=False), "\n")
while True: print(toSiddham(input("text IAST: ")), end="\n\n"); print(combo(input("text IAST: "), input("text Viet: "), printed=False), end="\n\n")
import pyperclip
pyperclip.copy(toSiddham(input("text IAST: ")))
"""

import re, os, html, json, requests
from unicodedata import normalize as uni_norm
Expand Down Expand Up @@ -30,6 +42,7 @@ def pali(textDeva: str, textLatn: str, esc: bool=True) -> str:
# API conversion multiple scripts
aksha_url = "https://aksharamukha-plugin.appspot.com/api/public"
aksha_reqdict = {"source": "IAST", "target": "Siddham"} # "IAST", "IPA", "ISO", "Devanagari"

def toSiddham_legacy(textIAST: str, ruby: bool=True, esc: bool=True) -> str:
"""convert romanized text to Siddham script"""
# some typo when copied from Digital Sanskrit Buddhist
Expand All @@ -55,8 +68,6 @@ def toSiddham(textIAST: str, ruby: bool=True, esc: bool=True) -> str:
else: res = textSidd
return res

# while True: print(toSiddham(input("text IAST: ")), "\n")

def stanzas(textIAST: str, esc: bool=True, printed: bool=True):
"""stanzas of Siddham"""
textSidd = toSiddham(textIAST, ruby=False)
Expand Down Expand Up @@ -120,8 +131,6 @@ def combo(textHan: str, textViet: str, esc: bool=True, printed: bool=True, debug
if printed: print(res)
else: return res

# while True: print(combo(input("text Hant: "), input("text Viet: "), printed=False), "\n")

def verse_HanViet(textHan: str, textViet: str, esc: bool=True, printed: bool=True, debug: bool=False) -> str:
"""combine text (multiple lines) into ruby annotation in HTML"""
text1, text2 = textHan.split("\n"), textViet.split("\n")
Expand All @@ -132,8 +141,6 @@ def verse_HanViet(textHan: str, textViet: str, esc: bool=True, printed: bool=Tru
if printed: print(res)
else: return res

# while True: print(toSiddham(input("text IAST: ")), end="\n\n"); print(combo(input("text IAST: "), input("text Viet: "), printed=False), end="\n\n")

# %% batch escape/unescape HTML & unicode entities

test_txt = "<ruby><rb>&#21335;</rb><rt>Nam</rt></ruby><ruby><rb>&#28961;</rb><rt>mô</rt></ruby>"
Expand All @@ -154,13 +161,3 @@ def unesc_han_fn(matchobj: re.Match) -> str:
return f"<rb>{x}</rb><!-- {y} -->"
han_ruby.sub(unesc_han_fn, test_txt) # example
unesc_han_sub = lambda txt: han_ruby.sub(unesc_han_fn, txt)

basepath = "pathtodir/DataFiles/"
for filename in os.listdir(basepath):
print(filename)
if filename.endswith(".html"):
my_file = basepath + "/" + filename
with open(my_file, mode="r", encoding="utf-8") as file:
tmp = file.readlines()
with open(my_file, mode="w", encoding="utf-8") as file:
file.writelines(map(unesc_han_sub, tmp)) # doesn't need list object

0 comments on commit 3160728

Please sign in to comment.