bradyvercher / gistpress

WordPress plugin to add Gist oEmbed and shortcode support with caching.
GNU General Public License v2.0
143 stars 28 forks source link

Allow unlimited max lines #59

Closed GaryJones closed 7 years ago

GaryJones commented 8 years ago

https://github.com/bradyvercher/gistpress/blob/develop/includes/class-gistpress.php#L310-L319 handles parsing of the lines attribute, for only showing a limited portion of the Gist.

If there's no hyphen (lines="5"), then only one line is shown as min and max are the same.

Otherwise the value is exploded on the hyphen, and the min and max values are set accordingly. However, that can mean knowing the number of lines in the gist, or supplying 2-9999 as the value.

I'd like there to be a condition that handled that automatically i.e. 2- would allow a check for max value being empty, and if so, assign it to a filterable high value such as 9999. That way, if the Gist ever gets updated to include more lines, the display of it won't end up being cut off.

Think substr() with no third argument.

bradyvercher commented 8 years ago

It looks like that format should already work. The empty max value gets converted to 0 and the processing method checks to see if the value is truthy before deciding if the line should be excluded.

It could probably be made more explicit using something like 2+ for the format, but I think this is already doable.

GaryJones commented 7 years ago

I've been using 2- recently, and so far, it seems to work.