viresh-ratnakar / exolve

Online interactive crossword software in JavaScript
MIT License
74 stars 15 forks source link

hyphen handling #40

Closed erikstar closed 3 years ago

erikstar commented 4 years ago

Hi!

First: for me hyphen placement is more a physical thing that I spontaneously should let the "exolve-grid" handle. With something like "-" or "!" after a letter.

But with your design I have some questions: 1) How to make a hyphened word in a multiword clue (except the first word)? https://fripp.changeip.org/melodikryss/melodikryss1/index_clues.html (2d, 3d)

2) Is it a bug or a feature that the hyphen exist in 20d? For me it is definitely be a feature! So for me it would be great if the hyphen wasn't chopped. (I needed it in a swedish name "Sven-Erik")

3) Is it possible to add hyphen in nodir clues?

Thanks! /Erik S

erikstar commented 4 years ago

And now I realize I could even like an option to place the hyphen before the first letter also.

/Erik S

erikstar commented 4 years ago

Oops. I now see "!" is already used... but perhaps ":" or something...

viresh-ratnakar commented 4 years ago
  1. Not quite sure what you mean. If you provide the enum like

2, 3 This should be a-b cde-f (1-1, 3-1)

that should work I think.

  1. Hmm, I don't want the hyphen to stick out of the box. Letting it reemerge from the other box would work, but it's a lot of code complexity for a corner case.

3, etc. I think you can simply write a function to place a hyphen wherever you want, and call it from customizeExolve(). This would be similar to the function that I had sketched for placing the "turning" symbol. Below is a (slightly modified so that you can adapt it) copy of the relevant part of code that creates hyphens:

      let gridCell = puz.grid[row][col]
      if (gridCell.hyphenToRight) {
        const hyphenRect =
            document.createElementNS('http://www.w3.org/2000/svg', 'rect');
        hyphenRect.setAttributeNS(null, 'x',
            puz.cellLeftPos(col + 1, puz.GRIDLINE - puz.hyphenWBy2));
        hyphenRect.setAttributeNS(null, 'y', puz.cellTopPos(
            row, puz.GRIDLINE + puz.squareDimBy2 - puz.SEP_WIDTH_BY2));
        let hw = (col + 1) < puz.gridWidth ? puz.hyphenW : puz.hyphenWBy2
        hyphenRect.setAttributeNS(null, 'width', hw);
        hyphenRect.setAttributeNS(null, 'height', puz.SEP_WIDTH);
        hyphenRect.style.fill = puz.colorScheme['separator']
        puz.svg.appendChild(hyphenRect)
      }
      if (gridCell.hyphenBelow) {
        const hyphenRect =
            document.createElementNS('http://www.w3.org/2000/svg', 'rect');
        hyphenRect.setAttributeNS(null, 'x', puz.cellLeftPos(
            col, puz.GRIDLINE + puz.squareDimBy2 - puz.SEP_WIDTH_BY2));
        hyphenRect.setAttributeNS(
            null, 'y', puz.cellTopPos(row + 1, puz.GRIDLINE - puz.hyphenWBy2));
        hyphenRect.setAttributeNS(null, 'width', puz.SEP_WIDTH);
        let hh = (row + 1) < puz.gridHeight ? puz.hyphenW : puz.hyphenWBy2
        hyphenRect.setAttributeNS(null, 'height', hh);
        hyphenRect.style.fill = puz.colorScheme['separator']
        puz.svg.appendChild(hyphenRect)
      }
erikstar commented 4 years ago

At least my "2, 3 linked (1-1 2-2)" from my example: https://fripp.changeip.org/melodikryss/melodikryss1/index_clues.html (2d, 3d) does only give one hyphen in the two words (2d, 3d).

viresh-ratnakar commented 4 years ago

Yes, thanks, this does look like a bug! I will fix it.

viresh-ratnakar commented 4 years ago

I looked into the code to fix this "bug", but realized that I had a typo above, unfortunately.

It should be (1-1, 2-2) (there should be a comma to indicate a space, as is usual in crosswords). I have also updated it in my comment above.

erikstar commented 4 years ago

OK. But for me it doesn't work with: 2, 3 linked (1-1, 2-2) or 2, 3 linked (1-1,2-2)

Without comma the first hyphen shows.

With comma the whole puzzle disappears.

viresh-ratnakar commented 4 years ago

Ah, this is indeed a bug that I can see now, but for now there is a workaround for you. If you also add 3d in your down clues, with any dummy text, it should work. For example:

  exolve-down:
    2,3 linked (1-1, 2-2) 
    3 see 2d
viresh-ratnakar commented 4 years ago

With v0.90 that I have now checked in, the hyphen in the linked clue should get rendered even if the linked clue is not explicitly listed in the list of clues.

erikstar commented 3 years ago

For me all this is perfectly solved in 0.95.