in reply to Pretty Print

Actually there are three questions involved

A) how to do this in a backwards compatible way to still be able to see the unformatted code. (Much posted code is broken, we need a fallback)

B) if syntax highlighting should be added too

C) how to implement this into the process chain

Brainstorm:

A) The only chance I see is an additional displaytype, like this users could switch between raw and formated source

B) perltidy can also produce highlighted code, but startup is slow and would cause a lag

C) patching perltidy to run in a server mode might be a solution.

Alternatives?

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re: Pretty Print (perltidy integration)

Replies are listed 'Best First'.
Re^2: Pretty Print (perltidy integration)
by LanX (Sage) on Sep 17, 2017 at 21:40 UTC
    > B) perltidy can also produce highlighted code, but startup is slow and would cause a lag

    > C) patching perltidy to run in a server mode might be a solution.

    FWIW:

    Actually no patch needed, this code from Perl::Tidy is very fast after initialization (which can take 1-2 secs)

    use Perl::Tidy; # ... # run in a loop reading source and outputting dest my $error = Perl::Tidy::perltidy( argv => $argv, source => \$source_string, destination => \$dest_string, stderr => \$stderr_string, errorfile => \$errorfile_string, + );

    Indenting some lines on laptop took under 0.05 sec and own formatters for "special" html are easily implemented.

    (trying to implement a so called "asynchronous process" interface for emacs now)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!