Reworking slug generation to handle accents.

This commit is contained in:
D. Moonfire 2018-03-09 21:30:04 -06:00
parent 8e1ba52e51
commit cbed3d55f3

View file

@ -34,7 +34,7 @@ my $BUILD_DIR = "$REPO_DIR/build";
# makes assumptions of all the relative paths and outputs.
my $DICT_MARKDOWN = "$BUILD_DIR/index.markdown";
my $DICT_DIR = "$REPO_DIR/src/dictionary";
# Make sure the build directory exists.
unless (-d $BUILD_DIR)
{
@ -78,7 +78,7 @@ for my $s (sort(glob("$DICT_DIR/*")))
# Write out the entry.
print STDERR "Processing: $bs ($w entries)\n";
print $DICT "# $bs\n\n";
print $SYB "---\ntitle: Miwāfu Dictionary - $bs\nbreadcrumbTitle: $bs\n---\n\n# $bs\n\n";
# Go through each of these entries.
@ -171,7 +171,12 @@ sub process_word
{
# Start by formatting the word.
my $slug = $word;
$slug =~ tr/[aeiouáéíóúàèìòùāēīōū]/[aeiouaeiouaeiou]/;
$slug =~ s/[áàā]/a/g;
$slug =~ s/[éèē]/e/g;
$slug =~ s/[íìī]/i/g;
$slug =~ s/[óòō]/o/g;
$slug =~ s/[úùū]/u/g;
print $DICT "[$word]($bs/$slug$EXT):";
print $SYB "[$word]($slug$EXT):";