Last active
September 6, 2024 02:39
-
-
Save katrinafyi/198dfb98f7d16701dc8223c867aa7eef to your computer and use it in GitHub Desktop.
coqfix: replaces special symbols in copied coq html with original coq
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
var coqdocjs = coqdocjs || {}; | |
coqdocjs.repl = { | |
" ": "\u00A0", | |
"forall": "∀", | |
"exists": "∃", | |
"~": "¬", | |
"/\\": "∧", | |
"\\/": "∨", | |
"->": "→", | |
"<-": "←", | |
"<->": "↔", | |
"=>": "⇒", | |
"<>": "≠", | |
"<=": "≤", | |
">=": "≥", | |
"el": "∈", | |
"nel": "∉", | |
"<<=": "⊆", | |
"|-": "⊢", | |
">>": "»", | |
"<<": "⊆", | |
"++": "⧺", | |
"===": "≡", | |
"=/=": "≢", | |
"=~=": "≅", | |
"==>": "⟹", | |
"lhd": "⊲", | |
"rhd": "⊳", | |
"nat": "ℕ", | |
"alpha": "α", | |
"beta": "β", | |
"gamma": "γ", | |
"delta": "δ", | |
"epsilon": "ε", | |
"eta": "η", | |
"iota": "ι", | |
"kappa": "κ", | |
"lambda": "λ", | |
"mu": "μ", | |
"nu": "ν", | |
"omega": "ω", | |
"phi": "ϕ", | |
"pi": "π", | |
"psi": "ψ", | |
"rho": "ρ", | |
"sigma": "σ", | |
"tau": "τ", | |
"theta": "θ", | |
"xi": "ξ", | |
"zeta": "ζ", | |
"Delta": "Δ", | |
"Gamma": "Γ", | |
"Pi": "Π", | |
"Sigma": "Σ", | |
"Omega": "Ω", | |
"Xi": "Ξ" | |
}; | |
coqdocjs.subscr = { | |
"0" : "₀", | |
"1" : "₁", | |
"2" : "₂", | |
"3" : "₃", | |
"4" : "₄", | |
"5" : "₅", | |
"6" : "₆", | |
"7" : "₇", | |
"8" : "₈", | |
"9" : "₉", | |
}; | |
document.addEventListener('copy', (event) => { | |
const quote = function(str) { | |
return str.replace(/([.?*+^$[\]\\(){}-])/g, "\\$1"); | |
}; | |
let x = document.getSelection().toString(); | |
for (const [k,v] of Object.entries({...coqdocjs.repl, ...coqdocjs.subscr})) { | |
const re = new RegExp(quote(v),"g"); | |
x = x.replace(re, k); | |
} | |
event.clipboardData.setData('text/plain', x); | |
console.log(x); | |
event.preventDefault(); | |
}); |
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
javascript:(function()%7Bvar%20coqdocjs%20%3D%20coqdocjs%20%7C%7C%20%7B%7D%3Bcoqdocjs.repl%20%3D%20%7B%22%20%22%3A%20%22%5Cu00A0%22%2C%22forall%22%3A%20%22%E2%88%80%22%2C%22exists%22%3A%20%22%E2%88%83%22%2C%22~%22%3A%20%22%C2%AC%22%2C%22%2F%5C%5C%22%3A%20%22%E2%88%A7%22%2C%22%5C%5C%2F%22%3A%20%22%E2%88%A8%22%2C%22-%3E%22%3A%20%22%E2%86%92%22%2C%22%3C-%22%3A%20%22%E2%86%90%22%2C%22%3C-%3E%22%3A%20%22%E2%86%94%22%2C%22%3D%3E%22%3A%20%22%E2%87%92%22%2C%22%3C%3E%22%3A%20%22%E2%89%A0%22%2C%22%3C%3D%22%3A%20%22%E2%89%A4%22%2C%22%3E%3D%22%3A%20%22%E2%89%A5%22%2C%22el%22%3A%20%22%E2%88%88%22%2C%22nel%22%3A%20%22%E2%88%89%22%2C%22%3C%3C%3D%22%3A%20%22%E2%8A%86%22%2C%22%7C-%22%3A%20%22%E2%8A%A2%22%2C%22%3E%3E%22%3A%20%22%C2%BB%22%2C%22%3C%3C%22%3A%20%22%E2%8A%86%22%2C%22%2B%2B%22%3A%20%22%E2%A7%BA%22%2C%22%3D%3D%3D%22%3A%20%22%E2%89%A1%22%2C%22%3D%2F%3D%22%3A%20%22%E2%89%A2%22%2C%22%3D~%3D%22%3A%20%22%E2%89%85%22%2C%22%3D%3D%3E%22%3A%20%22%E2%9F%B9%22%2C%22lhd%22%3A%20%22%E2%8A%B2%22%2C%22rhd%22%3A%20%22%E2%8A%B3%22%2C%22nat%22%3A%20%22%E2%84%95%22%2C%22alpha%22%3A%20%22%CE%B1%22%2C%22beta%22%3A%20%22%CE%B2%22%2C%22gamma%22%3A%20%22%CE%B3%22%2C%22delta%22%3A%20%22%CE%B4%22%2C%22epsilon%22%3A%20%22%CE%B5%22%2C%22eta%22%3A%20%22%CE%B7%22%2C%22iota%22%3A%20%22%CE%B9%22%2C%22kappa%22%3A%20%22%CE%BA%22%2C%22lambda%22%3A%20%22%CE%BB%22%2C%22mu%22%3A%20%22%CE%BC%22%2C%22nu%22%3A%20%22%CE%BD%22%2C%22omega%22%3A%20%22%CF%89%22%2C%22phi%22%3A%20%22%CF%95%22%2C%22pi%22%3A%20%22%CF%80%22%2C%22psi%22%3A%20%22%CF%88%22%2C%22rho%22%3A%20%22%CF%81%22%2C%22sigma%22%3A%20%22%CF%83%22%2C%22tau%22%3A%20%22%CF%84%22%2C%22theta%22%3A%20%22%CE%B8%22%2C%22xi%22%3A%20%22%CE%BE%22%2C%22zeta%22%3A%20%22%CE%B6%22%2C%22Delta%22%3A%20%22%CE%94%22%2C%22Gamma%22%3A%20%22%CE%93%22%2C%22Pi%22%3A%20%22%CE%A0%22%2C%22Sigma%22%3A%20%22%CE%A3%22%2C%22Omega%22%3A%20%22%CE%A9%22%2C%22Xi%22%3A%20%22%CE%9E%22%7D%3Bcoqdocjs.subscr%20%3D%20%7B%220%22%20%3A%20%22%E2%82%80%22%2C%221%22%20%3A%20%22%E2%82%81%22%2C%222%22%20%3A%20%22%E2%82%82%22%2C%223%22%20%3A%20%22%E2%82%83%22%2C%224%22%20%3A%20%22%E2%82%84%22%2C%225%22%20%3A%20%22%E2%82%85%22%2C%226%22%20%3A%20%22%E2%82%86%22%2C%227%22%20%3A%20%22%E2%82%87%22%2C%228%22%20%3A%20%22%E2%82%88%22%2C%229%22%20%3A%20%22%E2%82%89%22%2C%7D%3Bdocument.addEventListener('copy'%2C%20(event)%20%3D%3E%20%7Bconst%20quote%20%3D%20function(str)%20%7Breturn%20str.replace(%2F(%5B.%3F*%2B%5E%24%5B%5C%5D%5C%5C()%7B%7D-%5D)%2Fg%2C%20%22%5C%5C%241%22)%3B%7D%3Blet%20x%20%3D%20document.getSelection().toString()%3Bfor%20(const%20%5Bk%2Cv%5D%20of%20Object.entries(%7B...coqdocjs.repl%2C%20...coqdocjs.subscr%7D))%20%7Bconst%20re%20%3D%20new%20RegExp(quote(v)%2C%22g%22)%3Bx%20%3D%20x.replace(re%2C%20k)%3B%7Devent.clipboardData.setData('text%2Fplain'%2C%20x)%3Bconsole.log(x)%3Bevent.preventDefault()%3B%7D)%7D)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment