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

Starting Line Number #7

Closed GaryJones closed 11 years ago

GaryJones commented 11 years ago

Feature request - add a shortcode attribute which allows the choice of starting line number.

That would allow a post such as http://code.garyjones.co.uk/genesis-grid-loop/ to breakdown the large gist into smaller code snippets for easier explanation (using the lines attribute), but to also match the equivalent line numbers from the large gist.

My initial thinking would be along the lines of grabbing the .line-numbers <td> and adding the <span> elements to an array. Then flipping them around and start replacing the id and rel attributes and plain number, from the highest first, so that numbers like 21 are replaced wholly before 1 and 2 are.

bradyvercher commented 11 years ago

I don't think I'm following here. Using the lines attribute should already ensure the line numbers stay in sync. Are you wanting to using a separate file within the Gist for the snippet and specify its starting line number so it syncs up with the "full" file?

GaryJones commented 11 years ago

I'm not sure where I was getting my example from, as of course, yes, using the lines attribute results in sync numbers already.

How about a different use case - see the first gist of http://code.garyjones.co.uk/gravity-forms-jquery-ui-datepicker-too-narrow/ - line numbers happen to be hidden, but currently start at 1. I'd like to be able to drop the first comment, and then start the numbering at 583, so it coincides with the real jQuery UI Datepicker 1.6 file.

bradyvercher commented 11 years ago

This should be taken care of in the latest commit. Let me know if you have any problems with it.