miyuchina / mistletoe

A fast, extensible and spec-compliant Markdown parser in pure Python.
MIT License
791 stars 110 forks source link

Use strict PascalCase for class names #182

Closed pbodnar closed 11 months ago

pbodnar commented 1 year ago

The historically used "lenient" usage of the PascalCase (pascal case) convention in mistletoe is quite impractical when it comes to introducing more complex names. I suggest here to use the strict variant which doesn't have this problem and leads to a more consistent code base.

E.g. change HTMLRenderer to HtmlRenderer, HTMLBlock to HtmlBlock.

For backwards compatibility, we can introduce aliases for the old names, marking them as deprecated.

pbodnar commented 1 year ago

CC @anderskaplan.

pydsigner commented 11 months ago

Not impressed by this change. PEP-8 says:

Note: When using acronyms in CapWords, capitalize all the letters of the acronym. Thus HTTPServerError is better than HttpServerError.

Meanwhile, this is a hard-breaking change for anyone who uses mistletoe.HTMLRenderer rather than mistletoe.html_renderer.HTMLRenderer.

pbodnar commented 11 months ago

@pydsigner, thanks for letting us know and sorry for the inconvenience! I have just released v1.2.1 where mistletoe.HTMLRenderer should work again.

Regarding the change to "strict PascalCase" itself, you are right that PEP-8 suggests the other way. AFAIK in C-style languages (which Python isn't, I know ;)), HtmlRenderer is the recommended way to go (see e.g. here), even if there is just one acronym in the name. But I'm not strictly against returning to the PEP-8 style, provided it will be requested by the mistletoe community...