Added location information to Kramdown::Element.#96
Added location information to Kramdown::Element.#96gettalong merged 1 commit intogettalong:masterfrom
Conversation
* Uses StringScannerKramdown (which has current_line_number method) instead of StringScanner. * Records :location option on all Kramdown::Elements where this makes sense and where it is easily implemented. * Initializes nested StringScanners with their parent Element's :location as start_line_number. * Adds tests for :location information. * Adds tests for StringScannerKramdown. See pull request for more details.
How it worksWhenever we instantiate a new Kramdown uses nested StringScanners for StringScanner was made multi-byte character aware in Ruby 2.0 (via Design considerations
Performance impactI haven't run a benchmark, so I'm not sure what the performance impact is. The biggest hit probably comes from computing If performance is an issue, then we could change all instances of Alternatively, there may be a more efficient way to keep track of line numbers in StringScanner. Maybe we could keep a running count of Element types that don't record :location information
:location information can be added to all of the above if desired. |
|
Thanks for the pull request and detailed information! I'm rather busy at the moment but I will try to have a look at it this weekend! |
|
I have run some benchmarks and the performance impact does not seem to be that much. I also moved the custom StringScanner class to Kramdown::Utils. |
|
Thank you for accepting the pull request! Good call on moving the custom On 2013-12-08 2:57 , Thomas Leitner wrote:
|
See pull request for more details.