Skip to content

Commit

Permalink
v1.20
Browse files Browse the repository at this point in the history
### Version: Exolve v1.20 September 14 2021

- If a clue has multiple enum-like parts, use the *last* one.
- However, override that if there is an earlier enum-like substring
  that is immediately (or with intervening spaces) followed by "[...]"
  (which is a tell-tale start of the annotation part).
- Allow an empty "[]" to be placed to mark the end of the clue part
  for dealing with ambiguities and also for the corner case that
  the anno has to start with "[...]" without making the contents of
  the square brackets be treated like the solution. This used to
  require explicitly providing the solution (like
  "... clue (6) [WITTER] [t]WITTER") but can now also be tackled
  with "... clue (6) [] [t]WITTER". The empty "[]" is not shown in the
  clue or the anno.
- Bugfix: in the case when an anno is provided in a crossword
  without solutions, "reveal this" was clearing the cells (now doesn't).
  • Loading branch information
viresh-ratnakar authored Sep 14, 2021
1 parent 97a2206 commit 1292fde
Show file tree
Hide file tree
Showing 44 changed files with 294 additions and 201 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

### Version: Exolve v1.20 September 14 2021

- If a clue has multiple enum-like parts, use the *last* one.
- However, override that if there is an earlier enum-like substring
that is immediately (or with intervening spaces) followed by "[...]"
(which is a tell-tale start of the annotation part).
- Allow an empty "[]" to be placed to mark the end of the clue part
for dealing with ambiguities and also for the corner case that
the anno has to start with "[...]" without making the contents of
the square brackets be treated like the solution. This used to
require explicitly providing the solution (like
"... clue (6) [WITTER] [t]WITTER") but can now also be tackled
with "... clue (6) [] [t]WITTER". The empty "[]" is not shown in the
clue or the anno.
- Bugfix: in the case when an anno is provided in a crossword
without solutions, "reveal this" was clearing the cells (now doesn't).

### Version: Exolve v1.19 September 9 2021

- Bug-fix: blank lines in exolve specs mean grid height may be less than
Expand Down
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## An Easily Configurable Interactive Crossword Solver

### Version: Exolve v1.19 September 9 2021
### Version: Exolve v1.20 September 14 2021

Exolve can help you create online interactively solvable crosswords (simple
ones with blocks and/or bars as well as those that are jumbles or are
Expand Down Expand Up @@ -478,7 +478,12 @@ of opening and closing parentheses, containing only numbers, hyphens, commas,
apostrophes, and periods, starting with a number. The software also treats a
pair of parentheses containing the text "word" or "letter" or "?" with anything
before are after it as an enum (to allow the setter to specify the enum as
"(two words)" or "(?)", for example).
"(two words)" or "(?)", for example). But it looks for such enums only if a
normal enum is not present in the clue.

In the rare case that there are multiple candidate enum parts in a clue, the
last one is used. However, this can be overridden by explicitly using "[]"
to mark the end of the clue (see [`Annotations`](#annotations) below).

### Suppressing enums or separators

Expand Down Expand Up @@ -546,7 +551,25 @@ this option.
If the leading part of the anno needs to be something in square brackets, such
as "... (6) [t]WITTER ...," then setters should include the solution before
that (even if it can be inferred from the grid), to avoid misinterpreting the
leading part as the solution, like "... (6) [WITTER] [t]WITTER ..."
leading part as the solution, like "... (6) [WITTER] [t]WITTER ..." Or, they
can use an empty pair of square brackets to mark the end of the clue, like
"... (6) [] [t]WITTER ..." The special "[]" clue-end marker string is also
useful if there is any ambiguity about where the clue ends (perhaps because of
multiple enum-like substrings) that cannot be resolved by providing the
solution in square brackets.

Here are some more complex examples of enum/annotation parsing.
```
1 This (13) clue ends (word) here! (4)
2 This (13) clue also ends (1 word) here! (4) Some annotation follows.
3 This (13) clue also ends (2 letters) here! (8) [SOLUTION] Some annotation follows.
4 This (13) clue also ends (words) here! (8) [] [t]WITTER The anno has (3) enum-like parts.
5 This is an enum-less and anno-less clue that ends here!
6 This is also an enum-less and anno-less clue that also ends here! (?)*
7 This is also an enum-less but with-anno clue that also ends here! (?)* [] [t]WITTER Here is the anno.
8 This clue, even though its anno contains an enum-like substring, ends here! (4) The (word) and (4 letters) enum-like parts here are not numeric.
9 This clue (13) does not end now (4) as [square brackets do not follow immediately]; it ends here! (4)
```

#### In-clue annotations
You can also decorate sub-phrases in the clue with underlines, different styles,
Expand Down
2 changes: 1 addition & 1 deletion exolve-from-ipuz.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
The latest code and documentation for Exolve can be found at:
https://github.com/viresh-ratnakar/exolve
Version: Exolve v1.19 September 9 2021
Version: Exolve v1.20 September 14 2021
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion exolve-from-puz.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
The latest code and documentation for Exolve can be found at:
https://github.com/viresh-ratnakar/exolve
Version: Exolve v1.19 September 9 2021
Version: Exolve v1.20 September 14 2021
*/

function exolveFromPuzNextNull(buffer, offset) {
Expand Down
6 changes: 3 additions & 3 deletions exolve-m-simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
See the full Exolve license notice in exolve-m.js.
Version: Exolve v1.19 September 9 2021
Version: Exolve v1.20 September 14 2021
-->

<link rel="stylesheet" type="text/css" href="https://viresh-ratnakar.github.io/exolve-m.css?v1.19"/>
<script src="https://viresh-ratnakar.github.io/exolve-m.js?v1.19"></script>
<link rel="stylesheet" type="text/css" href="https://viresh-ratnakar.github.io/exolve-m.css?v1.20"/>
<script src="https://viresh-ratnakar.github.io/exolve-m.js?v1.20"></script>

<title>Exolve</title>

Expand Down
2 changes: 1 addition & 1 deletion exolve-m.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Copyright (c) 2019 Viresh Ratnakar
See the full license notice in exolve-m.js.
Version: Exolve v1.19 September 9 2021
Version: Exolve v1.20 September 14 2021
*/

@media (max-width: 500px) {
Expand Down
6 changes: 3 additions & 3 deletions exolve-m.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
See the full Exolve license notice in exolve-m.js.
Version: Exolve v1.19 September 9 2021
Version: Exolve v1.20 September 14 2021
-->
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.19"/>
<script src="exolve-m.js?v1.19"></script>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.20"/>
<script src="exolve-m.js?v1.20"></script>

<title>Exolve (replace with puzzle title)</title>

Expand Down
129 changes: 75 additions & 54 deletions exolve-m.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Exolve(puzzleSpec,
visTop=0,
maxDim=0,
saveState=true) {
this.VERSION = 'Exolve v1.19 September 9 2021';
this.VERSION = 'Exolve v1.20 September 14 2021';

this.puzzleText = puzzleSpec;
this.containerId = containerId;
Expand Down Expand Up @@ -1729,6 +1729,39 @@ Exolve.prototype.parseCellLocation = function(s) {
return [row, col];
}

// Return [oparen, cparen, isNumeric] as the best indices of '(' and ')' for
// the enum in the clue. null if not found.
// We return the last matching enum part, unless we encounter an enum part
// that is immediately followed by something in square brackets, in which
// case we pass that enum part.
Exolve.prototype.findEnum = function(clueLine) {
let candidate = null;
let start = 0;
let cluePart = clueLine;
while (start < clueLine.length) {
let enumLocation = cluePart.search(/\([1-9]+[0-9\-,\.'’\s]*\)/);
let numeric = true;
if (enumLocation < 0 && !candidate) {
numeric = false;
// Look for the string 'word'/'letter'/? in parens.
enumLocation = cluePart.search(/\([^)]*(word|letter|\?)[^)]*\)/i);
}
if (enumLocation < 0) {
break;
}
const enumEndLocation = enumLocation +
cluePart.substr(enumLocation).indexOf(')');
console.assert(enumEndLocation >= 0, cluePart);
candidate = [start + enumLocation, start + enumEndLocation, numeric];
start += (enumEndLocation + 1);
cluePart = clueLine.substr(start);
if (cluePart.search(/[ ]*\[.*\]/) == 0) {
return candidate;
}
}
return candidate;
}

// Parse an enum like (4) or (4,5), or (5-2,4).
// Return an object with the following properties:
// enumLen
Expand All @@ -1750,33 +1783,13 @@ Exolve.prototype.parseEnum = function(clueLine) {
placeholder: '',
enumStr: '',
};
let enumLocation = clueLine.search(/\([1-9]+[0-9\-,\.'’\s]*\)/)
if (enumLocation < 0) {
// Look for the string 'word'/'letter'/? in parens.
enumLocation = clueLine.search(/\([^)]*(word|letter|\?)[^)]*\)/i)
if (enumLocation >= 0) {
let enumEndLocation =
enumLocation + clueLine.substr(enumLocation).indexOf(')')
if (enumEndLocation <= enumLocation) {
return parse
}
parse.enumStr = clueLine.substring(enumLocation, enumEndLocation + 1)
if (clueLine.charAt(enumEndLocation + 1) == '*') {
parse.afterEnum = enumEndLocation + 2;
parse.afterClue = enumLocation;
parse.dontShow = true;
} else {
parse.afterEnum = this.adjustAfterEnum(clueLine, enumEndLocation + 1)
parse.afterClue = parse.afterEnum;
}
}
return parse
}
let enumEndLocation =
enumLocation + clueLine.substr(enumLocation).indexOf(')')
if (enumEndLocation <= enumLocation) {
return parse
const foundEnum = this.findEnum(clueLine);
if (!foundEnum) {
return parse;
}
const enumLocation = foundEnum[0];
const enumEndLocation = foundEnum[1];
const isNumeric = foundEnum[2];
parse.enumStr = clueLine.substring(enumLocation, enumEndLocation + 1)
if (clueLine.charAt(enumEndLocation + 1) == '*') {
parse.afterEnum = enumEndLocation + 2;
Expand All @@ -1786,38 +1799,41 @@ Exolve.prototype.parseEnum = function(clueLine) {
parse.afterEnum = this.adjustAfterEnum(clueLine, enumEndLocation + 1)
parse.afterClue = parse.afterEnum;
}
let enumLeft = clueLine.substring(enumLocation + 1, enumEndLocation)
let nextPart
if (!isNumeric) {
return parse;
}
let enumLeft = clueLine.substring(enumLocation + 1, enumEndLocation);
let nextPart;
while (enumLeft && (nextPart = parseInt(enumLeft)) && !isNaN(nextPart) &&
nextPart > 0) {
for (let i = 0; i < nextPart; i++) {
parse.placeholder = parse.placeholder + '?'
parse.placeholder = parse.placeholder + '?';
}
parse.enumLen = parse.enumLen + nextPart
enumLeft = enumLeft.replace(/\s*\d+\s*/, '')
let nextSymbol = enumLeft.substr(0, 1)
enumLeft = enumLeft.replace(/\s*\d+\s*/, '');
let nextSymbol = enumLeft.substr(0, 1);
if (nextSymbol == '-') {
parse.hyphenAfter.push(parse.enumLen - 1)
enumLeft = enumLeft.substr(1)
parse.hyphenAfter.push(parse.enumLen - 1);
enumLeft = enumLeft.substr(1);
} else if (nextSymbol == ',') {
nextSymbol = ' '
parse.wordEndAfter.push(parse.enumLen - 1)
enumLeft = enumLeft.substr(1)
nextSymbol = ' ';
parse.wordEndAfter.push(parse.enumLen - 1);
enumLeft = enumLeft.substr(1);
} else if (nextSymbol == '.') {
parse.wordEndAfter.push(parse.enumLen - 1)
enumLeft = enumLeft.substr(1)
parse.wordEndAfter.push(parse.enumLen - 1);
enumLeft = enumLeft.substr(1);
} else if (nextSymbol == '\'') {
enumLeft = enumLeft.substr(1)
enumLeft = enumLeft.substr(1);
} else if (enumLeft.indexOf('’') == 0) {
// Fancy apostrophe
nextSymbol = '\''
enumLeft = enumLeft.substr('’'.length)
nextSymbol = '\'';
enumLeft = enumLeft.substr('’'.length);
} else {
break;
}
parse.placeholder = parse.placeholder + nextSymbol
parse.placeholder = parse.placeholder + nextSymbol;
}
return parse
return parse;
}

// Parse a clue label from the start of clueLine.
Expand Down Expand Up @@ -2263,10 +2279,15 @@ Exolve.prototype.parseAnno = function(anno, clueIndex) {
} else if (inBrac && !theClue.solution) {
theClue.explicitSol = true
theClue.solution = inBrac;
} else if (!inBrac) {
// Skip empty [] in anno, used to point at the start of the anno if
// there are multiple enum-like strings within the clue.
anno = anno.substr(indexOfBrac + 1).trim();
break;
} else {
break;
}
anno = anno.substr(indexOfBrac + 1).trim()
anno = anno.substr(indexOfBrac + 1).trim();
this.hasReveals = true
}
theClue.anno = anno;
Expand Down Expand Up @@ -5179,20 +5200,20 @@ Exolve.prototype.toggleNinas = function() {
}

Exolve.prototype.clearCell = function(row, col) {
let gridCell = this.grid[row][col]
let oldLetter = gridCell.currLetter
let gridCell = this.grid[row][col];
let oldLetter = gridCell.currLetter;
if (oldLetter != '0') {
gridCell.currLetter = '0'
gridCell.textNode.nodeValue = ''
gridCell.currLetter = '0';
gridCell.textNode.nodeValue = '';
if (this.atCurr(row, col)) {
this.gridInput.value = ''
this.gridInput.value = '';
}
}
if (oldLetter == '1') {
let gridSymCell = this.symCell(row, col)
let gridSymCell = this.symCell(row, col);
if (gridSymCell.isDgmless) {
gridSymCell.currLetter = '0'
gridSymCell.textNode.nodeValue = ''
gridSymCell.currLetter = '0';
gridSymCell.textNode.nodeValue = '';
}
}
}
Expand Down Expand Up @@ -5598,7 +5619,7 @@ Exolve.prototype.revealCurr = function() {
}
let oldLetter = gridCell.currLetter;
let letter = gridCell.solution;
if (letter && oldLetter != letter) {
if (letter && oldLetter != letter && letter != '0' && letter != '?') {
gridCell.currLetter = letter;
let revealedChar = this.stateToDisplayChar(letter);
gridCell.textNode.nodeValue = revealedChar;
Expand Down
12 changes: 6 additions & 6 deletions exolve-player.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.19"/>
<script src="exolve-m.js?v1.19"></script>
<script src="exolve-from-ipuz.js?v1.19"></script>
<script src="exolve-from-puz.js?v1.19"></script>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.20"/>
<script src="exolve-m.js?v1.20"></script>
<script src="exolve-from-ipuz.js?v1.20"></script>
<script src="exolve-from-puz.js?v1.20"></script>

<style>
#exolve-player {
Expand Down Expand Up @@ -112,8 +112,8 @@
'<meta charset="utf-8"/>\n' +
'<meta name="viewport" content="width=device-width, initial-scale=1"/>\n' +
'<link rel="stylesheet" type="text/css" ' +
'href="https://viresh-ratnakar.github.io/exolve-m.css?v1.19"/>\n' +
'<script src="https://viresh-ratnakar.github.io/exolve-m.js?v1.19">' +
'href="https://viresh-ratnakar.github.io/exolve-m.css?v1.20"/>\n' +
'<script src="https://viresh-ratnakar.github.io/exolve-m.js?v1.20">' +
'<\/script>\n' +
'<\/head>\n' +
'<body>\n' +
Expand Down
Loading

0 comments on commit 1292fde

Please sign in to comment.