emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* substitutions in html export?
@ 2022-07-17 14:16 kevinbanjo
  2022-07-17 14:25 ` Ihor Radchenko
  0 siblings, 1 reply; 11+ messages in thread
From: kevinbanjo @ 2022-07-17 14:16 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 257 bytes --]

Hi everyone:

Is there any way to make something like this actually work?

#+title:test
#+macro: num 50

#+name: numbers
#+begin_src emacs-lisp no-export
40
#+end_src

#+begin_export html

the result is {{{num}}}

another result is <<numbers>>
#+end_export

[-- Attachment #2: Type: text/html, Size: 376 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-17 14:16 substitutions in html export? kevinbanjo
@ 2022-07-17 14:25 ` Ihor Radchenko
  2022-07-17 17:18   ` kevinbanjo
  2022-07-17 20:54   ` kevinbanjo
  0 siblings, 2 replies; 11+ messages in thread
From: Ihor Radchenko @ 2022-07-17 14:25 UTC (permalink / raw)
  To: kevinbanjo; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 98 bytes --]

See inline calls in
https://orgmode.org/manual/Evaluating-Code-Blocks.html#Evaluating-Code-Blocks

[-- Attachment #2: Type: text/html, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-17 14:25 ` Ihor Radchenko
@ 2022-07-17 17:18   ` kevinbanjo
  2022-07-17 18:54     ` Berry, Charles
  2022-07-17 20:54   ` kevinbanjo
  1 sibling, 1 reply; 11+ messages in thread
From: kevinbanjo @ 2022-07-17 17:18 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 455 bytes --]

On Sun, Jul 17, 2022 at 7:24 AM Ihor Radchenko <yantar92@gmail.com> wrote:

> See inline calls in
> https://orgmode.org/manual/Evaluating-Code-Blocks.html#Evaluating-Code-Blocks
>

I did this and it didn't work (but the one outside the export block did):

#+title:test

#+name: numbers
#+begin_src emacs-lisp :exports none
40
#+end_src

#+begin_export html

the result is call_numbers()

#+end_export

the result outside an export block is call_numbers()

[-- Attachment #2: Type: text/html, Size: 1083 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-17 17:18   ` kevinbanjo
@ 2022-07-17 18:54     ` Berry, Charles
  2022-07-17 19:19       ` kevinbanjo
  2022-07-18  1:16       ` kevinbanjo
  0 siblings, 2 replies; 11+ messages in thread
From: Berry, Charles @ 2022-07-17 18:54 UTC (permalink / raw)
  To: kevinbanjo; +Cc: Ihor Radchenko, emacs-orgmode

Kevin,

> On Jul 17, 2022, at 10:18 AM, kevinbanjo <kevinbanjo@gmail.com> wrote:
> 
> 
> 
> On Sun, Jul 17, 2022 at 7:24 AM Ihor Radchenko <yantar92@gmail.com> wrote:
> See inline calls in https://orgmode.org/manual/Evaluating-Code-Blocks.html#Evaluating-Code-Blocks
> 
> I did this and it didn't work (but the one outside the export block did):
> 
> #+title:test
> 
> #+name: numbers
> #+begin_src emacs-lisp :exports none
> 40 
> #+end_src
> 
> #+begin_export html
> 
> the result is call_numbers()
> 
> #+end_export


The export block provides text that is to be used "as is" by the html backend. So, "call_numbers()" is treated as html.

You need to construct the export block programmatically. Maybe something like 

#+begin_src emacs-lisp :results html :exports results :var num=numbers()
   (format "the result is %d" num )
#+end_src

 
HTH,

Chuck





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-17 18:54     ` Berry, Charles
@ 2022-07-17 19:19       ` kevinbanjo
  2022-07-17 23:18         ` Ihor Radchenko
  2022-07-18  1:16       ` kevinbanjo
  1 sibling, 1 reply; 11+ messages in thread
From: kevinbanjo @ 2022-07-17 19:19 UTC (permalink / raw)
  To: Berry, Charles; +Cc: Ihor Radchenko, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1184 bytes --]

On Sun, Jul 17, 2022 at 11:54 AM Berry, Charles <ccberry@health.ucsd.edu>
wrote:

> Kevin,
>
> > On Jul 17, 2022, at 10:18 AM, kevinbanjo <kevinbanjo@gmail.com> wrote:
> >
> >
> >
> > On Sun, Jul 17, 2022 at 7:24 AM Ihor Radchenko <yantar92@gmail.com>
> wrote:
> > See inline calls in
> https://orgmode.org/manual/Evaluating-Code-Blocks.html#Evaluating-Code-Blocks
> >
> > I did this and it didn't work (but the one outside the export block did):
> >
> > #+title:test
> >
> > #+name: numbers
> > #+begin_src emacs-lisp :exports none
> > 40
> > #+end_src
> >
> > #+begin_export html
> >
> > the result is call_numbers()
> >
> > #+end_export
>
>
> The export block provides text that is to be used "as is" by the html
> backend. So, "call_numbers()" is treated as html.
>
> You need to construct the export block programmatically. Maybe something
> like
>
> #+begin_src emacs-lisp :results html :exports results :var num=numbers()
>    (format "the result is %d" num )
> #+end_src
>
>
> HTH,
>
> Chuck
>
>
>
Thanks for that Chuck.   It would seem a lot cleaner if there was a hook or
something one could run that would just expand macros in export blocks
before exporting them.

-Kevin

[-- Attachment #2: Type: text/html, Size: 2047 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-17 14:25 ` Ihor Radchenko
  2022-07-17 17:18   ` kevinbanjo
@ 2022-07-17 20:54   ` kevinbanjo
  2022-07-17 23:21     ` Ihor Radchenko
  2022-07-18 19:00     ` Berry, Charles
  1 sibling, 2 replies; 11+ messages in thread
From: kevinbanjo @ 2022-07-17 20:54 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

When I look at the doc string for (org-macro-replace-all) it says:


*Optional argument KEYWORDS, when non-nil is a list of keywords,*
*as strings, where macro expansion is allowed.*

I tried passing it '("export-block") but it didn't work, but it seems like
something like that should be close.

This whole area of org documentation seems pretty obtuse, with few examples.

[-- Attachment #2: Type: text/html, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-17 19:19       ` kevinbanjo
@ 2022-07-17 23:18         ` Ihor Radchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Ihor Radchenko @ 2022-07-17 23:18 UTC (permalink / raw)
  To: kevinbanjo; +Cc: Berry, Charles, emacs-orgmode

kevinbanjo <kevinbanjo@gmail.com> writes:

> Thanks for that Chuck.   It would seem a lot cleaner if there was a hook or
> something one could run that would just expand macros in export blocks
> before exporting them.

Check out export filters in 13.17 Advanced Export Configuration

By default, we cannot allow Org syntax inside export blocks because it
can interfere with the exported format syntax.

Best,
Ihor


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-17 20:54   ` kevinbanjo
@ 2022-07-17 23:21     ` Ihor Radchenko
  2022-07-18 19:00     ` Berry, Charles
  1 sibling, 0 replies; 11+ messages in thread
From: Ihor Radchenko @ 2022-07-17 23:21 UTC (permalink / raw)
  To: kevinbanjo; +Cc: emacs-orgmode

kevinbanjo <kevinbanjo@gmail.com> writes:

> When I look at the doc string for (org-macro-replace-all) it says:
>
>
> *Optional argument KEYWORDS, when non-nil is a list of keywords,*
> *as strings, where macro expansion is allowed.*
>
> I tried passing it '("export-block") but it didn't work, but it seems like
> something like that should be close.

KEYWORDS argument is listing the "keyword" syntactic elements. Your
export block is an "export block" element where macro expansion cannot
work by design.

> This whole area of org documentation seems pretty obtuse, with few
> examples.

Could you please point out which particular part of org documentation is
lacking?

Best,
Ihor



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-17 18:54     ` Berry, Charles
  2022-07-17 19:19       ` kevinbanjo
@ 2022-07-18  1:16       ` kevinbanjo
  2022-07-18  4:35         ` Ihor Radchenko
  1 sibling, 1 reply; 11+ messages in thread
From: kevinbanjo @ 2022-07-18  1:16 UTC (permalink / raw)
  To: Berry, Charles; +Cc: Ihor Radchenko, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 990 bytes --]

On Sun, Jul 17, 2022 at 11:54 AM Berry, Charles <ccberry@health.ucsd.edu>
wrote:

> Kevin,
>
> > On Jul 17, 2022, at 10:18 AM, kevinbanjo <kevinbanjo@gmail.com> wrote:
> >
> >
> >
> > On Sun, Jul 17, 2022 at 7:24 AM Ihor Radchenko <yantar92@gmail.com>
> wrote:
> > See inline calls in
> https://orgmode.org/manual/Evaluating-Code-Blocks.html#Evaluating-Code-Blocks
> > <snip>
>


> The export block provides text that is to be used "as is" by the html
> backend. So, "call_numbers()" is treated as html.
>
> You need to construct the export block programmatically. Maybe something
> like
>
> #+begin_src emacs-lisp :results html :exports results :var num=numbers()
>    (format "the result is %d" num )
> #+end_src
>
>
The problem with that is when I export I get <p> </p> both above and below
the result (even though I added :results output raw) and I need it inline
plus it's changing my angle brackets to &gt and &lt (I'm trying to generate
php code).

