rsvp-reader/alt-implementations/readifry-master/hyphenator/compressor.html

238 lines
38 KiB
HTML
Raw Normal View History

2019-12-08 09:19:55 +01:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Hyphenator.js &ndash; pattern compressor</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
body {
font: 11px/1.8em Verdana;
margin-left: 20%;
margin-right:20%;
background-color:#EEEEEE;
width:60em;
}
fieldset {
background-color:#FFFFFF;
border:1px solid #AAAAAA;
margin:1em 0em;
padding: 0em 1em 2em 1em;
}
h1 {
background-color:#FFFFFF;
border:1px solid #AAAAAA;
margin:1em 0em;
color: #404041;
text-align:right;
}
img {
vertical-align:middle;
}
.info_btn {
vertical-align:text-bottom;
cursor:pointer;
}
.info_box {
display:none;
border:1px dashed #AAAAAA;
padding:0.2em 1em;
font-style:italic;
}
.multicol {
text-align:justify;
width: 28em;
float:left;
margin:0em 1em;
}
ul.multicol {
width:21em;
padding:0;
margin:0;
}
li {
list-style:none;
}
form {
clear: both;
padding-top:2em;
}
legend {
border:1px solid #AAAAAA;
background-color:#FFFFFF;
padding:0em 1em;
font-style: italic;
font-weight: 200;
}
input {
margin-right:1em;
}
textarea {
width:100%;
}
.grayedout {
border: 1px solid grey;
color: grey;
}
#fields {
float: left;
margin-right: 10px;
}
#desc {
font-size: 12px;
}
</style>
<script type="text/javascript">
var oldpatterns, newpatterns, specialChars;
function lengthSort(a, b) {
return a.length - b.length;
}
function output2String() {
var tmp, len;
tmp = 'Hyphenator.languages[\'' + document.getElementsByName('language')[0].value + '\'] = {\n';
tmp += '\tleftmin : ' + document.getElementsByName('leftmin')[0].value + ',\n';
tmp += '\trightmin : ' + document.getElementsByName('rightmin')[0].value + ',\n';
tmp += '\tspecialChars : "' + specialChars + '",\n';
tmp += '\tpatterns : {\n';
for (len in newpatterns) {
if (newpatterns.hasOwnProperty(len)) {
tmp += '\t\t' + len + ' : "' + newpatterns[len] + '",\n';
}
}
tmp = tmp.slice(0, -2);
tmp += '\n\t}\n};';
document.getElementsByName('newpattern')[0].value = tmp;
}
function startConversion() {
var len, i, curlen, key, special, s;
newpatterns = {};
special = document.getElementsByName('oldpattern')[0].value.match(/[^a-z0-9\. ]/gi);
if (special) {
//Todo: Special vereinfachen...
s = {};
for (i = 0; i < special.length; i++) {
s[special[i]] = true;
}
special = '';
for (i in s) {
if (s.hasOwnProperty(i)) {
special += i;
}
}
} else {
special = '';
}
specialChars = special;
oldpatterns = document.getElementsByName('oldpattern')[0].value.replace(/ $/, '').split(' ');
oldpatterns.sort(lengthSort);
len = oldpatterns.length;
for (i = 0; i < len; i++) {
key = oldpatterns[i].replace(/\d/g, '');
curlen = oldpatterns[i].length;
if (curlen in newpatterns) {
newpatterns[curlen] += oldpatterns[i].replace(/\./g, '_');
} else {
newpatterns[curlen] = oldpatterns[i].replace(/\./g, '_');
}
}
output2String();
}
window.onload = function () {
var desc = document.getElementById('desc');
document.getElementsByName('language')[0].onfocus = function () {
if (this.value === 'language') {
this.value = '';
}
desc.innerHTML = "<em>Define language:</em><br>Use the <a href='http://www.loc.gov/standards/iso639-2/php/code_list.php'>ISO 639-1</a> two-letter language code.<br>(e.g. 'en' for english.)";
};
document.getElementsByName('language')[0].onblur = function () {
if (this.value === '') {
this.value = 'language';
}
desc.innerHTML = "";
};
document.getElementsByName('leftmin')[0].onfocus = function () {
if (this.value === 'leftmin') {
this.value = '';
}
desc.innerHTML = "<em>Define leftmin:</em><br>Define how many letters at minimum should stay on the old line upon hyphenation.<br>(e.g.: setting this to 3 would prevent 'Hy-phenation')";
};
document.getElementsByName('leftmin')[0].onblur = function () {
if (this.value === '') {
this.value = 'leftmin';
}
desc.innerHTML = "";
};
document.getElementsByName('rightmin')[0].onfocus = function () {
if (this.value === 'rightmin') {
this.value = '';
}
desc.innerHTML = "<em>Define rightmin:</em><br>Define how many letters at minimum should stay on the new line upon hyphenation.<br>(e.g.: setting this to 3 would prevent 'divid-ed')";
};
document.getElementsByName('rightmin')[0].onblur = function () {
if (this.value === '') {
this.value = 'rightmin';
}
desc.innerHTML = "";
};
document.getElementsByName('oldpattern')[0].onfocus = function () {
if (this.value === '.a5 .rt4 .d4gt2 asdf2 9kas3') {
this.value = '';
}
desc.innerHTML = "<em>Define oldpattern:</em><br>Paste the patterns you like to convert. They have to be separated by spaces, not newlines! Points (.) will be automatically replaced by underscores (_).<br>(e.g.: .ach4 .ad4der .af1t .al3t .am5at .an5c .ang4 .ani5m .ant4)";
};
document.getElementsByName('oldpattern')[0].onblur = function () {
if (this.value === '') {
this.value = '.a5 .rt4 .d4gt2 asdf2 9kas3';
}
desc.innerHTML = "";
};
document.getElementById('myform').onsubmit = function (e) {
if (e && e.preventDefault) {
e.preventDefault();
} else if (window.event) {
window.event.returnValue = false;
}
startConversion();
};
};
</script>
</head>
<body>
<h1>Compressor for <img src="data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%97%00%00%007%08%06%00%00%00%01%83%D8%97%00%00%00%04sBIT%08%08%08%08%7C%08d%88%00%00%20%00IDATx%9C%ED%9Dw%9C%5C%E5y%EF%BF%A7M%DF%99%DD%D9%5E%25%ED%AA%01%AA%88b%10H%60%3A%A2c%1B%DB8%D8%26%BE%F7b%9B8%8E%1D%DB%09.Ipn%9C%60%9B%C4%C4%80qI%AE%03%18%C7%A68%E0%98%18%89%22%89*P%EFeUv%A5%DD%D5%F6%E9s%E6%B4%FB%C7)sfv%85%A4%98%DB%3E%D7%EF%E73%9A%D9%99s%DE%F3%BE%CF%FB%BCO%F9%3D%CF%F3J%B0%2C%CB%E2%F7%ED%F7%ED%BDk%1E%3F%C9%A7t%B5e!%08%02.%1F%FA%F9Q%10%04%DF%95%02%FE%3F%FD%F7U%F3%B0%20%08%DEo%95%7D%FC%DF%D3%FE_%1F%FF%FF%E9%26%FC%5Er%9D%B8%95J%25%02%81%00%5B%B6le%F5%0B%ABI%26%93%D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F%90%CB%E6%90%24%C9Sk%96e%91%CB%E5%F8%F6%7D%DF%E1%DE%BF%FA%26%C5b%81h4J8%1Cf%C6%8C%19%9Cy%E6%19%CC%99%D3CSs%13%00%F5%F5%F5%A4R
<p class="multicol hyphenate">
Compressor converts standard TeX hyphenation patterns to a special format used by hyphenator.js and adds some meta-information automatically. Just fill in the language, leftmin, rightmin and the patterns (overwrite the examples!) and click 'Convert!'.</p>
<p class="multicol hyphenate">
Copy the output and paste it in the appropriate pattern file ('patterns/lang.js').<br>
The script loads the version of Hyphenator.js that resides in the same directory as this page.
</p>
<form action="#outanchor" method="post" id="myform">
<fieldset>
<legend>Paste TeX-styled patterns:</legend>
<p id="fields">
<input type="text" name="language" value="language"><br>
<input type="text" name="leftmin" value="leftmin"><br>
<input type="text" name="rightmin" value="rightmin">
</p>
<p id="desc"></p>
<textarea name="oldpattern" cols="80" rows="20">.a5 .rt4 .d4gt2 asdf2 9kas3</textarea>
<input type="submit" value="Convert!"><input type="reset" value="Reset">
</fieldset>
<fieldset>
<legend>Copy Hyphenator.js pattern files:</legend>
<p>Copy the output and paste it in the appropriate pattern file ('patterns/&lt;lang&gt;.js').</p>
<textarea name="newpattern" cols="80" rows="20"></textarea>
</fieldset>
</form>
</body>
</html>