Re: numbering src blocks in HTML export

2022-07-22 Thread Greg Minshall
Ihor,

> Dear All, may we should provide a normal header arg as an equivalent of
> switches? Honestly, this whole switch syntax sounds unnecessary and only
> over-complicates things.

i'm a fan.



Re: numbering src blocks in HTML export

2022-07-20 Thread Juan Manuel Macías
Ihor Radchenko writes:

> AFAIU, source block switches are never inherited.
>
> Dear All, may we should provide a normal header arg as an equivalent of
> switches? Honestly, this whole switch syntax sounds unnecessary and only
> over-complicates things.

I think that web pages or documents that contain several code examples
(tutorials, documentation, etc.) tend to unify the style in this regard:
either all examples are line-numbered or all examples are unnumbered;
therefore, if the first option is chosen, it would be good to have some
global setting, when there are many blocks. But I also think this can be
easily achieved with some function locally hooked to
org-export-before-processing-hook. Or even within the document on the
fly.

A global 'factory setting' would also have the extra complication that
there would be two global numbering versions (at least): a) a separate
numbering for each block; b) each block continuing the numbering of the
previous block. And there could be a subtype of b) where it is necessary
to restart the numbering when starting a new section. Or a) and b) could
be arbitrarily mixed in the same document. All this seems complicated
to implement...

But one thing that could be nice is to give an option (perhaps with a
prefix argument) for org-babel-demarcate-block (C-c C-v C-d) to inherit
the switches:

before:

#+begin_src emacs-lisp -n
a
a
a
a
a
a
#+end_src

after C-c C-v C-d

#+begin_src emacs-lisp -n
a
a
a
#+end_src

#+begin_src emacs-lisp +n
b
b
b
#+end_src


Best regards,

Juan Manuel 






Re: numbering src blocks in HTML export

2022-07-20 Thread Fraga, Eric
On Wednesday, 20 Jul 2022 at 11:58, Ihor Radchenko wrote:
> AFAIU, source block switches are never inherited.

Thank you for confirming.  It's easy enough for me to change all of my
src blocks with a single Emacs command.  And that's why "it's all text"
is so important! :-)

> may we should provide a normal header arg as an equivalent of
> switches?

Sounds like a reasonable idea.  I think they are possibly a holdover
from text blocks for examples, pre-babel?

-- 
: Eric S Fraga, with org release_9.5.4-643-g057df6 in Emacs 29.0.50


Re: numbering src blocks in HTML export

2022-07-19 Thread Ihor Radchenko
"Fraga, Eric"  writes:

> Followup question, if I may: how can I make -n be default behaviour for
> export?  I have tried, for instance,
>
> #+property: header-args:julia -n 1
>
> to have all Julia src blocks show line numbers but it doesn't work.

AFAIU, source block switches are never inherited.

Dear All, may we should provide a normal header arg as an equivalent of
switches? Honestly, this whole switch syntax sounds unnecessary and only
over-complicates things.

Best,
Ihor



Re: numbering src blocks in HTML export

2022-07-19 Thread Fraga, Eric
Followup question, if I may: how can I make -n be default behaviour for
export?  I have tried, for instance,

#+property: header-args:julia -n 1

to have all Julia src blocks show line numbers but it doesn't work.

Thanks again,
eric

-- 
: Eric S Fraga, with org release_9.5.4-643-g057df6 in Emacs 29.0.50


Re: numbering src blocks in HTML export

2022-07-19 Thread Fraga, Eric
On Tuesday, 19 Jul 2022 at 15:28, Juan Manuel Macías wrote:
> I usually do it this way:
>
> #+begin_src sh -n :exports code

Thank you.  Obvious (in hindsight).  

I now found the section in the info manual on this (under Markup for
Rich Contents, which is I guess not where I expected it... but did get
there by following link for switches in header arguments which I somehow
missed earlier.)

eric

-- 
: Eric S Fraga, with org release_9.5.4-643-g057df6 in Emacs 29.0.50

Re: numbering src blocks in HTML export

2022-07-19 Thread Juan Manuel Macías
Fraga, Eric writes:

> I really do not understand the last paragraph although it implies that
> org already supports adding the line numbers.  My elisp-fu is not up to
> scratch to figure this out from the code unfortunately.  Would somebody
> explain what to do?  Or should I simply add the CSS code that would do
> it for me?

I usually do it this way:

#+begin_src sh -n :exports code
aa
bb
dd
ee
ff
#+end_src

And you can also indicate the number of the first line, ie -n 20

Best regards,

Juan Manuel 



numbering src blocks in HTML export

2022-07-19 Thread Fraga, Eric
Hello,

a quick and hopefully easy question: how do I get lines in src blocks
numbered in HTML export?  I have looked at the code and the first thing
I did was set org-html-wrap-src-lines to t.  This wraps each line in
"...".

I know how to use CSS to add line numbers to lines with these tags but,
looking at the export code, I see it uses the following function:

,[ C-h f org-export-get-loc RET ]
| org-export-get-loc is a native compiled Lisp function in ‘ox.el’.
| 
| (org-export-get-loc ELEMENT INFO)
| 
| Return count of lines of code before ELEMENT.
| 
| ELEMENT is an example-block or src-block element.  INFO is the
| plist used as a communication channel.
| 
| Count includes every line of code in example-block or src-block
| with a "+n" or "-n" switch before block.  Return nil if
| ELEMENT doesn’t allow line numbering.
| 
`

I really do not understand the last paragraph although it implies that
org already supports adding the line numbers.  My elisp-fu is not up to
scratch to figure this out from the code unfortunately.  Would somebody
explain what to do?  Or should I simply add the CSS code that would do
it for me?

Thank you,
eric

-- 
: Eric S Fraga, with org release_9.5.4-643-g057df6 in Emacs 29.0.50