From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id QHFDOGzaKmOgygAAbAwnHQ (envelope-from ) for ; Wed, 21 Sep 2022 11:33:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id AJ5mN2zaKmNY/AAAG6o9tA (envelope-from ) for ; Wed, 21 Sep 2022 11:33:32 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6A8D1DBF8 for ; Wed, 21 Sep 2022 11:33:32 +0200 (CEST) Received: from localhost ([::1]:36480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaw6l-0005T4-3c for larch@yhetil.org; Wed, 21 Sep 2022 05:33:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaw50-0005Sc-1Y for emacs-orgmode@gnu.org; Wed, 21 Sep 2022 05:31:42 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:37481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaw4u-00018F-HR for emacs-orgmode@gnu.org; Wed, 21 Sep 2022 05:31:41 -0400 Received: by mail-pj1-x1035.google.com with SMTP id o99-20020a17090a0a6c00b002039c4fce53so8172386pjo.2 for ; Wed, 21 Sep 2022 02:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date; bh=FhYB/JZvabUbaZ3zfJ+59RnhS2hMFnAb6ovGarqzlnw=; b=imGX12q4qdhzD2wzMRxH5oXgY4U6CSeyo3b/cG8THKKCniyt474UVCJJkK5Z9dLrlV RkKRxb86+mKRaZkR/2XYB/z93Jl+f9TaHdr1yi+E0dS1fDYs3BUwKZwEvZE3WjVozQWX HO9qxlV+ADLWWfYQomcdv0Ei+JS8m6cdvmuA/cPVEUeaHGaSolWg/ydKRg1gQbgmsv3+ dVorsVd+nlrCvTwvI0JNJ3ZlkxUJbzoymbIMhAB6NcYK9xF9Ds30X8jmLJ4BMeHyuSS6 J/dvUj2Ype0Deouw1Em/oF4JJVvzPJDU0kICKV4pt/8Y3B6Xw/YNmTWlmJGk89diFLpU 1H/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date; bh=FhYB/JZvabUbaZ3zfJ+59RnhS2hMFnAb6ovGarqzlnw=; b=JI9jcu2BpXm9TjZQiITLdvAdqr3Bx6ju42CB2ccfkYEymo1FXotY7Rg9lWK2ot0QDI JVM5cBqfo61UYrLqVzivwOOHJORfxYq75lo9eQAcZNQZQJ7rVLPZ+LrNIvokqy4yaIjq KQFIgJ+t8XlFsf9YY9EB8W498RQBR6elWFcnzD1Egr7ecmfTv/bzylopFHGKDjVl+cpZ jv6eQs4UZnjvqwXtMp/UqfOhy8ZRXTrH7z3iQ8UnIyDCnLaam9kDSv24YujTZt69pRzc +KCDxLq+pTYiams8x+sqOhvCEZIZtkYBAi5KTKjiMuMMWs9uNldSccQoAf/jbByxkBVT kqyQ== X-Gm-Message-State: ACrzQf1mR2z8C8tuK8S2zC+oBqiw376kIm4n5GgHMYFTzAfNsjxf2prI 6Q3WTnNolhSQKv2sv/4PME3wvoaunnFqwA== X-Google-Smtp-Source: AMsMyM6QgordsAXlnaWGEJAUPbvmXHkrU88VIr+U5ZhCPqrsQgHyhHbfOokIOwwQbeMmThJYUNYhpQ== X-Received: by 2002:a17:90b:48ce:b0:202:61d0:323 with SMTP id li14-20020a17090b48ce00b0020261d00323mr8663131pjb.157.1663752692527; Wed, 21 Sep 2022 02:31:32 -0700 (PDT) Received: from localhost ([2409:8970:a80:3a4:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id a29-20020a62d41d000000b0052dfe83e19csm1683035pfh.16.2022.09.21.02.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:31:24 -0700 (PDT) From: Ihor Radchenko To: reza Cc: "emacs-orgmode@gnu.org" Subject: Re: svg file from tikz picture In-Reply-To: <010201835a532739-08121085-5b99-4410-8f53-11b74f8d7dcc-000000@eu-west-1.amazonses.com> References: <3bc47afb-0bac-f6e8-1097-13dcb6f2be1f@housseini.me> <01020182a2d7ed46-7be65254-b93a-4e52-b275-c7dde587f51b-000000@eu-west-1.amazonses.com> <87o7wk34oe.fsf@localhost> <964a4117-ef6c-8d41-a25d-00e61c0c93d8@housseini.me> <01020182a6195e86-02f458a1-9efa-47ba-9b77-5669dbf06c6a-000000@eu-west-1.amazonses.com> <0931497c-9075-c214-c7f2-6507340a6d74@housseini.me> <87h72c3397.fsf@localhost> <01020182a62a5d2f-30791667-55f9-45ac-ae47-82377defea68-000000@eu-west-1.amazonses.com> <6daeb56b-163c-f862-5866-da624b43edd9@housseini.me> <01020182a6556f7e-bc5439ea-e56f-4acb-953c-7f3535eaedad-000000@eu-west-1.amazonses.com> <878rno301p.fsf@localhost> <7dcd1348-6faf-8464-38b5-8efac7c69250@housseini.me> <01020182a6670908-78f84b7b-c05b-42db-a109-0b828f53dc45-000000@eu-west-1.amazonses.com> <010201835a532739-08121085-5b99-4410-8f53-11b74f8d7dcc-000000@eu-west-1.amazonses.com> Date: Wed, 21 Sep 2022 17:32:17 +0800 Message-ID: <875yhhxece.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=yantar92@gmail.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1663752812; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=FhYB/JZvabUbaZ3zfJ+59RnhS2hMFnAb6ovGarqzlnw=; b=jBOXmBjTCv1g3bM7lzLjmeQm0LgH/Zsm4DrSNd8jtSh71iHDvRBD5nnG+TXAjCcH5rssQn JFlRbjEeGQmY3GGOmts76/tzE7GIUP9uZ4F/x3TAuZelqI12IjaDcelETr4BxmvU2bQMmK Cj7J5LeCI4LdVm6r+ehVnPfxF6A770EPw/PWfmBHCR8hs9WJu3m2rIzkPlHeOGDGp53pOD q0F7Fszp0fs3DI1MnTkNecW+96gHLv4oVYKSqWHQakX+xlrAK7jPaOu+LEIn6bDRkRlRzw nuuEzje51E0X1FLqTvGwK/1CRvD+Ant2gSgx24V8wDVvRAJEHhxWuIfbaACZRw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1663752812; a=rsa-sha256; cv=none; b=CAGPEcb8b/i1fCStkXkUrhMNB73uwOmPnfh1I1JaGhO3E7/VzpqBZFPnkCjgyRJvsUmsyF 7hqCvTDsRC+T1O6tG/8nd0GMqg5n2MnUCGvfcXoKZ89EHCCedyVL2koOozg3DJfmQlJ55G ySnTz/QzeVle+DqKwCGQSR/CGTZw2fSeIqFz1qWs10FwUR0eo8J7/7ZvvQd6Z+eL9P2tRx hGQJhEavx9ozm7SRqEoRmKdP7u+vxAiGG0F75wV+ENOEZJT8L3w1zekqUyN2Y26UuDX32G o9oJfi0fTxqFj6fk3k+dT/QfLbukoUDQ+rkGHhz+MslxoF8SKL5hq/cSB8yMUw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=imGX12q4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.34 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=imGX12q4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 6A8D1DBF8 X-Spam-Score: -3.34 X-Migadu-Scanner: scn1.migadu.com X-TUID: mzZG5hz/nF+1 reza writes: First of all, thanks a lot for digging into ob-latex! This file has not been touched seriously since 7 years ago and the last major change is 8 years ago (510e70379). > When having a look at the code inside ob-latex.el I also encountered a > few stuff which made me wondering: > > 1. png generation is done with the preview code inside org.el > (org-create-formula-image), there is also a perfectly fine svg preview > function but this does not get used for the svg extension which does the > svg conversion without any external tools like inkscape (see > https://github.com/bzg/org-mode/blob/main/lisp/ob-latex.el#L156 and > https://github.com/bzg/org-mode/blob/main/lisp/org.el#L3181) This, and many other oddities are likely related to the fact that org.el preview code is more up-to-date, while ob-latex have not been changed, including its assumptions about org.el's LaTeX preview. I suspect that some features in org.el were implemented separately, but did not get integrated with ob-latex. > 2. there is a tikz extension switch which does insert the code verbatim, > which in my opinion does create a whole bunch of problems (backend > dependency issues). Not to mention that it also mimics behaviour which > is reserved for the header :results (see > https://github.com/bzg/org-mode/blob/main/lisp/ob-latex.el#L177). Could you please elaborate? > 3. there is a html extension switch with an unclear purpose to me (in > what scenario would you want to produce an html file?). It also has some > strange (and contradicting) checking if an svg or an html file got > produced. As far as I can tell this code never gets executed and is > therefore pointless (see > https://github.com/bzg/org-mode/blob/main/lisp/ob-latex.el#L181). Well. We do not remove existing features unless there is strong justifications. See https://bzg.fr/en/the-software-maintainers-pledge/ As for the contradicting checking, it is likely a classic copy-paste error when html and svg branches of the code got split. > 4. the whole pdf generation looks like duplicate code which is already > done in other parts of the code base (ox-latex.el and for the svg > extension) it ais also not using the variable org-babel-latex-begin-env > and org-babel-latex-end-env (see > https://github.com/bzg/org-mode/blob/main/lisp/ob-latex.el#L225). Again, I am not sure here. It is a very old code. My best guess is that it was developer prior to ox-latex. The best hint I can provide is https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html that should document some details of the logic. > I don't want to criticize anyone, I just want to find answers for in my > opinion some strange decisions. Criticism is welcome as long as it is aiming to improve Org. No worries. If you want to dig further, I can also suggest to use git blame and dig into mailing list messages from Eric Schulte, the original author of ob-latex. > My propositions for refactoring is: > > 1. use the svg preview code for svg generation (and therefore ditching > the whole imagemagick headers) Note that imagemagick argument does more than you may expect. For example, one can apply various image effects on the generated file via imagemagick: https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html >> :imagemagick >> When not nil the source block is processed to pdf and the pdf is converted with ImageMagick to whatever is given as :file. Thus, the format is not limited to png. >> :iminoptions >> This is passed to ImageMagick before the pdf file. >> :imoutoptions >> This is passed to ImageMagick before the output file. That said, I do agree that re-using svg preview generation sounds like an improvement. But we need to be careful not to remove the existing functionality. > 2. remove the whole tikz generation completely > > 3. remove the whole html generation completely I did not see justification why we need to do it other than lack of ideas why they are useful. For now, I do not think that removing tikz/html generation is a good idea. According to https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html, tikz generation can be useful during LaTeX export. > 4. try to merge pdf generation with org.el and ox-latex.el or > incorporating it into he preview code and > org-preview-latex-process-alist (this is probably a whole project of it own) This sounds like a very good idea. I'd merge the preview code from org.el into ob-latex. > WDYT? Improving ob-latex is most welcome. I think that the first step is incremental refactor. Let's not remove features until we have less tangled code that is easier to understand. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92