fsprojects / FSharp.Data

F# Data: Library for Data Access
https://fsprojects.github.io/FSharp.Data
Other
816 stars 288 forks source link

HtmlState: restore FormattedMode if still in pre after char ref #1414

Closed stroborobo closed 2 years ago

stroborobo commented 3 years ago

At the same time the assumption that the code element is formatted is not correct. They are often used at the same time though and with that comes another issue: keeping FormattedMode in elements nested into pre.

I'm not sure how to approach this, I've never worked with refs like here before. Would it be ok to drop the FormattedMode and add an IsFormatted: bool ref instead? And update that when entering/exiting pre elements.

stroborobo commented 2 years ago

Hey @cartermp, since you didn't say anything I implemented my earlier suggestion with the bool ref instead. My assumption was not correct in the original implementation anyways, so it didn't really work well, test was flawed also :/

But this seems to work, at least for the fixed up test and my use case of glueing together different parts of fsharp.github.io/fsharp-core-docs

cartermp commented 2 years ago

Weird that this failure is only on Windows: Drops whitespace outside pre

stroborobo commented 2 years ago

Oh right, the formatter inserts Environment.NewLine, totally forgot about it. I'll change the test to expect those as well.