Games:...:Sgf2Dg(3pm)
β¨ Games::Go::Sgf2Dg β¨
okay so bestie, welcome to the manual page for Games::Go::Sgf2Dg β it's a Perl module that lives in the User Contributed Perl Documentation section (that's the 3pm vibe, iykyk). no cap, this thing is iconic.
π NAME π
Games::Go::Sgf2Dg β convert Smart Go Format (SGF) files to diagrams similar to those seen in Go books and magazines. it's giving "glow up your go game into actual art," fr fr. π
πΈ SYNOPSIS πΈ
sgf2dg [ option ... ] file[.sgf|.mgt]
π¦ DESCRIPTION π¦
Games::Go::Sgf2Dg takes a Smart Go Format (SGF) file β you can give it as filename, filename.sgf, or filename.mgt β and it produces a diagram file called filename.suffix, where the suffix is determined by whichever converter you're using (more on that below, bestie, don't worry π
).
Games::Go::Sgf2Dg modualizes the sgf2dg script. as such, it parses the command line (@ARGV) directly, and it has only one callable method: run. you call it like this (the sgf2dg script does exactly this):
Games::Go::Sgf2Dg->run;
the default converter is Dg2TeX, which converts the Diagram to TeX source code (fun fact: sgf2dg is a superset replacement for the sgf2tex script and package). if you have the GOOE fonts (they're provided in the same package as sgf2dg) correctly installed on your system, you'll be able to tex filename.tex to produce a .dvi file. and yes bestie, you can of course embed all or parts of filename.tex into other TeX documents. slay. β¨
π OPTIONS π
-h|-helpβ print a help message and quit. simple as that, periodt.-i|-in<filename> | <filename>.sgf | <filename>.mgt β specifies the input filename. (STDINor none for standard input.) this option is not needed in ordinary use, ngl.-o|-out<filename> β specifies the output file. ('STDOUT'for standard output.) if the input file is <filename>, <filename>.sgf or <filename>.mgt, then <filename>.converter is the default (see the converter option). this option is not needed in ordinary usage.-t|-top<top line number> β specifies the top line to print. default is1.-b|-bottom<bottom line number> β specifies the bottom line to print. default is19.-l|-left<left line number> β specifies the leftmost line to print. default is1.-r|-right<right line number> β specifies the rightmost line to print. default is19.-break|-breakList<break list> β break list is a list of moves, separated by comma, with no spaces. these are breakpoints: each will be the last move in one diagram.-m|-movesPerDiagram<moves per diagram> β moves per diagram is a positive integer, specifying the maximal number of moves per diagram. default is50unless-breakor-breakListis set, in which case the default is set to a very large number (10,000). the two options-breakListand-movesPerDiagrammay be used together. π-n|-newNumbersβ begin each diagram with the number1. the actual move numbers are still used in the label.-newNumbersand-doubleDigitsare alternative schemes for avoiding three-digit numbers in the diagrams. they should probably not be used together, bestie β pick one. π-d|-doubleDigitsβ if the first move of a diagram exceeds100, the move number is reduced modulo100. the actual move numbers are still used in the label.-newNumbersand-doubleDigitsare alternative schemes for avoiding three-digit numbers in the diagrams. they should probably not be used together.-rl|-repeatLastβ the last move in each diagram is the first move in the next. this emulates a common style for annotating Go games. so iconic. π-ic|-ignoreCommentsβ comments embedded in the SGF with theCproperty are ignored.-il|-ignoreLettersβ letters embedded in the SGF with theLorLBproperty are ignored.-im|-ignoreMarksβ marks embedded in the SGF with theMorMAproperty are ignored.-ip|-ignorePassβ passes are ignored. in sgf, a pass is a move at the fictitious pointtt. without this option,sgf2dgindicates passes in the diagram comments.-ia|-ignore allβ ignore SGF letters, marks, variations and passes. the "leave me alone" option fr.-firstDiagram<diagram number> β specifies the first diagram to print. default is1.-lastDiagram<diagram number> β specifies the last diagram to print. default is to print all diagrams until the end.-coordsβ adds coordinates to right and bottom edges.-verboseβ print diagnostic messages as the conversion proceeds. most SGF properties produce some kind of message. it's giving "spill the tea about every property."-converter|-convertβ selects different output converter plugins. converters available with the current distribution package are:Games::Go::Sgf2Dg::Dg2TeXβ TeX source (default)Games::Go::Sgf2Dg::Dg2Mpβ MetaPost embedded in TeXGames::Go::Sgf2Dg::Dg2ASCIIβ simple ASCII diagramsGames::Go::Sgf2Dg::Dg2PDFβ Portable Document Format (PDF)Games::Go::Sgf2Dg::Dg2Psβ PostScriptGames::Go::Sgf2Dg::Dg2Tkβ Perl/Tk NoteBook/CanvasGames::Go::Sgf2Dg::Dg2TkPsβ PostScript via Dg2Tk (Dg2Psis prefered)Games::Go::Sgf2Dg::Dg2SLβ Sensei's Library (by Marcel Gruenauer)
converters are quite easy to write β should take just a few hours if you are already conversant with the conversion target. if you would like to create a converter plugin module, the easiest way is probably to grab a copy of Dg2Ps.pm (for example) and modify it. once it's working, please be sure to send us a copy so we can add it to the distribution. we're rooting for you bestie π«Ά
converters are always prepended with 'Games::Go::Sgf2Dg::Dg2', so to select the ASCII converter instead of the default TeX converter, use:
-converter ASCII
converter names are case sensitive. no cap.
the default output filename suffix is determined by the converter: the converter name is lower-cased to become the suffix, so the ASCII converter produces <filename>.ascii from <filename>.sgf.
you can also select different converters by changing the name of the sgf2dg script (or better, make symbolic links, or copies if your system can't handle links). the converter name is extracted from the name with this regular expression:
m/sgf2(.*)/
anything after 'sgf2' is assumed to be the name of a converter module. for example, let's create a link to the script:
$ cd /usr/local/bin
$ ln -s sgf2dg sgf2Xyz
executing:
$ sgf2Xyz foo.sgf [ options ]
attempts to use Games::Go::Sgf2Dg::Dg2Xyz as the converter. the converter name extracted from the script name is case sensitive.
note that three extracted names are treated specially:
texdiagramdg
these three names (when extracted from the script name) always attempt to use Games::Go::Sgf2Dg::Dg2TeX as the converter. special treatment, main character energy. π
π CONVERTER OPTIONS π
converters may be added dynamically as plugins, so this list only includes converter plugin modules that are included with the Sgf2Dg distribution.
converter options are prepended with the converter name so that option xyz for converter Games::Go::Sgf2Dg::Dg2Abc is written on the command line as:
$ sgf2dg ... -Abc-xyz ...
converter options that take arguments must be quoted so that the shell passes the option and any arguments as a single ARGV. for example, if the xyz option for converter Dg2Abc takes 'foo' and 'bar' as additional arguments, the command line would be:
$ sgf2dg ... "-Abc-xyz foo bar" ...
or a more realistic example of changing the background color:
$ sgf2dg genan-shuwa -converter Tk "-Tk-bg #d2f1b4bc8c8b"
since Sgf2Dg is a super-set replacement for the Sgf2TeX package, TeX holds the default position for converters. because of this historically priviledged position, the Dg2TeX options below do not need to be prepended with 'TeX-'. all of the following options apply to the Dg2TeX converter.
other plugins available at the time of release are Dg2Mp, Dg2ASCII, Dg2PDF, Dg2Ps, Dg2Tk and Dg2TkPs. Dg2ASCII and Dg2TkPs take no additional options. Dg2Tk doesn't explicitly accept options, but it attempts to pass unrecognized options to the Tk::Canvas widgets at creation time (which is why the example above works).
for more information about converter-specific options, please refer to the perldoc or manual pages:
$ perldoc Games::Go::Sgf2Dg::Dg2PDF
or
$ man Games::Go::Sgf2Dg::Dg2Ps
πΈ Dg2TeX options πΈ
-simpleβ (Dg2TeX) this generates very simple TeX which may not look so good on the page, but is convenient if you intend to edit the TeX.-magnumber β (Dg2TeX) changes the default\\magnificationfrom1000to number.-twoColumnβ (Dg2TeX) this generates a two-column format using smaller fonts.-bigFontsβ (Dg2TeX) use fonts magnified1.2times.-texCommentsβ (Dg2TeX) if this option is NOT used then the characters{,}and\found in comments are replaced by[,]and/, since TeX roman fonts do not have these characters. if this option is used, these substitutions are not made, so you can embed TeX source (like{\bf change fonts}) directly inside the comments. it's giving "power user mode," bestie.-floatControl'control_string' β (Dg2TeX)Dg2TeXcan float the diagram to the left or the right of the accompanying text.-floatControlallows you to specify the position of each diagram. control_string is a sequence of letters which specify where each diagram should be positioned. the letters may be:'l': left'r': right'a': alternate- other: random
control_string letters are consumed, one per diagram, until there is only one letter left. the final letter is used for all remaining diagrams.
the default control_string is 'rx' which places the first diagram on the right (text on the left) and all remaining diagrams are placed randomly.
π SEE ALSO π
sgfsplit(1)β splits a.sgffile into its component variations
π«Ά AUTHOR π«Ά
sgf2dg was written by Reid Augustin, <reid@hellosix.com>
the GOOE fonts and TeX macros were designed by Daniel Bump (bump@math.stanford.edu). Daniel hosts the GOOE and sgf2dg home page at:
<http://match.stanford.edu/bump/go.html>
okay that's the whole page bestie, you're basically a sgf2dg expert now π this iconic piece of documentation was brought to you by perl v5.30.0, dated 2019-10-27. stay slay, stay converting, and remember β every Go diagram deserves main character energy. β¨π¦πΈ
π¦ 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