Any idea how to fix that?

-Kevin

[-- Attachment #2: Type: text/html, Size: 1948 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-18  1:16       ` kevinbanjo
@ 2022-07-18  4:35         ` Ihor Radchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Ihor Radchenko @ 2022-07-18  4:35 UTC (permalink / raw)
  To: kevinbanjo; +Cc: Berry, Charles, emacs-orgmode

kevinbanjo <kevinbanjo@gmail.com> writes:

>> You need to construct the export block programmatically. Maybe something
>> like
>>
>> #+begin_src emacs-lisp :results html :exports results :var num=numbers()
>>    (format "the result is %d" num )
>> #+end_src
>>
>>
> The problem with that is when I export I get <p> </p> both above and below
> the result (even though I added :results output raw) and I need it inline
> plus it's changing my angle brackets to &gt and &lt (I'm trying to generate
> php code).
>
> Any idea how to fix that?

Use inline src block or an inline call to the src block.

Best,
Ihor


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: substitutions in html export?
  2022-07-17 20:54   ` kevinbanjo
  2022-07-17 23:21     ` Ihor Radchenko
@ 2022-07-18 19:00     ` Berry, Charles
  1 sibling, 0 replies; 11+ messages in thread
From: Berry, Charles @ 2022-07-18 19:00 UTC (permalink / raw)
  To: kevinbanjo; +Cc: emacs-orgmode

Kevin,

> On Jul 17, 2022, at 1:54 PM, kevinbanjo <kevinbanjo@gmail.com> wrote:
> 
> When I look at the doc string for (org-macro-replace-all) it says:
> 
> Optional argument KEYWORDS, when non-nil is a list of keywords,
> as strings, where macro expansion is allowed.
> 
> I tried passing it '("export-block") but it didn't work, but it seems like something like that should be close.
> 

Does this help?

Adding this to your example:

Here is an inline code src_emacs-lisp[
:results html :exports results :var num=numbers()]{
(format "the result is %d." num )} End.


Produces a paragraph:

<p>
Here is an inline code the result is 40. End.
</p>


> This whole area of org documentation seems pretty obtuse, with few examples.

Did you browse worg? Especially this:

https://orgmode.org/worg/org-contrib/babel/index.html


Agree that documentation is a WIP and export blocks are mentioned only in reference to specific exporters, so there is that.

HTH,
Chuck


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-07-18 19:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-17 14:16 substitutions in html export? kevinbanjo
2022-07-17 14:25 ` Ihor Radchenko
2022-07-17 17:18   ` kevinbanjo
2022-07-17 18:54     ` Berry, Charles
2022-07-17 19:19       ` kevinbanjo
2022-07-17 23:18         ` Ihor Radchenko
2022-07-18  1:16       ` kevinbanjo
2022-07-18  4:35         ` Ihor Radchenko
2022-07-17 20:54   ` kevinbanjo
2022-07-17 23:21     ` Ihor Radchenko
2022-07-18 19:00     ` Berry, Charles

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).