Games:...:Dg2TeX(3pm)

πŸ“¦
version 4.252 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

🌸 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 => number
  • boardSizeY => number β€” sets how big the board is. πŸ“

Default: 19

  • doubleDigits => true | false β€” the numbers on the stones wrap back around to 1 once they hit 100. 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, $y into whatever coordinate system your Games::Go::Sgf2Dg::Diagram object is using. The default diaCoords turns 1-based $x, $y into 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 β€” if file is defined, the TeX source gets dumped into the target. And the target can be literally any of these:
    • filename β€” the filename gets opened with IO::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 by IO::File->new, or a \*FILE descriptor. 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 the print method (below) with a reference to the Dg2TeX object 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 forces simple true. 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 magnified 1.2 times. 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 β€” floatControl is 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, ?...?) β€” change Dg2TeX options from values that were passed at new time.
  • my $coord = $dg2mp->diaCoords ($x, $y) β€” gives you access to the diaCoords option (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 not file was defined, print accumulates the TeX code for later retrieval with converted. πŸ—ƒοΈ
  • my $tex = $dg2tex->converted ($replacement_tex) β€” returns the TeX source code converted so far for the Dg2TeX object. If $replacement_tex is 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 a Games::Go::Sgf2Dg::Diagram into TeX. If file was 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 $text into TeX code by changing certain characters that aren't available in the TeX cmr10 font, and by converting \n\n into \hfil\break. convertText behavior gets modified by the texComments and simple options.

Returns the converted text. πŸ’Œ

  • $dg2tex->close β€” prints the TeX closer (\bye) and closes the dg2tex object. Also closes file if 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