ebullient / ttrpg-convert-cli

Utility to convert JSON data (for content you own) from 5etools or pf2etools into Obsidian-friendly Markdown.
https://www.ebullient.dev/projects/ttrpg-convert-cli/
Apache License 2.0
149 stars 33 forks source link

✨ Duplicate Source Key Error handling #453

Closed magejosh closed 1 month ago

magejosh commented 1 month ago

Describe the solution you'd like When a source from the homebrew key in the config.json carries a duplicate source key, it would be nice if we could automatically append "h####" to the key. Such that if say PHB as a source key were encountered again after reaching the homebrew keyed items, it would instead of erroring and failing the convert process, convert the source key to become PHBh0001 with the number appended ascending as new PHB duplicates are found.

Describe alternatives you've considered Writing a script to check the source key of every json file in the homebrew repo versus a list created from the 5e-tools mirror repo (sourceMap.md) and modify all the ones in homebrew as described since they are the problem in the process anyways. This becomes a tedious step with updating though and would be better if it were native error handling in the CLI tool.

Additional context

ebullient commented 1 month ago

There should not be duplicates between homebrew and the main 5eTools corpus, as I believe homebrew tooling checks for that. I can not exhaustively check each homebrew file, and with the way things are cross-referenced, it is not as simple as just appending an identifier.

What would help me is a concrete example of homebrew that does this.

magejosh commented 1 month ago

Yeah, I just spent some time searching for it myself and can't seem to find any duplicates. So that's my bad. I just keep trying to run and seem to get that error consistently. Sorry for the wasted enhancement request. Attached is the output log for ref. I'm just trying to see what it looks like to run the full set of 5e and homebrew repos through, morbid curiosity more than anything. ttrpg-convert.out.txt he wasted enhancement request.

ebullient commented 1 month ago

I think most of those should be fine. For example:

[ 🛑 ERR] Duplicate source key mfov for MFOV:WD -> Warden (Complete)

The key that is actually used in the source material is "MFOV:WD" (that's the source abbreviation) and that's fine.

These homebrew have an abbreviation specified, and that abbreviation is not unique:

"json": "MFOV:WD",
"abbreviation": "MFoV",
"full": "Warden (Complete)",
"authors": [
    "Middle Finger of Vecna"
],

and that appears to be very common (maybe even expected).

It looks like the source attributes all use the correct value, but this is a case where I can't make a mapping from the abbreviation to the source, because.. one already exists.

magejosh commented 1 month ago

Right, so i incorrectly focused on the wrong problem I'm guessing. Nothing outputs when I run the command in the terminal, it creates the output folder, but no notes within it.

ebullient commented 1 month ago

yea.. looks like one of them has an unexpected math formula in it. I do not try to run with all homebrew, as not all of them are well-formed. If there is a specific homebrew that doesn't work, and you know its syntactically correct, then raise an issue for that one.