From b39d03881169c389c87af4073eb8b45606176d21 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Thu, 16 Dec 2021 16:25:58 +0100 Subject: [PATCH] html: Apply appropriate "lang" attributes Primarily so that browsers can choose the correct font for CJK pages. --- www/index.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/www/index.pl b/www/index.pl index 2186f32..7dafaf6 100755 --- a/www/index.pl +++ b/www/index.pl @@ -195,7 +195,7 @@ sub framework_ { my $content = pop; my(%o) = @_; - html_ sub { + html_ lang => 'en', sub { head_ sub { link_ rel => 'stylesheet', type => 'text/css', href => '/man.css?5'; title_ $o{title}.' - manned.org'; @@ -630,7 +630,7 @@ TUWF::get qr{/([^/]+)/([0-9a-f]{8})/src} => sub { sub man_nav_ { - my($man, $toc) = @_; + my($man, $toc, $htmllang) = @_; my @systems = tuwf->dbAlli(' SELECT DISTINCT p.system @@ -713,7 +713,7 @@ sub man_nav_ { ul_ sub { for (0..$#$toc) { li_ sub { - a_ href => sprintf('#head%d', $_+1), lc $toc->[$_]; + a_ @$htmllang, href => sprintf('#head%d', $_+1), lc $toc->[$_]; } } } @@ -767,10 +767,11 @@ sub man_page { AND f.shorthash <> ', \shorthash_to_int($man->{shorthash}), ' LIMIT 1' ); + my @htmllang = $man->{locale} =~ /^([a-z]{2,3})(?:_([A-Z]{2}))?(?:$|@|\.)/ ? (lang => $1.($2?"-$2":'')) : (); tuwf->resLastMod($man->{released}); framework_ title => $man->{name}, mainclass => 'manpage', sub { - man_nav_ $man, \@toc; + man_nav_ $man, \@toc, \@htmllang; # TODO: Replace the 'versions' and 'locations' functionality with non-JS alternatives. div_ id => 'manbuttons', sub { h1_ $man->{name}; @@ -785,7 +786,7 @@ sub man_page { } }; div_ id => 'manres', class => 'hidden', ''; - pre_ sub { lit_ $fmt }; + pre_ @htmllang, sub { lit_ $fmt }; }; }