-
Notifications
You must be signed in to change notification settings - Fork 62
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
Text.pm regression since v0.58: YAML::Tiny failed to classify line ... #365
Comments
Hello, thanks for reporting. Is it really an issue? The only other possibility would be to allow po4a to silently fail on malformated YAML headers, and I feel bad about it. The experience show that people only look at po4a error messages when the build fails. I'm afraid of people not noticing important breakages if we allow the YAML header to fail. If you insist that your file should be allowed to have Thanks |
I understand that this is a cornercase: I can only imagine it being rare to have markdown content that begins with a horisontal ruler - and additionally expressing that using exactly three dashes. I do think, however, that it is not totally weird to have scenarios like mine: a markdown text being a footer, where that footer should have a horisontal ruler as its very first "word". How about by default to parse YAML loosely, and have a I mean, fundamentally markdown was intended as failing gracefully, deliberately choosing markup that would be reasonably readable if not understood or mistyped. |
I understand your point, but I'm still not convinced. Maintainers don't look at po4a output, even less at the files produced by po4a. I don't think it's safe to go for the loose default. I will extend the error message that you get when the file begins with |
This is proposing a potential solution to #365
What you propose is to continue letting po4a dictate how to write content. I find that ugly - sure, only for a cornercase, but still. Please if you do not want to implement loose-by-default then at least implement loose-as-option and have the error message mention that option as an alternative. |
I'm 100% OK with the implementation of loose-as-option, and won't close that bug But I'm still wondering what kind of data structure I should use to save them. If "someone" comes up with a patch implementing the loose-by-default (ie, just Does it sound like a plan? ;) |
Sounds like a plan to me. I wonder (without volunteering to dive in, however) if it really needs to be this complicated to solve: Current code does something like this:
Seems to me a simple solution would be to call YAML::Tiny twice, like this:
More elegant might be to only call YAML::Tiny once, passing its result to the function - or get rid of the separate function altogether: It is only called once ;-) |
One difficulty is to get the input from where it is (using I was only describing this part "pop the data, but make sure you can reinject it in case of problem" earlier. This is perfectly complementary with what you describe here. |
Oh, I understand the complication now. Sorry, if core code has no way of "rolling back" if hitting a dead end, then indeed my "simple approach" is not so simple after all. :-( |
the core code (TransTractor) has a rollback solution, but you have to unshift content+reference in the right order. Not necessarily difficult, but it has to be taken into account. |
Right. I clearly didn't account for that (I have "only" juggled Perl for ~25 years - haven't familiarized myself with iterators yet). |
Text.pm chokes on a text containing a markdown horisontal ruler at the very top of the file.
This file was processed correctly until and including po4a v0.57 but fails with v0.58 onwards.
Problem is the introduction of the YAML Front Matter parser: Code wrongly treats leading triple-dash as always meaning beginning of a YAML header, but YAML metadata is optional for markdown text and the proper is therefore to only try parse as YAML but gracefully fallback to parsing as markdown in case of failure.
For now I have applied the workaround of using four dashes, but I am confident that the Text.pm module should be fixed.
The text was updated successfully, but these errors were encountered: