Ox unindents lines but I can't see when
Dear all, I'm currently working on a tiny project org-inline-blocks that aims to provide a simple syntax for latex-blocks in org-mode based on indent. Namely, instead of #+begin_theorem ... #+end_theorem, it will be possible to write "Theorem." and the export will be based on indent to decide whether some text belongs to the block or not. Unfortunately, ox modifies the indentation of the org-text before running the filter functions. Here is an illustration. Consider the following file `hamlet.org`: --- *Prince Hamlet of Denmark is the son of the recently deceased King Hamlet, and nephew of King Claudius, his father’s brother and successor. Claudius hastily married King Hamlet’s widow, Gertrude, Hamlet’s mother, and took the throne for himself. Denmark has a long-standing feud with neighbouring Norway, in which King Hamlet slew King Fortinbras of Norway in a battle some years ago.Although Denmark defeated Norway and the Norwegian throne fell to King Fortinbras’s infirm brother, Denmark fears that an invasion led by the dead Norwegian king’s son, Prince Fortinbras, is imminent.* *On a cold night on the ramparts of Elsinore, the Danish royal castle, the sentries Bernardo and Marcellus discuss a ghost resembling the late King Hamlet which they have recently seen, and bring Prince Hamlet’s friend Horatio as a witness.* *---* and this tiny `org-export-filter-body`'s function: --- *(with-eval-after-load 'ox (defun org-strange-behavior (text backend info)"Print text, as read by the export-filter-body functions."(when (org-export-derived-backend-p backend 'latex) (message text))) (add-to-list 'org-export-filter-body-functions 'org-strange-behavior))* *---* When exporting `hamlet.org` in whatever format, the Message buffer shows this: --- *Prince Hamlet of Denmark is the son of the recently deceased King Hamlet, and nephew of King Claudius, his father’s brother and successor. Claudius hastily married King Hamlet’s widow, Gertrude, Hamlet’s mother, and took the throne for himself. Denmark has a long-standing feud with neighbouring Norway, in which King Hamlet slew King Fortinbras of Norway in a battle some years ago.Although Denmark defeated Norway and the Norwegian throne fell to King Fortinbras’s infirm brother, Denmark fears that an invasion led by the dead Norwegian king’s son, Prince Fortinbras, is imminent.On a cold night on the ramparts of Elsinore, the Danish royal castle, the sentries Bernardo and Marcellus discuss a ghost resembling the late King Hamlet which they have recently seen, and bring Prince Hamlet’s friend Horatio as a witness.* *---* *My question is thus: how can I prevent ox from unindenting the last line ? * I explored ox as much as I could, and did not find anything promising :/. I'm aware of an `org-export-preserve-breaks` variable but it preserves too much things (and causes export to be odd, in my opinion). If I run org-unindent-buffer in the buffer, the last line is unindented. But this function is not called in ox as far as I saw. Moreover, given that I'm writing a package, using an org-verse environment all around is not suitable. Best, Leo
Re: Ox unindents lines but I can't see when
Hi, I can not reproduce this (ie. my second paragraph is unindented). Here comes my bug.org/org.txt files I have using ASCII export. I run Emacs 28.2, I just updated the packages. I think this is not of importance here, but I use Doom Emacs (up-to-date also). I confirm that my goal is to have the indentation of the second paragraph preserved. Best, Leo Le sam. 1 oct. 2022 à 07:31, Ihor Radchenko a écrit : > Léo Ackermann writes: > > > I'm currently working on a tiny project org-inline-blocks that aims to > > provide a simple syntax for latex-blocks in org-mode based on indent. > > Namely, instead of #+begin_theorem ... #+end_theorem, it will be possible > > to write "Theorem." and the export will be based on indent to decide > > whether some text belongs to the block or not. > > Unfortunately, ox modifies the indentation of the org-text before running > > the filter functions. Here is an illustration. > > > > Consider the following file `hamlet.org`: > > ... > > *---* > > and this tiny `org-export-filter-body`'s function: > > ... > > *My question is thus: how can I prevent ox from unindenting the last line > > ? * > > I am not sure if I understand your problem. > I tried to export the attached bug.org file to ASCII (C-c C-e t U) and > got the attached bug.txt file. > > The indentation of the second paragraph is preserved. > > Do I miss something? > > > -- > 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 > Table of Contents ─ Prince Hamlet of Denmark is the son of the recently deceased King Hamlet, and nephew of King Claudius, his father’s brother and successor. Claudius hastily married King Hamlet’s widow, Gertrude, Hamlet’s mother, and took the throne for himself. Denmark has a long-standing feud with neighbouring Norway, in which King Hamlet slew King Fortinbras of Norway in a battle some years ago. Although Denmark defeated Norway, Denmark fears that an invasion led by the dead Norwegian king’s son, Prince Fortinbras, is imminent. Prince Hamlet of Denmark is the son of the recently deceased King Hamlet, and nephew of King Claudius, his father’s brother and successor. Claudius hastily married King Hamlet’s widow, Gertrude, Hamlet’s mother, and took the throne for himself. Denmark has a long-standing feud with neighbouring Norway, in which King Hamlet slew King Fortinbras of Norway in a battle some years ago. Although Denmark defeated Norway, Denmark fears that an invasion led by the dead Norwegian king’s son, Prince Fortinbras, is imminent.
An org-latex face
Hi, When it comes to preview inline LaTeX fragments within org-mode, the org package applies the `org-block` face. It would be nice to *treat inline latex block specially*, to make integration of the those preview-block easier when surrounded by plaintext. This feature would allow to have a theme that highlight blocks (source code, examples) without the background artifact you can see in attachment when previewing latex fragments. It seems that a way to adress this is to add another `org-latex` face, as we already have with `org-quote`. One could also change the `org-src-font-lock-fontify-block` function to include a subroutine for inline latex blocks. Nevertheless, the later seems to be harder to customize... What do you think of this ? Thank you for your job on this amazing program! Have a nice day! Best, Leo
Re: An org-latex face
Hi both! Thanks a lot for your answers, it looks pretty now :) Best, Leo Le mar. 1 juin 2021 à 10:43, Timothy a écrit : > Hi Léo, > > For what it’s worth, I currently make do with: > > (setq org-highlight-latex-and-related '(native script entities))(add-to-list > 'org-src-block-faces '("latex" (:inherit default :extend t))) > > All the best, > *Timothy* > > * From*: Léo Ackermann <%22Léo+ackermann%22+%3cleo.ko...@gmail.com%3E> > * Subject*: An org-latex face > * To*: "emacs-orgmode@gnu.org" > * Date*: Tue, 01 Jun 2021 14:04:47 +0800 > Hi, > > When it comes to preview inline LaTeX fragments within org-mode, the org > package applies the `org-block` face. It would be nice to *treat inline > latex block specially*, to make integration of the those preview-block > easier when surrounded by plaintext. This feature would allow to have a > theme that highlight blocks (source code, examples) without the background > artifact you can see in attachment when previewing latex fragments. > It seems that a way to adress this is to add another `org-latex` face, as > we already have with `org-quote`. One could also change the > `org-src-font-lock-fontify-block` function to include a subroutine for > inline latex blocks. Nevertheless, the later seems to be harder to > customize... > What do you think of this ? > > Thank you for your job on this amazing program! > Have a nice day! > > Best, > Leo >
Re: Large source block causes org-mode to be unusable
Hi all, Many thanks for those advices! I am new to org-mode but, is there a reason why #+BEGIN_proof #+END_proof and other org-latex-special-block are treated as block ? I mean; those #+... aim, as far as I understand, to give tips to org-export for prettier exports but nothing else (between those #+... you still need to write in org). I highlight that org-latex-special-block have nothing to do (in my point of view) with #+BEGIN_latex / #+END_latex that allow a user to insert some LaTeX within the document (e.g. Tikz pictures). Therefore, it might a great idea to take #+BEGIN_proof & co into account only when it comes to export the document. The proofs/definitions/theorems will no longer be considered as block, and fast fontification may follow :) What do you think of this ? Best, Leo Le mar. 22 juin 2021 à 09:55, Eric S Fraga a écrit : > On Monday, 21 Jun 2021 at 14:36, John Hendy wrote: > > [...] or split the block into a number of more reasonably sized > > cells. > > This is what I do in practice. I then use noweb syntax to bring > everything together. In my case, the long LaTeX blocks tend to be tikz > pictures. > > Using (native) for org-highlight-latex-and-related also helps in most > cases. > > For me, the remaining performance issue is working with big tables and > I've not found a solution to this. > -- > : Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-566-gf0198e > : Latest paper written in org: https://arxiv.org/abs/2106.05096 > >
Re: Large source block causes org-mode to be unusable
> I am not sure what you are asking. What specific treatment are you referring to? I suggest that special block in LateX export ( https://orgmode.org/manual/Special-blocks-in-LaTeX-export.html) may be treated differently. Once again, I'm new to org-mode, but here is my intuition: - What is happening now. The #+BEGIN_proof / #+END_proof keywords cause my proof to be seen as a block. Therefore, babel fontification is called to highlight syntax of my proof within my buffer. Timothy already discussed here how inefficient the babel fontification is. - What could happen. Changing (somewhere) the treatment of #BEGIN_proof & co the following way: Assign them to a new face "latex_export_sugar" and ignore them while editing. Doing this, the fontification of the org proof will be made as usual and will be fast enough. While exporting, replace #+BEGIN_proof by \begin{proof} and so on... Do you see what I mean ? Best, Le mar. 22 juin 2021 à 14:13, Eric S Fraga a écrit : > On Tuesday, 22 Jun 2021 at 13:20, Léo Ackermann wrote: > > I am new to org-mode but, is there a reason why #+BEGIN_proof #+END_proof > > and other org-latex-special-block are treated as block ? > > I am not sure what you are asking. What specific treatment are you > referring to? > > -- > : Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-567-g22bf80 > : Latest paper written in org: https://arxiv.org/abs/2106.05096 >
Re: Large source block causes org-mode to be unusable
Neither do I (concerning the special fontification). Nevertheless, if you look at the profiler report (1st mail), the fontification process differ from the usual one (see attached screenshot) *because* the proof is considered as a block by org-mode. [image: image.png] Best, Le mar. 22 juin 2021 à 15:03, Eric S Fraga a écrit : > On Tuesday, 22 Jun 2021 at 14:32, Léo Ackermann wrote: > > Do you see what I mean ? > > I do but I guess I must have a differently configured system as I do not > see any special fortification due to being in a special block. > > However, I see nothing in my configuration that affects special blocks. > > -- > : Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-567-g22bf80 > : Latest paper written in org: https://arxiv.org/abs/2106.05096 >
Re: Large source block causes org-mode to be unusable
Hi, As I found no convenient solution, I will try to write a small module that adress this problem. It will be a good occasion to discover Elisp :). It is thought as an alternative to org-special-latex-block: efficient fontification using default face, folding environment to hide proofs, pretty latex export... @EricSFrada, would you mind sharing your code for your proof sections ? If you've got ideas for this module, or/and want to participate to its development, please let me know :) Best, Le jeu. 24 juin 2021 à 09:59, Eric S Fraga a écrit : > On Wednesday, 23 Jun 2021 at 15:42, Gennady Uraltsev wrote: > > In Org Mode, headings cannot "terminate" i.e. only a new section can > > stop a previous one. > > True. > > What I do for cases where I want "separation" for visibility etc. is use > headings at the same level but tell the exporter to ignore the actual > headings when exporting. So I frequently have something like this: > > #+begin_src org > ,* Section heading > ,** introduction to section :ignoreheading: > ,** statement of problem :ignoreheading: > ,** proof :ignoreheading: > ,#+latex: \begin{proof} > proof goes here > ,#+latex: \end{proof} > ,** continuation of section :ignoreheading: > ,* Next section > #+end_src > > also showing how you can introduce a proof environment without using > special blocks and hence maybe help with speed. (noting that you could > do the same for HTML.) > > I have a filter for export that strips headings that have the > :ignoreheading: tag. I believe there's something similar built-in now? > > This approach makes for easier navigation in the document (for me) and > helps keep that bird's eye view of what I am writing. > -- > : Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-571-gc591be > : Latest paper written in org: https://arxiv.org/abs/2106.05096 > >
[BUG] Conflict between org-emphasis and org-latex
Hi! I noticed that in org@888aaa97c0ce331097787333d0d712dd6e4d078f, the following happens: When writing `Consider $a^{*}$ and $b^{*}$` in an org-mode buffer, the two stars match together, causing "and" to appear in bold case. Any idea to fix this unwanted behavior ? Thanks for making org-mode better every day! Leo
Re: [BUG] Conflict between org-emphasis and org-latex
Hi Juan Manuel, I agree that some tricks exist in order to prevent this behavior. Nevertheless, I think that this bug has been introduced recently (I never noticed it before) and has to be corrected properly (as this is a really basic use of org-mode). Unfortunately, I can barely understand elisp... so writing a patch is far away from what I can do :/ Best, Leo Le dim. 26 sept. 2021 à 14:57, Juan Manuel Macías a écrit : > Hi Léo, > > Léo Ackermann writes: > > > Hi! > > I noticed that in org@888aaa97c0ce331097787333d0d712dd6e4d078f, the > > following happens: > > When writing `Consider $a^{*}$ and $b^{*}$` in an org-mode buffer, the > > two stars match together, causing "and" to appear in bold case. > > > > Any idea to fix this unwanted behavior ? > > You can insert a zero width space character (U+200B), to prevent that > segment is fontified as emphasis [see the Manual in the section `Escape > Character']. It is enough with insert the character after one of the > asterisks: M-x insert-char RET 200b RET. I also recommend that you look > at this section on Timothy's blog `This Month in Org': > https://blog.tecosaur.com/tmio/2021-05-31-async.html#easy-zero-width > > Best regards, > > Juan Manuel >
Re: [BUG] Conflict between org-emphasis and org-latex
Hi, I’ll try to do so ;) Let you know, Leo > Le 26 sept. 2021 à 19:01, Timothy a écrit : > > > Hi Léo, > > You write: >> Nevertheless, I think that this bug has been introduced recently (I never >> noticed it before) and has to be corrected properly (as this is a really >> basic use of >> org-mode). >> Unfortunately, I can barely understand elisp... so writing a patch is far >> away from what I can do :/ > > Do you think you might be able to identify a "good" commit and bisect > the bug? That would be a tremendous help for solving it, and shouldn't > require any elisp. > > -- > Timothy