# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Here are some translation tables to produce HTML encoded chars:
%Humlaut = (
	'A' => '&Auml;', 'a' => '&auml;',
	'E' => '&Euml;', 'e' => '&euml;',
	'I' => '&Iuml;', 'i' => '&iuml;',
	'Q' => '&Ouml;', 'o' => '&ouml;',
	'U' => '&Uuml;', 'u' => '&uuml;',
);
%Hacute = (
	'A' => '&Aacute;', 'a' => '&aacute;',
	'E' => '&Eacute;', 'e' => 'é',
	'I' => '&Iacute;', 'i' => '&iacute;',
	'Q' => '&Oacute;', 'o' => '&oacute;',
	'U' => '&Uacute;', 'u' => '&uacute;',
);
%Hgrave = (
	'A' => '&Agrave;', 'a' => '&agrave;',
	'E' => '&Egrave;', 'e' => '&egrave;',
	'I' => '&Igrave;', 'i' => '&igrave;',
	'Q' => '&Ograve;', 'o' => '&ograve;',
	'U' => '&Ugrave;', 'u' => '&ugrave;',
);
%Hcircum = (
	'A' => '&Acirc;', 'a' => '&acirc;',
	'E' => '&Ecirc;', 'e' => '&ecirc;',
	'I' => '&Icirc;', 'i' => '&icirc;',
	'Q' => '&Ocirc;', 'o' => '&ocirc;',
	'U' => '&Ucirc;', 'u' => '&ucirc;',
);
%Hcomma = (
	'C' => 'Ç', 'c' => 'ç',
	'S' => 'Ş', 's' => 'ş',
	'T' => 'Ţ', 't' => 'ţ',
);
%Hklicka = (
	'C' => 'Č', 'c' => 'č',
	'S' => 'Š', 's' => 'š',
);
%Hring = (
	'A' => '&Aring;', 'a' => '&aring;',
);
%Hslash = (
	'C' => '&Ccedil;', 'c' => '&ccedil;',
	'O' => '&Oslash;', 'o' => '&oslash;',
);

sub abc2html {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Convert all the escape sequences in an ABC string to their HTML  encodings.
# This is only done to title strings at present.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
	local($s) = @_;
	$s =~ s#(\\)(["'`^])([aceiou])#&htmlenc($1,$2,$3)#ieg;	# Marked vowels.
	$s =~ s#(\\)([col])#&htmlenc($1,'/',$2)#ieg;	# C-cedille and o-slash.
	$s =~ s#(\\)(a)(a)#&htmlenc($1,$2,$3)#ieg;		# Scand \aa notation.
	$s =~ s#(\\)(,)([cst])#&htmlenc($1,$2,$3)#ieg;	# French/Romanian \,[cst] notation.
	$s =~ s#(\\)(v)([cs])#&htmlenc($1,$2,$3)#ieg;	# Slavic \v[cs] notation.
#	$s =~ s#([aeiou])/#&htmlenc('',"'",$1)#ieg;		# Gaelic V/ notation.
	return $s;
}

sub htmlenc {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Convert one escape sequence to its corresponging HTML encoding. If we can't
# identify it, we return the original string.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
	local(
		$c1,	# Escape char, used only when we fail.
		$c2,	# The mark char, used to select a translate table.
		$c3)	# The char to mark, used to select a table entry..
		= @_;
	return($Humlaut{$c3} || "$c1$c2$c3") if ($c2 eq '"');
	return($Hacute {$c3} || "$c1$c2$c3") if ($c2 eq "'");
	return($Hgrave {$c3} || "$c1$c2$c3") if ($c2 eq '`');
	return($Hcircum{$c3} || "$c1$c2$c3") if ($c2 eq '^');
	return($Hcomma {$c3} || "$c1$c2$c3") if ($c2 eq ',');
	return($Hklicka{$c3} || "$c1$c2$c3") if ($c2 eq 'v');
	return($Hring  {$c3} || "$c1$c2$c3") if ($c2 eq 'a' || $c2 eq 'A');
	return($Hslash {$c3} || "$c1$c2$c3") if ($c2 eq '/');
	return("$c1$c2$c3");
}

1;
