Skip to content

Instantly share code, notes, and snippets.

@strn
Created September 6, 2020 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strn/f5c6d9c5242fdc9c49d09f21ecad1ffa to your computer and use it in GitHub Desktop.
Save strn/f5c6d9c5242fdc9c49d09f21ecad1ffa to your computer and use it in GitHub Desktop.
Convert TeX hyphenation file to KOreader form
#!/bin/bash
INFILE="$1"
cat <<EOF
<?xml version="1.0" encoding="utf8"?>
<!--
Taken and converted from:
-->
<HyphenationDescription>
EOF
while IFS='' read -r line || [[ -n "$line" ]]; do
# Skip comments and other TeX constructs
if [[ "${line}" =~ }.*|\\.*|%.* ]]; then
continue
fi
lnew=$(echo ${line} | sed -e 's#\.# #g;s#\-#5#g')
echo " <pattern>${lnew}</pattern>"
done < "${INFILE}"
echo "</HyphenationDescription>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment