Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature suggestion #35

Open
ibendr opened this issue Jan 8, 2025 · 13 comments
Open

feature suggestion #35

ibendr opened this issue Jan 8, 2025 · 13 comments

Comments

@ibendr
Copy link

ibendr commented Jan 8, 2025

Hi Viresh I'm a big fan of your work. I look at Exet and think "this is where I was going with my project" as so many of the features of your program are things I had envisaged, and your design philosophy seems very similar. (My own project stalled long ago. I was working in python, as I hadn't thought browser-based would cope with holding entire lexicon in memory, as once upon a time it wouldn't have! I am still using my software as a CLI in a terminal, having been torn between going to a GUI or ncurses format next ... which was many years ago.)
I am now starting to use Exet for setting some of my grids (with some swallowing of pride, having relied on my own program for so long now) but an obstacle to integrating it into my workflow is when I go to save my work which I will then want to convert to a different format. (I am self-publishing using my own solving interface.) It would be great if I could save a puzzle in a really simple bare-bones text format, such as seen in the sample file attached. I have a simple program that can then convert that to the html file for publishing on my site.
I toyed with the idea of forking your project and trying to write the necessary extra code myself, then sending you a pull request, but I know that would be opening quite a can of worms and I might never get it done, so thought I'd pop it in as a feature request. BUT if you have the time to answer the odd question to help me find my way around your code, I could be willing to have a go at it. And more broadly, even though collaboration has never been my strong suit, I am potentially interested in contributing some effort to your project. It's always worried me that as programmers, so many of our efforts are duplicating one another's work rather than building on it, so I have long thought I should break out of my solo silo and do some collaboration. As an example of an area where you might welcome a contribution, I recently finally adapted my own solving interface to be phone-friendly, and I notice that Exolve (as far as I can see) is not yet well optimised for that setting.
I don't log into Github often and don't know what the mechanism is for receiving replies to this sort of communication, so I will also DM you in Messenger to open an easy line of communication.
386sltd29.txt

@viresh-ratnakar
Copy link
Owner

Hi Ben,

Thanks, I hope Exet works out for you. I'm always open to feature requests, bug reports, and am also happy to discuss potential contributions, ideas/algorithms/etc.

Re: the simple text format that you would like: the Exolve format is ultimately itself a simple plain text format. It looks very similar to what you need. For example:

exolve-width: 3
exolve-height: 3
exolve-grid:
  ACE
  C.A
  TAT
exolve-across:
  1 Clue for ACE (3)
  3 Clue for TAT (3)
exolve-down:
  1 Clue for ACT (3)
  2 Clue for EAT (3)

There are additional features in the Exolve format (such as providing clue annotations, underlining the definition part after Reveal, etc.), but you can easily remove all that if needed.

If you save a crossword from Exet using the "Save > Download Exolve file with solutions" option, then the downloaded file, say exet-exolve-output.html, can be converted to your format with some simple scripting. Eg., you can save the following script as exolve-to-plain.sh:

#!/bin/bash

awk_script='
BEGIN {
  in_grid = 0;
  in_clues = 0;
} /exolve/ {
  in_grid = 0;
  in_clues = 0;
} /exolve-grid/ {
  in_grid = 1;
  in_clues = 0;
} /exolve-across/ {
  in_grid = 0;
  in_clues = 1;
  printf "\nAcross:\n";
} /exolve-down/ {
  if (in_grid) printf "\n";
  in_grid = 0;
  in_clues = 1;
  printf "Down:\n";
} !/exolve-/ {
  if (in_grid) {
    gridline = $0;
    gsub(/ /, "", gridline);
    gsub(/\./, "=", gridline);
    printf "%s\n", gridline;
  }
  if (in_clues) {
    clue = $0;
    # Code to print the clue number right justified in four spaces and with a trailing period
    num_matches = match(clue, /[0-9]+/);
    if (num_matches != 0) {
      num = substr(clue, RSTART, RLENGTH);
      printf "%4d. ", num;
      clue = substr(clue, RSTART + RLENGTH);
    }
    # Strip away any "annotation" part
    num_matches = match(clue, /) /);
    if (num_matches != 0) {
      clue = substr(clue, 1, RSTART);
    }
    # Remove defintion markers, if any
    gsub(/~{/, "", clue);
    gsub(/}~/, "", clue);
    # Trim leading/trailing spaces
    gsub(/^[ ]+/, "", clue);
    gsub(/[ ]+$/, "", clue);
    printf "%s\n", clue;
  }
}'

awk "$awk_script" -

And then run:

cat exet-exolve-output.html | ./exolve-to-plain.sh > plain-text-puzzle.txt

I am a bit reluctant to add a specific "Download as .." option for your specific format to Exet itself, as the format is just specific to your use-case. One possibility would be to add support where Exet lets the user paste in a JavaScript function to create any arbitrary format, using the simple data structures that carry the grid and the clues, and then you can save the output. But that too, I worry, would not be widely used.

Re: Exolve on mobile devices. Exolve does support mobile devices: for example, you can load any of my puzzles at gussalufz.com from a browser on a phone. But if you've done that already and have suggestions for improvements, am happy to listen and/or accept contributions!

@ibendr
Copy link
Author

ibendr commented Jan 8, 2025 via email

@viresh-ratnakar
Copy link
Owner

Yeah, there is some html around the exolve part (but the script I posted above should just ignore that).

Also, spaces in the grid part are optional (but Exet does use them). The script also removes the spaces.

Please let me know how it goes!

@ibendr
Copy link
Author

ibendr commented Jan 8, 2025 via email

@viresh-ratnakar
Copy link
Owner

Great!

One bug is that if you have parentheses inside the clue, anything after that will get deleted :-). Exet does always start the annotation part with "[SOLUTION]", so you can make a false positive very unlikely by replacing the line:

    num_matches = match(clue, /) /);

with:

    num_matches = match(clue, /) \[[A-Z]/);

Also, the line:

  if (in_grid) printf "\n";

is not needed (I was trying to insert the extra blank line that your format had, before "Across:", but then I just added it to the part that prints the "Across:".

@ibendr
Copy link
Author

ibendr commented Jan 8, 2025 via email

@ibendr
Copy link
Author

ibendr commented Jan 8, 2025 via email

@ibendr
Copy link
Author

ibendr commented Jan 8, 2025 via email

@ibendr
Copy link
Author

ibendr commented Jan 8, 2025 via email

@viresh-ratnakar
Copy link
Owner

Yeah, bookmarklet seems like a good way to do this. It basically does the "custom JS code to transform/format before saving" that I had mentioned we could consider adding as a feature, but the browser already has that feature by way of bookmarklets. Nice.

@ibendr
Copy link
Author

ibendr commented Jan 8, 2025 via email

@viresh-ratnakar
Copy link
Owner

This is fine, I do not plan to change the basic names. In fact I have a test in Exolve that checks for the presence of some basic fields, and I run all the tests before every release. There are other people who use customizations in their Exolve puzzles who rely on the presence of many basic fields, so I think of these as part of the Exolve "API".

I've now also added a couple of fields that you were using that were not already present in the test: https://github.com/viresh-ratnakar/exolve/blob/master/test-customize-puzzle.html

Also, FYI, when using Exet, the Exolve object can also be accessed as exet.puz

@ibendr
Copy link
Author

ibendr commented Jan 9, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants