gistpress
gistpress copied to clipboard
Refactor process_gist_html() method
The process_gist_html()
method currently does too much.
It:
- removes line number cell if line numbers have been disabled.
- removes the meta section if meta has been disabled.
- pulls out the an array of lines of code from the HTML.
- restricts the line numbers being displayed, if necessary.
- further tidies up the array of lines for further processing.
- removes lines of code if they are not to be displayed.
- adds classes to each line.
- joins all the html back together.
That is far too much responsibility for a single method, and should be split into several smaller protected methods that would be more easily testable and easier to read and maintain.
This gist processor may even be better being pulled out into a new class?
Something to consider is how changes to the HTML structure will affect the way the plugin works. Right now it's reliant on the current markup, so if there's a way we can break the processor out and make it easy to update in the event the markup does change, that would be ideal. We may also want to modify the default class names to move away from the .pre-
suffix.