Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: getting html characters to align

by Your Mother (Archbishop)
on Mar 07, 2019 at 03:43 UTC ( [id://1230994]=note: print w/replies, xml ) Need Help??


in reply to getting html characters to align

An option; probably too heavy on the idiom but that’s why it’s fun; for me. :P There are a few others with modern CSS. This is fragmentary HTML—it should be loaded properly in a full page—but it's just for example and modern browsers don't care. <td></td> has caveats in older browsers and maybe IE still for all I know but I will never launch that without being paid. You can put a &nbsp; in it if necessary but using whitespace to control HTML layout is painful to even suggest. :P

#!/usr/bin/env perl
use 5.16.0;
use utf8;
use strictures;
use open ":std", ":encoding(utf8)";

print <<"";
<style>
table {
  border:0;
  border-collapse:collapse;
}
td {
  font-weight:700;
  text-align:center;
  line-height:200%;
  font-size: 150%;
  border:2px solid black;
  width:2em;
  height:2em
}
td.fill {
  background-color:black;
}
</style>

chomp( my @rows = <DATA> );

say "<table>";
for my $row ( @rows )
{
    say "  <tr>";
    for my $col ( split //, $row )
    {
        say $col =~ /\w/ ?
            "    <td>$col</td>"
            :
            "    <td class='fill'></td>";
    }
    say "  </tr>";
}
say "</table>";

__DATA__
л лесопарк
о и о о е
комар р й
л б трасса
ё  к   т б
пасс   ухо
  менеджер
фауна раки
  тоска  г
шкант м  е
    атаман
    в т т
    н ухаб
    игроки
    к грач

Replies are listed 'Best First'.
Re^2: getting html characters to align
by Aldebaran (Curate) on Mar 09, 2019 at 02:11 UTC
    using whitespace to control HTML layout is painful to even suggest

    Alright, I'm glad that's settled. Screenshot of output shows initial output. I'm really impressed with the style, thank you for writing it. The campaign continues between readmore tags:

    Thanks for your comments,

      #print $fh $$string; # ^^ print $fh $string;
      poj

      It seems like you are only missing <meta charset="UTF-8"> in the <head> part of your HTML. That is, take the HTML you currently generate, place it in <body>...</body> tags, then buryplace the body between <html>...</html>. Finally, add <head><meta charset="UTF-8"></head> before the body (but still inside html).

      Browsers tend to assume latin1 encoding when it hasn't been explicitly declared, so what you see is the result of decoding UTF-8-encoded text as Latin-1. Pages of your website have this tag, so they get decoded properly.

        This shows the latest version of this material. Discussion continues:

        Cheers,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1230994]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found