Re: substitutions in html export?

2022-07-18 Thread Berry, Charles
Kevin,

> On Jul 17, 2022, at 1:54 PM, kevinbanjo  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:


Here is an inline code the result is 40. End.



> 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



Re: substitutions in html export?

2022-07-17 Thread Ihor Radchenko
kevinbanjo  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   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  and  (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



Re: substitutions in html export?

2022-07-17 Thread kevinbanjo
On Sun, Jul 17, 2022 at 11:54 AM Berry, Charles 
wrote:

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


> 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   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  and  (I'm trying to generate
php code).

Any idea how to fix that?

-Kevin


Re: substitutions in html export?

2022-07-17 Thread Ihor Radchenko
kevinbanjo  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




Re: substitutions in html export?

2022-07-17 Thread Ihor Radchenko
kevinbanjo  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



Re: substitutions in html export?

2022-07-17 Thread kevinbanjo
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.


Re: substitutions in html export?

2022-07-17 Thread kevinbanjo
On Sun, Jul 17, 2022 at 11:54 AM Berry, Charles 
wrote:

> Kevin,
>
> > On Jul 17, 2022, at 10:18 AM, kevinbanjo  wrote:
> >
> >
> >
> > On Sun, Jul 17, 2022 at 7:24 AM Ihor Radchenko 
> 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


Re: substitutions in html export?

2022-07-17 Thread Berry, Charles
Kevin,

> On Jul 17, 2022, at 10:18 AM, kevinbanjo  wrote:
> 
> 
> 
> On Sun, Jul 17, 2022 at 7:24 AM Ihor Radchenko  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






Re: substitutions in html export?

2022-07-17 Thread kevinbanjo
On Sun, Jul 17, 2022 at 7:24 AM Ihor Radchenko  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()


Re: substitutions in html export?

2022-07-17 Thread Ihor Radchenko
See inline calls in
https://orgmode.org/manual/Evaluating-Code-Blocks.html#Evaluating-Code-Blocks


substitutions in html export?

2022-07-17 Thread kevinbanjo
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 <>
#+end_export