@confuzzle/puz-crossword
v1.2.3
Published
.puz crossword reader, writer, and parser
Maintainers
Readme
@confuzzle/puz-crossword
This package is for reading, writing, and parsing .puz format files. It contains a single class, PuzCrossword. For standalone reading or writing, see also:
Methods
PuzCrossword.from(x)- equivalent toBuffer.from(x), reads.puzfile fromxand returns a newPuzCrossword.toBytes()- returns aUint8Arraycontaining this crossword in.puzbinary formattoBuffer()- returns aBuffercontaining this crossword in.puzbinary format
Fields
PuzCrossword objects have the following fields as defined in the .puz file format. They are all strings unless otherwise specified.
titleauthorcopyrightnotewidth- integerheight- integerclues- array of stringssolutionstate
In addition to these, there are the following fields:
hasState- boolean indicating whether state is all blank squaresparsedClues- array of parsed clue objects
There is no clue numbering explicitly encoded in the .puz file format, so parsed clues are provided as a convenience. Here is an example of a parsed clue object.
{
number: 42,
text: 'The ultimate question',
solution: 'GFOPIOFJ',
state: '--------',
row: 9,
col: 0,
isAcross: true,
length: 8
}Example Usage
const PuzCrossword = require('@confuzzle/puz-crossword').PuzCrossword;
const fs = require('fs');
const cw = PuzCrossword.from(fs.readFileSync("test.puz"));
cw.title = "A new title"
const cw2 = PuzCrossword.from(cw.toBytes());
console.log(cw2.title)Limitations
The solution in the above clue is scrambled, unscrambling is not yet implemented. Other .puz features such as rebuses and timers have also not yet been implemented.
