markwatkinson / luminous

Accurate and powerful syntax highlighting library
http://luminous.asgaard.co.uk
GNU Lesser General Public License v2.1
50 stars 5 forks source link

Specify the formatter via the class name on the command line #35

Closed J5lx closed 10 months ago

J5lx commented 9 years ago

Just an idea I came up with while working on #34. Now that Luminous is (well, will be) relying on Composers autoloader, wouldn’t it make sense to allow for specifying the formatter via the class name? Here’s why it would be useful (IMHO):

Of course this would also be nice for scanners, however some extra work would be required to make it work for those as well, since there needs to be a way to specify name and description of the language.

What do you think about this?

markwatkinson commented 9 years ago

This is a really good idea!

On 4 August 2015 at 19:22, J5lx notifications@github.com wrote:

Just an idea I came up with while working on #34 https://github.com/markwatkinson/luminous/pull/34. Now that Luminous is (well, will be) relying on Composers autoloader, wouldn’t it make sense to allow for specifying the formatter via the class name? Here’s why it would be useful (IMHO):

  • Suppose you’re working on a project J5lx\AwesomeProject which relies on Luminous for syntax highlighting.
  • For this project you created a custom PDF formatter J5lx\AwesomeProject\PdfFormatter (btw, I’m not actually working on a PDF formatter, even though this might be an interesting project)
  • You want to use the luminous CLI to test your formatter. You do this by running vendor/bin/luminous -f J5lx\AwesomeProject\PdfFormatter -i test.php -o test.pdf
  • By combining this with evince’s autoreload feature you can now efficiently test your PDF formatter!

Of course this would also be nice for scanners, however some extra work would be required to make it work for those as well, since there needs to be a way to specify name and description of the language.

What do you think about this?

— Reply to this email directly or view it on GitHub https://github.com/markwatkinson/luminous/issues/35.

J5lx commented 9 years ago

Regarding support for specifying scanners: How about adding an option -s name[,name...]:[scanner]:description? I think this syntax would cover pretty much every use case:

E.g. -s 'php,phtml:Luminous\\Scanners\\PhpScanner:PHP: Hypertext Preprocessor' would yield name => ["php", "phtml"], scanner => "Luminous\Scanners\PhpScanner" and description => "PHP: Hypertext Preprocessor".

markwatkinson commented 9 years ago

Sounds good to me.