[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] New LaTeX code export option: engraved

From: Ihor Radchenko
Subject: Re: [PATCH] New LaTeX code export option: engraved
Date: Thu, 05 May 2022 16:48:39 +0800

Timothy <tecosaur@gmail.com> writes:

> This patchset accomplishes two things:
> 1. It refactors the overly large `org-latex-src-block' function, and makes a 
> few
>    other improvements to pre-existing code
> 2. It adds a new option for exporting code, named (you guessed it!) “engraved”
> What is this new option, and why do we want it?
> About a year ago I started work on a package that generalises the 
> functionality
> of `htmlize.el', termed `engrave-faces'
> (<https://elpa.gnu.org/packages/engrave-faces.html>). It provides the ability 
> to
> extract font-lock information and export it to a number of formats: html, 
> ansi,
> and (crucially) LaTeX! Since the LaTeX export is built on the `fvextra' 
> (LaTeX)
> package (like pygments), the vast majority of the Minted options you’re used 
> to
> just carry over.
> This allows for a result that is, I think, straight up better than all the
> pre-existing options. For starters, you can now apply syntax highlighting to 
> any
> language you have a major mode for.

Implementing fontification using Emacs capabilities is certainly a step
in the right direction. LaTeX support for fontification has always been

Some comments:

- I tried to test your patch, and it only works partially. There is some
  stray text caused by LaTeX errors:

Attachment: test.org
Description: Lotus Organizer

Attachment: test.pdf
Description: Adobe PDF document

- You did not add a NEWS entry and did not update the manual in your patch.
- There are many compiler warnings emitted when compiling Org with your patch

> +(defun org-latex-inline-src-block--minted (info code lang)
> +  (let ((mint-lang (or (cadr (assq (intern lang)
> +
> +(defun org-latex-inline-src-block--listings (info code lang)
> +  (let* ((lst-lang (or (cadr (assq (intern lang)

The docstrings are missing in the above.

> -Alternatively,
> +There are two fancier options for fontification.
> +
> +The first fancy alternative,

I am not sure why, but the word fancy feels slightly annoying here.

> +
> +The styling of the engraved result can customised with
> +`org-latex-engraved-preamble' and `org-latex-engraved-options'.
> +The default preamble also uses the tcolorbox LaTeX package in
> +addition to fvextra.

Since engraved is not entirely relying on LaTeX options, a lot of
customisation is not mentioned in this docstring. AFAIU, color
customisation is only possible by changing defcustoms from engrave-faces

Another related note is what is going to happen in beamer export with
dark background. The default face mapping in engrave-faces is using some
kind of light theme, which may lose all the contrast on not-light

> +\\renewcommand\\theFancyVerbLine{\\footnotesize\\color{black!40!white}\\arabic{FancyVerbLine}}
> +
> +\\providecolor{codebackground}{HTML}{f7f7f7}
> +\\providecolor{codeborder}{HTML}{f0f0f0}
> +\\providecolor{EFD}{HTML}{28292e}

> +(defcustom org-latex-engraved-options
> +  '(("commandchars" . "\\\\\\{\\}")
> +    ("highlightcolor" . "white!95!black!80!blue")
> +    ("breaklines" . "true")
> +    ("breaksymbol" . 
> "\\color{white!60!black}\\tiny\\ensuremath{\\hookrightarrow}"))
> +  "Association list of options for the latex fvextra package when engraving 
> code.

It feels that codebackground, codeborder, and EFD should be customizable
by org-latex-engraved-options.

> +(defun org-latex-generate-engraved-preamble (info syntax-colours-p)


> +(defun org-latex-inline-src-block--engraved (info code lang)
> +  (if (require 'engrave-faces-latex nil t)
> ...
> +    (message "Cannot engrave inline src block, `engrave-faces-latex' is 
> unavailible.")
> +    (insert (org-latex--text-markup code 'code info))))

Why message instead of error?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]