WP2X(1)
π WP2X(1) π
from the General Commands Manual, and she's lowkey a whole icon π«Ά
πΈ NAME πΈ
wp2x β A WordPerfect 5.0 to whatever converter
β¨ SYNOPSIS β¨
wp2x [ -s ] [ -v ] [ -nblip ] configfile wpfile
π¦ DESCRIPTION π¦
Okay bestie, so wp2x is literally intended to convert simple files stored in WordPerfect 5.1 format into any other document processing language that uses plain text files. It's giving TeX, LaTeX, troff, GML and HTML β the whole text-format friend group, no cap. π
For a quick result without manual configuration β and bestie, that's the main character energy move β you can try the following command to convert a WP file into HTML:
wp2x html foo.wp > foo.html
wp2x reads a configuration file and a WordPerfect 5.1 input file, and uses the information in them to produce an output file, which is sent to stdout. I'm obsessed with that. If the configuration file cannot be found, a suffix of .cfg is appended. The current directory is searched, as well as the lib directory specified by the WP2X_DIR variable in the Makefile (iykyk). (Usually /usr/local/lib/wp2x) and the directories specified by the environment variables PATH, DPATH, and WP2XLIB. π
Some codes are not translated because documents that require these codes typically would require significant hand-editing. Hence, there's no point in trying to emulate something you're going to delete anyway. fr fr. π
Remember, wp2x is not intended to be used as an automated conversion program. Rather, it is intended to be used as a single step in the document conversion process, which gets most of the the grunt work of conversion done and out of the way, so that you can concentrate your efforts on converting the trickier parts of the document. The object of the game is to produce a readable conversion, rather than a perfect conversion. periodt.
As the program runs, a dot is printed to stderr for every 1024 characters converted. This can be suppressed with the -s switch, and the interval between dots can be changed with the -n switch. β¨
π OPTIONS π
Vibe check: these options are giving control freak, but in the cutest way. π
-sβ ngl, it suppresses all non-error output tostderr, including the typeout banner, the progress dots, and warnings about undefined expansions.-nblipβ Every blip tokens, a dot is emitted tostderr, unless the-sswitch is given. The value blip must appear immediately following the-nwithout an intervening space. If no-nswitch is supplied, then a value of1024is assumed.-vβ prints the version number and the program usage.
π USAGE π
okay bestie so here's the tea: the configuration file is literally the main character that controls how the file gets converted from WordPerfect 5.1 format. every single line of that config file looks like this:
identifier="list of codes"
where that list of codes is a string that gets dropped into the output stream every time the matching WordPerfect code shows up. slay. standard C-style backslash-escape sequences are recognized, plus \xFF for hex values. and good news β you do not have to backslash-protect a newline. some identifiers hand you replaceable parameters, and you interpolate them like this:
%1β interpolate first parameter as a decimal integer. π―%2β interpolate second parameter as a decimal integer.%cβ interpolate first parameter as an ASCII character.%\nβ interpolate a newline if the most-recently-output character was not already a newline. (the\ncan be either the C-style escape sequence, or an actual newline character.) use this if the expansion must take place at the beginning of a line. (like, for example, troff control characters have to appear as the first character in the line in order to take effect, iykyk.) this sequence is meaningful only at the beginning of the string β if it shows up anywhere else, it's flagged as erroneous. π©%%β interpolate a percent-sign.
a percent sign followed by any other character? considered an error, periodt. and it's also an error to interpolate a parameter that isn't applicable to the identifier you're defining. but the fun part: you may interpolate the parameters as many times as you want, in whatever order you want. (with the one exception of the %\n code, bestie.)
here follows the list of accepted identifiers. in the discussion, %1 means the first parameter and %2 means the second. and remember that the character version of %1 is available as %c. π
BEGINβ Expanded at the beginning of the file.ENDβ Expanded at the end of the file.COMMENTβ Expanded whenwp2xneeds to insert a comment into the output. The comment is passed as%s.PageNoβ Insert current page numberRomanPageβ Set page number to%1, and set roman-numeral modeArabicPageβ Set page number to%1, and set arabic-numeral modeTabβ What to do when you see a tab character.BeginTabsβ Emitted when tab settings are about to change. TheBeginTabscode should delete all existing tabs and prepare for new tab settings to start. All tab values are given in columns measured from the physical left edge of the paper. (Not from the left margin.) πSetTabβ Set a normal (left-justified) tabstop at column%1.SetTabCenterβ Set a centered tabstop at column%1.SetTabRightβ Set a right-justified tabstop at column%1.SetTabDecimalβ Set a decimal tab at column%1.EndTabsβ Finish the setting of tabstops.
so for example, if the WordPerfect file contains a code that says Set new tabstops as follows: Regular tab at column 15, a centered tab at column 40, a right-justified tab at column 59, and a regular tab at column 60, then these expansions get made in succession:
BeginTabs
SetTab(15)
SetTabCenter(40)
SetTabright(59)
SetTab(60)
EndTabs
HSpaceβ Hard (nonbreakable) space.HPgβ Hard page break.CondEOPβ Force a new page if fewer than%1half-lines remain on current page.HRtβ Hard return.SRtβ Soft return.-β Breakable hyphen.--β Breakable hyphen, appearing at the end of a line.=β Non-breakable hyphen.\-β Discretionary hyphen.\--β Discretionary hyphen, appearing at the end of a line.Margβ Set left margin at%1characters and right margin at%2characters.TopMarginβ Set top margin to%1lines.PageLengthβ Set page length to%1lines.SSβ Single spacing.DSβ Double spacing.1.5Sβ One-and-a-half spacing.TSβ Triple spacing.LSβ Other line spacing.%1is twice the desired spacing. (like, a request for 2.5-spacing sets%1=5.)LPIβ Set%1lines per inch (%1is either6or8)Boldβ Begin boldfaceboldβ End boldfaceUndβ Begin underlineundβ End underlineDoubleUndβ Begin double underlinedoubleundβ End double underlineRedβ Begin redlineredβ End redlineStrikeβ Begin strikeoutstrikeβ End strikeoutRevβ Begin reverse videorevβ End reverse videoOutlineβ Begin outline textoutlineβ End outline textFineβ Begin fine font sizefineβ End fine font sizeOverβ Begin overstrike fontoverβ End overstrike fontSupβ Begin superscriptsupβ End superscriptSubβ Begin subscriptsubβ End subscriptLargeβ Begin large font sizelargeβ End large font sizeSmallβ Begin small font sizesmallβ End small font sizeVeryLargeβ Begin very large font sizeverylargeβ End very large font sizeExtraLargeβ Begin extra large font sizeextralargeβ End extra large font sizeItalicsβ Begin an italics fontitalicsβ End an italics fontShadowβ Begin shadow fontshadowβ End shadow fontSmallCapsβ Begin small capitals font (fixed width)smallcapsβ End small capitals font (fixed width)UpHalfLineβ Advance printer up 1/2 lineDownHalfLineβ Advance printer down 1/2 lineAdvanceToHalfLineβ Advance to absolute vertical position.%1is what WordPerfect thinks the current vertical page position is, in half-lines.%2is the desired position, also in half-lines.Indentβ Expanded when an "Indent" code appears.indentβ Expanded at the end of an indented paragraph.DIndentβ Expanded when a "left-and-right-indent" code appears.dindentβ Expanded at the end of an double indentMarginReleaseβ Margin release.%1is the number of characters to move left.Centerβ Center current linecenterβ End centeringCenterHereβ Center line around current columncenterhereβ End centeringAlignβ Begin alignmentalignβ End alignmentAlignCharβ Set alignment characterFlushRightβ Begin flush rightflushrightβ End flush rightMathβ Begin math modemathβ End math modeMathCalcβ Begin math calc modeMathCalcColumnβ Math calc columnSubTotalβ Do subtotalIsSubTotalβ Subtotal entryTotalβ Do totalIsTotalβ Total entryGrandTotalβ Do grand totalColβ Begin column modecolβ End column modeFnβ Expanded at the beginning of a footnote.fnβ Expanded at the end of a footnote.Enβ Expanded at the beginning of an endnote.enβ Expanded at the end of an endnote.SetFn#β Set the number for the next footnote to%1.FNote#β Footnote number.ENote#β Endnote number.Figure#β Figure number.TableMarkerβ Insert table of contents hereHyphβ Enable hyphenation.hyphβ Disable hyphenation.Justβ Enable justification.justβ Disable justification.Widβ Enable widow/orphan protection.widβ Disable widow/orphan protection.HZoneβ The hyphenation zone.%1and%2are the two magical values that WordPerfect uses to control hyphenation. β¨DAlignβ Set the decimal alignment character to that whose ASCII value is%1. (%cis useful here.)Headerβ Begin header textheaderβ End header textFooterβ Begin footer textfooterβ End footer textSuppβ Suppress page number/header/footer information for one page.%1argument is a bit field which describes what sort of suppression is desired. here's what the bits mean, bestie:1= all2= page number4= page numbers moved to bottom8= all headers16= header a32= header b64= footer a128= footer b
CtrPgβ Center page verticallySetFontβ Change pitch or font.%1is the desired pitch. (Negative means proportionally-spaced.)%2is the font number.SetBinβ Select paper bin to%1=0,1, ...PN0β No page numbering.PN1β Page number in top left.PN2β Page number in top center.PN3β Page number in top right.PN4β Page number on top outside corners (even/odd).PN5β Page number in lower left.PN6β Page number in bottom center.PN7β Page number in lower right.PN8β Page number on bottom outside corners (even/odd).
if no expansion is supplied for an identifier, then nothing is emitted to stdout, but a warning message gets sent to stderr. this warning message will appear at most once per identifier, and you can suppress it completely with the -s option. π«Ά
the special identifier typeout makes its replacement text display on the screen every single time the configuration file is read. it's giving identification messages, or reminders to the user. lowkey useful.
a special identifier is any character enclosed in single quotation marks, which represent themselves. for example,
'Ξ±'="{\\alpha}"
causes the string {\alpha} to be emitted when an Ξ± is encountered. this could also have been written as
'\xE0'="{\\alpha}"
if the character Ξ± has ASCII value 0xE0. (which is true for the IBM PC encoding, no cap.)
if no definition exists for a particular special character, it is transmitted undisturbed. but if a special character is encountered from the upper half of the ASCII character set, and if it has no definition, then a warning message is also emitted. (which can be suppressed with the -s option, bestie.)
π pro tip: lines beginning with the # character are comments.
π NOTES (the lore drop, bestie)
okay so real talk β this whole thing started as an original WP 4.2 to anything translator. and the file format? it has changed a lot between 4.2 and 5.0. like, glow-up of the century. so this translator no longer reads WP 4.2 files, although it could be extended to do so. it justβ¦ hasn't been. π«Ά
the 5.0+ format starts with a standard header file. there's a four byte magic number at the head of the file, followed by various product and version information. all WordPerfect Corporation utilities use this standard header. see the WPproducts array in wp2x.c. π
once the contents of the file have been located, there are three kinds of codes:
- simple one byte controls (WP 4.2 had only these kinds)
- fixed length controls
- variable length controls
there are a large number of undefined types defined for future use. if wp2x detects something it doesn't understand, it can extract the length and skip that code. no panic, just vibes. and there are a number of defined codes that are unimplemented. please see the code, specifically tokens.c where much of the input processing is done. π
π FILES
the sample configuration files in /usr/local/lib/wp2x give you some sort of idea what a production quality configuration file might look like.
not me being honest: they are not intended to be used as-is. they're meant to be modified to suit your particular needs. consider them inspo, not a finished look. β¨
π SEE ALSO
π¨ DIAGNOSTICS
the group chat of error messages. here's what each one is telling you:
Ignoring byte [XX]β indicates that an unimplemented single byte code was ignored. πIgnoring fixed [XX]β indicates that an unimplemented fixed length code was ignored.Ignoring variable [XX] sub [XX] lengthβ indicates that an unimplemented variable length code was ignored, and gives its length. πWarning: Expected XX but received XX at pos: YYYYβ something is wrong in the input file at byteYYYY.Warning: No expansion for XX (C)β a WP code for which no expansion was defined in the config file was encountered.Internal error: Invalid escape Cβ an error occurred while processing an expansion escape (%xsubstitution). probably it was not a recognized escape, check the config file.Fixed Length block [XX] incorrectly terminated by [YY] as pos Zβ something is wrong with the input file, a fixed length block was screwed up. πReserved code [XX] seenβ something that WPC defined as reserved was seen. check with WPC for new meaning.Not a recognized file type.β the file did not start with the right WPC magic number. maybe this is a 4.2 file, or not a WordPerfect file at all? π€Error: Cannot open X (reason)β the file X could not be opened, for the indicated reason.Error: Expecting a hex digitβ inside a string, you typed the characters\x, but the next character was not a valid hex digit.Error: string pool overflowβ the configuration file contained too many strings. increase the value ofPOOL_SIZEand recompile. π«Error: Unknown identifier Xβ the word X was encountered in the configuration file whenwp2xexpected a token identifier likeHRt. most likely, you either misspelled it, or you got your quotation marks out of sync.Error: Identifier not followed by = signβ after an identifier must come an equals-sign. periodt.Error: Quotation mark expectedβ after the equals-sign must come a quotation mark.Error: X: `%\n' not at start of expansionβ the expansion for the identifier X contained the indicated sequence of characters somewhere other than the beginning of the string. the`%\n'interpolation code is meaningful only at the beginning of a string.Error: X: invalid escape `%x'β the expansion for the identifier X contained an invalid escape. either you used%1,%2or%cwhen the identifier X does not supply that parameter, or you meant for a genuine percent sign to be output, in which case you should put%%in the expansion.Error: Invalid character identifierβ character identifiers can only be one character long (after backslash interpretation).Warning: Expected XX but received YY.β the program expected the next byte from the WP file to beXX, but the byteYYwas encountered instead. this means either that your WP file is damaged, or that the program is seriously confused. (or both.) the program will pretend that the byte in the file was indeedXX, which may lead to synchronization errors later on. πWarning: No expansion for Xβ the WP file contained the token X, but the configuration file did not contain any expansion text for it. a null expansion was assumed.Warning: No expansion for XX (c)β the WP file contained the character c (hex codeXX), but the configuration file did not contain any expansion text for it. the character was emitted unaltered. beware that this may give your text formatter indigestion if it does not handle eight-bit characters. π€’Warning: X code not supportedβ the file being converted uses a code whichwp2xdoes not know how to convert. a comment is placed in the output file in its place. if you ever encounter aWPCorp reservedor aWPCorp undefinedcode, the author would appreciate hearing from you. π«ΆInternal error: Invalid escape, %xβ while processing text,wp2xnoticed that you used an invalid escape. nothing is emitted as the escape text. (the internal-ness is that this error is supposed to be caught at the time the configuration file is read.) π΅βπ«
π BUGS
naive configuration files will fail if your WP file doesn't nest its tags properly. a typical case is
[Center][B]Hello[center]
[Center]There[b][center]
to produce a centered boldface Hello. if you use the naive encoding of
Center="\\centerline{"
center="}\n"
Bold="{\\bf "
bold="}"
then this will expand to
\centerline{{\bf Hello}
\centerline{There}}
WordPerfect has no clean concept of grouping; it lets you change fonts at any time and let those changes propagate outside the current environment. (with the exception of headers, footers, footnotes, and endnotes.) no cap. π
now sure, you could write complicated configuration strings to try to handle this properly, but it'd probably not be worth the trouble. after all, the purpose is not to perform a perfect conversion, but rather to produce a readable conversion, which can then be massaged by hand to produce a perfect manuscript. lowkey iconic design philosophy honestly. π
another potential problem is combined attributes, like boldface underline. under a naive configuration,
[B]Boldface [U]Underlined boldface[b] Underlined[u] normal.
comes out as
{\bf Boldface {\it Underlined boldface} Underlined\/} normal.
which is wrong for two reasons:
- the nesting problem discussed above
- TeX font attributes do not combine. π
similar problems exist for other document preparation systems. so be careful. fr fr.
π AUTHORS
- original author: Raymond Chen
<raymond@math.berkeley.edu> - previous maintainer: Michael Richardson
<mcr@ccs.carleton.ca> - current maintainer: Martin Hinner
<mhi@penguin.cz>
and that's a wrap on the whole WP2X(1) page, bestie β section 1 of the manual, all of it, converted and slayed. πβ¨ go forth and translate those WordPerfect files, and remember: readable > perfect. mwah. ππ¦
π¦ where this page comes from
- debian bookworm: wp2x 2.5-mhi-14
- debian trixie: wp2x 2.5-mhi-15
- ubuntu jammy: wp2x 2.5-mhi-13
- ubuntu noble: wp2x 2.5-mhi-14
- ubuntu questing: wp2x 2.5-mhi-15
- ubuntu resolute: wp2x 2.5-mhi-15build1
- ubuntu stonking: wp2x 2.5-mhi-15build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms