Re: Code block syntax highlighting

Dave The Dane <[email protected]>
Newsgroups gmane.text.xml.fop.user
Message-ID <[email protected]>
Can it handle the WITH Clause?
...probably the most unknown tool for structuring SQL Queries!

DaveLaw,
Subquery-Factoring Evangelist 😎

On 20/09/2022 07:45, Andreas Reichel wrote:
> Thanks Dave.
>
> I have written a good SQL Formatter 
> https://manticore-projects.com/JSQLFormatter/index.html
>
> I only will need to add xsl-fo output which is easy.
>
> All the best
> Andreas
>
> On 20 Sept 2022 06:01, Dave The Dane <[email protected]> 
> wrote:
>
>     Would ANTLR & their Grammars for Java, SQL, etc. make sense for this?
>     https://www.antlr.org/
>     https://github.com/antlr/grammars-v4
>
>     All the best,
>     DaveLaw
>
>     On 19/09/2022 10:07, Andreas Reichel wrote:
>
>         Klaus and Team,
>
>         thank you for your feedback.
>         I have actually figured out something working nicely:
>
>         1) based on Pygments
>         2) use the XSLFO Pygments formatter (can be installed from
>         PIP, the code is fairly simple and straight forward)
>         3) from your XML document containing the Code Block:
>         a) iterate through all code blocks
>                 b) call Pygments with the XSLFO Formatter and format
>         the block into a temporary XML file (your FO styled codeblock)
>                 c) when this succeeded, add to the Code Block node a
>         childnode with the absolute path to this temporary XML file
>         4) amend your XSL file and for each code-block use the
>         XSL:COPY-OF directive to insert the FO formatted content of
>         the temporary XML file into the final PDF directly. (Apply a
>         XSL:CHOOSE, when child exists then XSL:COPY-OF otherwise
>         XSL:VALUE.)
>         5) clean up all the temporary files from step 3)
>
>         Caveats:
>         a) you need to call Python Pygmentize from Java using
>         ProcessBuilder/Process (and react to failures)
>         b) Pygments understanding of the code is limited and the
>         highlighting can be questionable especially for SQL. However,
>         I will use my own SQL Formatter to properly format complex SQL
>         in FO
>
>         Cheers!
>
>
>
> --------------------------------------------------------------------- 
> To unsubscribe, e-mail: [email protected] 
> For additional commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.