Skip Menu |

This queue is for tickets about the PPI-Prettify CPAN distribution.

Report information
The Basics
Id: 92217
Status: resolved
Priority: 0/
Queue: PPI-Prettify

People
Owner: SILLYMOOS [...] cpan.org
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.03
Fixed in: (no value)



Subject: Bareword to ::Function conversion is too eager
Hi there, The http://perltricks.com/article/60/2014/1/13/Display-beautiful-Perl-code-in-HTML-without-JavaScript example looks great, but it demonstrates an issue with the built-in function detection being too aggressive: the 'length' hashkey (length => ... and {length}) are incorrectly highlighted as keywords rather than regular words. The current implementation upgrades all PPI::Token::Word instances to ::Function without checking for context - suspect it's not trivial to fix: ->{length} # bareword ->{length($x)} # function ->{length $x} # function ->{length 'abc'} # function ->{length length} # both functions LOOP: {length} # function Maybe worth a switch to disable the function conversion? This would at least give consistent output in the example. cheers, Tom
On Thu Jan 16 18:21:09 2014, TEAM wrote: Show quoted text
> Hi there, > > The http://perltricks.com/article/60/2014/1/13/Display-beautiful-Perl- > code-in-HTML-without-JavaScript example looks great, but it > demonstrates an issue with the built-in function detection being too > aggressive: the 'length' hashkey (length => ... and {length}) are > incorrectly highlighted as keywords rather than regular words. > > The current implementation upgrades all PPI::Token::Word instances to > ::Function without checking for context - suspect it's not trivial to > fix: > > ->{length} # bareword > ->{length($x)} # function > ->{length $x} # function > ->{length 'abc'} # function > ->{length length} # both functions > LOOP: {length} # function > > Maybe worth a switch to disable the function conversion? This would at > least give consistent output in the example. > > cheers, > > Tom
Hey Tom, Thanks for reporting these scenarios. I've made the function / keyword detection more sophisticated from v0.06 onwards. For example: - $object->length is recognised as a method call, not a built in. - {length => 4} is recognised as a string, not a built in. - {length 4} is recognised as a built in. - {length(4)} is recognised as a built in. - {length} is recognised as an interpolated string. - {length length} is recognised as two built ins. If you find any more scenarios let me know! Cheers, David