Closed vyhd closed 2 years ago
Interesting, I must have overlooked this feature when I wrote the initial parser. I should've referred back to SM source code for the rewrite, but instead just used my old implementation & test cases.
We'll need to update msdparser, and we'll also need to consider how to escape control characters during serialization from this package. Right now serialization is all done ad-hoc (given that it's simple enough to interpolate some #:;
characters around some strings) but we might need to make it a little more structured to do this right. Maybe a simfile._private.msd
module with helper functions?
Alright, I landed on a solution for this that I think is reasonable, and it's now available as msdparser
version 2.0.0b1.
You can upgrade this package underneath simfile
to get escape-handling behavior out of the box, but only for reading simfiles. Writing simfiles with escapes will require an update to the simfile
package; the new msdparser
release offers a solution for this, but it's not being called from simfile
yet.
Documentation for this pre-release can be found here.
Poetry: poetry add msdparser@2.0.0b1
Pipenv: pipenv install --pre msdparser==2.0.0b1
If the title parses as A;B
and not A\
, you're good to go:
>>> import simfile
>>> simfile.loads('#TITLE:A\;B;')
<SMSimfile: A;B>
Again, don't upgrade if you need to write simfiles. Wait for simfile
version 2.1.0 for the complete fix.
First off, thanks for building this library! It's been remarkably easy to use for simfile introspection.
I ran into this unfortunate edge case while parsing through DDR A20 PLUS content:
which was triggered by this line:
#SOURCE:ゲーム「STEINS\;GATE」;
in the SM file located at: https://zenius-i-vanisher.com/v5.2/viewsimfile.php?simfileid=45612It looks like StepMania's MSD parser allows you to use
\
to escape any control character (source), so this lib probably should be able to as well.I... might be able to submit a PR for this sometime in the next few weeks? But I wanted to flag it now, in case someone gets to it first.