Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:
I present today with a grab bag of problems, that I can demonstrate in some type of a short and closed example. I've gotten some form of reasonable output with my russian crosswords, but what should align does not yet. Let me show the page, and if you're at all interested in making this easier on the eyes, then click readmore. ataman is the page, and the project is on github at first russian xword
To fix this, I have to rewrite:
sub get_utf8_text { use 5.010; use HTML::FromText; use Path::Tiny; use utf8; use open OUT => ':utf8'; ### Passing in #reference to main data structure and directory for captions my ( $rvars, $dir ) = (@_); my %vars = %$rvars; say "dir is $dir"; opendir my $eh, $dir or warn "can't open dir for utf8 captions $!\n +"; while ( defined( $_ = readdir($eh) ) ) { next if m/~$/; next if -d; if (m/txt$/) { my $file = path( $dir, $_ ); my $guts = $file->slurp_utf8; my $temp = text2html( $guts, lines => 1, paras => 1, ); # surround by divs my $oitop = $vars{"oitop"}; my $oben = $oitop->slurp_utf8; my $oibottom = $vars{"oibottom"}; my $unten = $oibottom->slurp_utf8; my $text = $oben . $temp . $unten; say "text is $text"; $content{$_} = $text; } } closedir $eh; #important to sort my @return; foreach my $key ( sort keys %content ) { #print $content{$key} . "\n"; push @return, $content{$key}; } return \@return; }
I think I want to get away from HTML::FromText for this input, as I will have a reference to the array of array of at hand. I am not, however, certain that I'm not getting the exact representation I need, but that my .css is off.
Here is what the body looks like, both on STDOUT and when I view the page source:
<div class="outer"> <div class="hft-lines">л лесоп +30;рк<br /> о и о о е <br /> комар р й <br /> л б трасса<br /> ё к т б<br /> пасс ухо<br /> менеджер<br /> фауна раки<br /> тоска г<br /> шкант м е<br /> атаман<br /> в т т <br /> н ухаб<br /> игроки<br /> к грач<br /></div></div> <!-- end # +outer-->
The spaces aren't represented as any special html entity. Do they need to be?
Another thing I want to rewrite about this routine is:
# surround by divs my $oitop = $vars{"oitop"}; my $oben = $oitop->slurp_utf8; my $oibottom = $vars{"oibottom"}; my $unten = $oibottom->slurp_utf8; my $text = $oben . $temp . $unten;
All this does is wrap a string with two other strings I keep in template files:
$ cat oi*.txt <div class="outer"> </div> <!-- end #outer--> $
Isn't there an xml way to do this?
I won't want to dwell on it forever, but I will show the relevant .css in the original post:
.outer { background-color:white; margin-left : auto; margin-right : auto; border-radius : 1em; clear: left; margin-top: .7em; margin-bottom: .7em; max-width:25%; display:block; } .hft-lines { background-color:white; margin-left : auto; margin-right : auto; border-radius : 1em; clear: left; margin-top: .7em; margin-bottom: .7em; max-width:85%; display:block; text-align:center; font-size: 1.5em; }
I am by no means a .css guru, so there might be low-hanging fruit for improvements. The page does register as without .css error.
So let me review and try to ask a cohesive question. As the script runs, I have a perfectly rectangular representation of these data as indicated by Data::Dump. The question is how to get this row and column nature to show up properly. I would imagine that there's more than one way to do it.
And remember, if you have cross words, do crosswords instead....
Thanks all for comments,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: getting html characters to align
by Your Mother (Archbishop) on Mar 07, 2019 at 03:43 UTC | |
by Aldebaran (Curate) on Mar 09, 2019 at 02:11 UTC | |
by poj (Abbot) on Mar 09, 2019 at 10:19 UTC | |
by Anonymous Monk on Mar 09, 2019 at 13:42 UTC | |
by Aldebaran (Curate) on Mar 11, 2019 at 20:42 UTC | |
|
Re: getting html characters to align
by tangent (Parson) on Mar 07, 2019 at 02:44 UTC | |
|
Re: getting html characters to align
by holli (Abbot) on Mar 07, 2019 at 09:35 UTC |