emacs-orgmode
[Top][All Lists]
Advanced

[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: Sat, 07 May 2022 13:16:09 +0800

Timothy <tecosaur@gmail.com> writes:

Thanks for the updated patch! See some more comments below.

> +The first two options provide basic syntax
> +highlighting (listings), or none at all (verbatim).
> ...
> -Alternatively,
> +There are two options for more comprehensive fontification. The
> +first can be set with,

Maybe "The other two options"? Also, using first/second here is a bit
confusing because: (1) they are actually 3/4 in the above list; (2)
engraved is listed last.

> +The second more comprehensive option can be used with,

*can be set with

> -causes source code to be exported using the minted package as
> -opposed to listings.  If you want to use minted, you need to add
> -the minted package to `org-latex-packages-alist', for example
> +which causes source code to be exported using the minted package
> +as opposed to listings.  If you want to use minted, you need to
> +add the minted package to `org-latex-packages-alist', for example
>  using customize, or with

I feel slightly confused about using the word "package" here. Which one
refers to LaTeX package and which one to Emacs? I would state "Emacs
package" explicitly to highlight contrast with "LaTeX package".
  
> +(defcustom org-latex-engraved-preamble
> +  "\\usepackage{fvextra}
> +
> +[FVEXTRA-SETUP]
> +
> +\\renewcommand\\theFancyVerbLine{\\footnotesize\\color{black!40!white}\\arabic{FancyVerbLine}}

I'd like to see a comment on what it does.

> +\\usepackage{xcolor}
> +
> +\\providecolor{codebackground}{HTML}{f7f7f7}
> +\\providecolor{codeborder}{HTML}{f0f0f0}
> +\\providecolor{EFD}{HTML}{28292e}
> +
> +% TODO have code boxes keep line vertical alignment
> +\\usepackage[breakable,xparse]{tcolorbox}
> +\\DeclareTColorBox[]{Code}{o}%

Same request to provide a comment. Also, what it that % TODO doing
there? It is confusing.

Also, it is unclear what the [breakable,xparse] options to tcolorbox are
doing there and what will happen if the user removes them.

Further, I am wondering what is going to happen if the user happens to
have tcolorbox without options loaded via org-latex-packages-alist.

> +There is quite a lot of flexibility in what this preamble can be, as long as 
> it:
> +- Loads the fvextra package.
> +- Loads the package xcolor (if it is not already loader elsewhere).
> +- Defines a \"Code\" environment (note the capital C), which can be
> +  later used to wrap \"Verbatim\" environments (provided by fvextra).

The last point is not very clear. What kind of environment?

> +(defun org-latex-generate-engraved-preamble (info syntax-colours-p)
> +  "Generate the preamble to setup engraved code.
> +The result is constructed from `org-latex-engraved-preamble' and
> +`org-latex-engraved-options'."

This is relying on

(:latex-engraved-options nil nil org-latex-engraved-options)
(:latex-engraved-preamble nil nil org-latex-engraved-preamble)

If it changes any time in future (e.g. to allow per-file settings), the
docstring may be overlooked. 

> +       (let ((src-p (org-element-map (plist-get info :parse-tree)
> +                        '(src-block inline-src-block) #'identity))
> +             (fixedw-p
> +              (org-element-map (plist-get info :parse-tree)
> +                  '(example-block fixed-width) #'identity)))

I'd use FIRST-MATCH argument for org-element-map. It will be slightly
faster on large buffers.

> -                       (downcase org-lang)))
> +                       (downcase lang)))

I am not sure if this belongs to this patch. Please double check.

> +                            (mapcar 'length
> +                                    (org-split-string (car code-info)
> +                                                      "\n")))))

I am not sure how well it will work with e.g. Chinese characters in comments.

Best,
Ihor



reply via email to

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