athackst / mkdocs-simple-plugin

Build documentation files inside your code into a MkDocs site.

Home Page:https://althack.dev/mkdocs-simple-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Divergence between docs and behavior for "start" parameter

gwhitney opened this issue · comments

As of mkdocs 0.5.0, the documentation at https://allisonthackston.com/mkdocs-simple-plugin/mkdocs_simple_plugin/plugin/ states with respect to the "start" parameter that "the (last) extraction mode (if any) with no start parameter is active beginning with the first line of the scanned file; there is no way such a mode can be reactivated if it stops."

However, the behavior is actually that an extraction mode with no start parameter is activated after any line is reached where no mode is active and no earlier extraction pattern is activated by that line. That means that such an extraction mode is only active starting with the second line of a file, and moreover that once it stops, it will always be reactivated after skipping a line. Hence it is no longer useful for "front-matter extraction" (as also mentioned in the documentation).

Again, I would be happy to file a PR including an appropriate test of the behavior. In this case, I'd like to urge restoration of the documented behavior, as the altered behavior seems less useful, can be obtained without the "no start pattern" convention simply by using a start pattern of '.', and there does not seem to be any simple way of supporting "front-matter extraction" without the convention as it is documented. One can make an extraction mode that will match any first line of a file and emit it, but then that pattern will immediately restart right after stopping, since its start pattern has to be designed to match anything.

Yeah, sounds like I broke something here. 🤦

Feel free to open a fix

Sorry it took me a couple of days to fit this into my schedule. (Creating the test took several times as long as the code change, but is of course ultimately the more valuable part of this PR long term.)