Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fair bit of changes here.
First, there's the ability to optionally (default off) use a proper parser for formatting. This is MUCH more robust, and about 10+ times faster then the pure-regex solution.
It also should be much more correct, in that it much closer approaches how an actual browser understands HTML (it does full parsing).
I made some other minor changes that should probably improve the normal performance a little tiny bit. Mostly, the original codebase was using
rawcode_flat_list = re.split('\n', rawcode_flat)
in several places. I don't see any reason to usere
for that, since your pattern is a fixed single char. I replaced all instances like that with the plain oldrawcode_flat_list = rawcode_flat.split('\n')
, which should push it down to the pure C layer.Lastly, I added the ability to change the indentation character. It was previously hard-coded to a literal tab character, and while I personally agree with that, it's probably better to not start another holy war, at least unintentionally.
If the
).
indent_with
parameter is specified, each indentation level is created with one instance of the parameter string. Otherwise, it defaults to 4 spaces (Caveats
This change also requires introducing a dependency, namely on the
bs4
package. I don't think this is a big deal, but that's just me.Hopefully, this contains 100% less asshole bug reports.