* Ox unindents lines but I can't see when
@ 2022-09-30 10:40 Léo Ackermann
2022-10-01 5:32 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Léo Ackermann @ 2022-09-30 10:40 UTC (permalink / raw)
To: Org Mode List
[-- Attachment #1: Type: text/plain, Size: 3324 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 3795 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ox unindents lines but I can't see when
2022-09-30 10:40 Ox unindents lines but I can't see when Léo Ackermann
@ 2022-10-01 5:32 ` Ihor Radchenko
2022-10-01 7:48 ` Léo Ackermann
0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2022-10-01 5:32 UTC (permalink / raw)
To: Léo Ackermann; +Cc: Org Mode List
[-- Attachment #1: Type: text/plain, Size: 964 bytes --]
Léo Ackermann <leo.komba@gmail.com> 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?
[-- Attachment #2: bug.org --]
[-- Type: application/vnd.lotus-organizer, Size: 855 bytes --]
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.
[-- Attachment #3: bug.txt --]
[-- Type: text/plain, Size: 960 bytes --]
Ihor Radchenko
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 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.
[-- Attachment #4: Type: text/plain, Size: 206 bytes --]
--
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ox unindents lines but I can't see when
2022-10-01 5:32 ` Ihor Radchenko
@ 2022-10-01 7:48 ` Léo Ackermann
2022-10-01 8:01 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Léo Ackermann @ 2022-10-01 7:48 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Org Mode List
[-- Attachment #1.1: Type: text/plain, Size: 1692 bytes --]
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 <yantar92@gmail.com> a écrit :
> Léo Ackermann <leo.komba@gmail.com> 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
>
[-- Attachment #1.2: Type: text/html, Size: 2636 bytes --]
[-- Attachment #2: bug.txt --]
[-- Type: text/plain, Size: 622 bytes --]
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.
[-- Attachment #3: bug.org --]
[-- Type: text/org, Size: 540 bytes --]
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ox unindents lines but I can't see when
2022-10-01 7:48 ` Léo Ackermann
@ 2022-10-01 8:01 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-10-01 8:01 UTC (permalink / raw)
To: Léo Ackermann; +Cc: Org Mode List
Léo Ackermann <leo.komba@gmail.com> writes:
> 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.
Ok. I see what is happening.
The file you provided here is importantly different from the text you
had in text part of your email.
The text I tried had multiple lines with the smallest common indentation =
0. The text you attached consists of a single line with a non-zero
common indentation (indentation = the single line indentation).
As a basic principle of Org markup, Org ignores common indentation of
paragraphs and other syntax elements inside section. Thus, your
paragraph indentation gets removed. It is done in
`org-element-normalize-contents'.
If you want to force Org to ignore the one-line paragraph indentation,
you can put an escape character [zero-width space] (see
https://orgmode.org/manual/Escape-Character.html#Escape-Character) at
the beginning of the line. Alternatively, you can put a non-exportable
object like @@nil:@@.
Hope it helps.
--
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-01 8:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-30 10:40 Ox unindents lines but I can't see when Léo Ackermann
2022-10-01 5:32 ` Ihor Radchenko
2022-10-01 7:48 ` Léo Ackermann
2022-10-01 8:01 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).