Games:...:Dg2TeX(3pm)
πΈ Games:...:Dg2TeX π
okay bestie, sit down, we're doing Perl POD in TeX and it's lowkey iconic β this is the manual page for Games:...:Dg2TeX from the User Contributed Perl Documentation, and yes, it's a real one, from perl v5.30.0, dated 2019-10-27. Buckle up π
β¨ NAME β¨
Games::Go::Sgf2Dg::Dg2TeX β it converts Games::Go::Sgf2Dg::Diagrams into TeX. That's it. That's the job. π
π¦ SYNOPSIS π¦
use Games::Go::Sgf2Dg::Dg2TeX
my $dg2tex = B<Games::Go::Sgf2Dg::Dg2TeX-E<gt>new> (options);
my $tex = $dg2tex->convertDiagram($diagram);
π DESCRIPTION π
A Games::Go::Sgf2Dg::Dg2TeX object takes a Games::Go::Sgf2Dg::Diagram object and turns it into TeX source code. And likeβ¦ you can use that TeX on its own, standing there serving looks all by itself, or you can tuck it inside bigger TeX documents. Either way, slay. β¨
π NEW π
my $dg2tex = Games::Go::Sgf2Dg::Dg2TeX->new (?options?)
A fresh Games::Go::D2TeX accepts these options, bestie:
boardSizeX => numberboardSizeY => numberβ sets how big the board is. π
Default: 19
doubleDigits => true | falseβ the numbers on the stones wrap back around to1once they hit100. Numbers that go with comments and diagram titles? Not affected, they're doing their own thing. π ββοΈ
Default: false
topLine => number(Default:1)bottomLine => number(Default:19)leftLine => number(Default:1)rightLine => number(Default:19) β these are the edges of the board that actually get shown. Anything on the board that reaches past these numbers just does not make it into the output. bye, not included, we don't know her πdiaCoords => sub { # convert $x, $y to Games::Go::Sgf2Dg::Diagram coordinates }β this callback lets you define a subroutine that converts coordinates from$x, $yinto whatever coordinate system yourGames::Go::Sgf2Dg::Diagramobject is using. The defaultdiaCoordsturns 1-based$x, $yinto the exact same coordinates used in SGF format files. You only need to define this if your Diagram is using a different coordinate system. πΊοΈ
Default:
sub { my ($x, $y) = @_;
$x = chr($x - 1 + ord('a')); # convert 1 to 'a', etc
$y = chr($y - 1 + ord('a'));
return("$x$y"); }, # concatenate two letters
psst β also go look at the diaCoords method further down. π
file => 'filename' | $descriptor | \$string | \@arrayβ iffileis defined, the TeX source gets dumped into the target. And the target can be literally any of these:filenameβ the filename gets opened withIO::File->new. The filename needs to include the'>'or'>>'operator, exactly like it says in'perldoc IO::File'. TeX source gets written into the file. πdescriptorβ a file descriptor as returned byIO::File->new, or a\*FILEdescriptor. TeX source gets written into the file.- reference to a string scalar β the TeX source gets concatenated onto the end of the string. π§΅
- reference to an array β the TeX source gets split on
"\n"and every single line gets pushed onto the array. π
Default: undef
print => sub { my ($dg2tex, @tex) = @_; ... }β a user-defined subroutine that replaces the default printing method. This callback gets called from theprintmethod (below) with a reference to theDg2TeXobject plus a list of lines that are part of the TeX diagram source. π¨οΈsimple => true | falseβ this generates very simple TeX. It might not look so good on the page, ngl, but it's convenient if you're planning to edit the TeX yourself. βοΈ
Default: false
twoColumn => true | falseβ this generates a two-column format using smaller fonts. This option forcessimpletrue. no warning, no negotiation, it just happens.
Default: false
coords => true | falseβ adds coordinates to the right and bottom edges. π§
Default: false
bigFonts => true | falseβ uses fonts magnified1.2times. Big font energy. π
Default: false
texComments => true | falseβ certain characters, when they show up in comments, normally get remapped like this:
\ => $\backslash$
{ => $\lbrace$
} => $\rbrace$
$ => \$
& => \&
# => \#
^ => $\wedge$
_ => \_
% => \%
~ => $\sim$
< => $<$
> => $>$
| => $|
(see the TeX Book page 38). But when texComments is specified, all those mappings get suppressed so you can embed normal TeX source directly inside the comments β like {\bf change fonts}. π¨
floatControl => controls which side diagrams will float onβfloatControlis a string that controls which side the diagrams float on. An'l'puts the diagram on the left side (text on the right),'r'puts the diagram on the right side,'a'alternates, and any other character places the diagram randomly. π² The first character is for the first diagram, the second character is for the second diagram, and so on. When there's only one character left, that character controls all the remaining diagrams.
floatControl is used only during 'normal' formatting. It is not used with the 'simple' or 'twoColumn' formats.
Default: 'rx' # first diagram on the right, all others are random
Default: 12
π Interactions between options
If twoColumn is true, simple is turned on (no warning). sneaky but true π
π§ METHODS π§
$dg2tex->configure (option => value, ?...?)β changeDg2TeXoptions from values that were passed at new time.my $coord = $dg2mp->diaCoords ($x, $y)β gives you access to thediaCoordsoption (see above). Returns coordinates in the converter's coordinate system for board coordinates($x, $y). So like, if you want a specific intersection structure:
my $int = $diagram->get($dg2mp->diaCoords(3, 4));
$dg2tex->print ($tex ? , ... ?)β prints raw TeX code to the file as defined at new time. Whether or notfilewas defined,printaccumulates the TeX code for later retrieval withconverted. ποΈmy $tex = $dg2tex->converted ($replacement_tex)β returns the TeX source code converted so far for theDg2TeXobject. If$replacement_texis defined, the accumulated TeX source code gets replaced by$replacement_tex. π$dg2tex->comment ($comment ? , ... ?)β inserts the TeX comment character ('%') in front of each line of each comment and prints it to file.my $tex_source = $dg2tex->convertDiagram ($diagram)β converts aGames::Go::Sgf2Dg::Diagraminto TeX. Iffilewas defined in the new method, the TeX source gets dumped into the file. And in any case, the TeX source is returned as a string scalar. πmy $tex = $dg2tex->convertText ($text)β converts$textinto TeX code by changing certain characters that aren't available in the TeXcmr10font, and by converting\n\ninto\hfil\break.convertTextbehavior gets modified by thetexCommentsandsimpleoptions.
Returns the converted text. π
$dg2tex->closeβ prints the TeX closer (\bye) and closes thedg2texobject. Also closesfileif appropriate. πͺ
π SEE ALSO π
sgf2dg(1)β script to convert SGF format files to Go diagrams. the classic π«Ά
π BUGS π
Nah. At least, I don't think so. Well, I hope not. π
and that's the whole page, bestie β this beauty shipped with perl v5.30.0 on 2019-10-27, from the User Contributed Perl Documentation, and it's still out here converting diagrams to TeX like the main character it is. mwah πβ¨
π¦ where this page comes from
- debian bookworm: sgf2dg 4.252-1
- debian trixie: sgf2dg 4.252-1
- ubuntu jammy: sgf2dg 4.252-1
- ubuntu noble: sgf2dg 4.252-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms