Re: [Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-17 Thread Tim Cross


Tom Gillespie  writes:

> Treating src blocks missing a lang as paragraphs is
> incorrect because according to the syntax spec they
> are syntactically still blocks (greater or lesser depending
> on your inclinations).
>
> I think the general principle we want to follow here is
> that a block (or any entity in general) should not lose
> its type because some part of its syntax is malformed
> (I have made similar arguments about property drawers).
>

I think you might be right here.

The big characteristic of source blocks and example blocks which make
them different from paragraphs is the line breaks and indentation. If
they are treated as paragraphs, won't this information be lost?



Re: [Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-17 Thread Ihor Radchenko
Max Nikulin  writes:

> Source blocks without language may be treated as #+begin_example blocks. 
> I believe, a warning should be issued in such case.

M-x org-lint already does it.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-16 Thread Tom Gillespie
Hi Ihor,
   Chiming in here with a slight variant on what
others have said. Best!
Tom

I don't think this should be handled at the syntactic
layer at all. The empty string block language should
be syntactically valid with any special behavior
needed being handled later.

Linters could treat it as a warning/error though,
but the parsing is made significantly easier if
the empty string is present allowing the grammar
to be fully closed and regular.

Thus, I don't think we need to make this a syntactic
error or pun a src block without a lang to another type.

I think we can add an implementation for when the
block language is the empty string. This keeps
the grammar regular by removing a special case.

I assume that internally the empty string block lang
would mostly call the example block codepaths,
except that it should probably issue a warning or fail
if someone tries to org-src-edit the block so that we
can alert them that they are missing the lang.

Treating src blocks missing a lang as paragraphs is
incorrect because according to the syntax spec they
are syntactically still blocks (greater or lesser depending
on your inclinations).

I think the general principle we want to follow here is
that a block (or any entity in general) should not lose
its type because some part of its syntax is malformed
(I have made similar arguments about property drawers).

That is, if something starts with #+begin_NAME stuff
and there is a corresponding #+end_NAME, then it
is a block.

The choice of how a src block without a lang should
behave is a bit more complex as there are multiple
consumers of src blocks that make different assumptions.

As mentioned above. I think that if a block is missing the lang
we could think of it instead as the null language. If we have the
:var language because someone has other contents on the line
they have a well formed src block, but will get a different error
because there is currently no known language ":var".


RE: [Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-15 Thread Pedro Andres Aranda Gutierrez
No, please. For two reasons:

1.- In HTML, you have 
2.- This could trickle to other backends where it makes sense

Thanks, /PA
-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet


Re: [Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-15 Thread Ihor Radchenko
Tim Cross  writes:

> I don't see any reason not to allow captions for examples either.

In LaTeX, example blocks are exported as verbatim. I am not sure if we
can even put captions into verbatim.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-15 Thread Tim Cross


Max Nikulin  writes:

> On 15/12/2022 16:31, Ihor Radchenko wrote:
>> The actual parser does allow empty lang in src blocks, setting :lang
>> element property to nil. Should we stop doing this and treat such src
>> blocks as paragraphs? Or should we allow empty lang and instead adapt
>> the exporters to treat empty lang correctly?
>
> Source blocks without language may be treated as #+begin_example blocks. I 
> believe, a
> warning should be issued in such case.
>
> I do not see a reason why caption is not allowed for examples.

Yes, I think I agree. Semantically, a src block without a language is
really just an example block - it cannot be executed or evaluated and is
essentially reduced to a example block.

I think having a warning is also a good idea as it will alert users when
they have inadvertently forgotten to add the lang.

I don't see any reason not to allow captions for examples either.



Re: [Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-15 Thread Timothy
Hi Ihor,

> There is an inconsistency here between Org parser and
>  + manual.
>
> The actual parser does allow empty lang in src blocks, setting :lang
> element property to nil. Should we stop doing this and treat such src
> blocks as paragraphs? Or should we allow empty lang and instead adapt
> the exporters to treat empty lang correctly?

My 2c: a nil lang seems like the “less wrong” option.

All the best,
Timothy

-- 
Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
Learn more about Org mode at .
Support Org development at ,
or support my work at .


Re: [Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-15 Thread Max Nikulin

On 15/12/2022 16:31, Ihor Radchenko wrote:


The actual parser does allow empty lang in src blocks, setting :lang
element property to nil. Should we stop doing this and treat such src
blocks as paragraphs? Or should we allow empty lang and instead adapt
the exporters to treat empty lang correctly?


Source blocks without language may be treated as #+begin_example blocks. 
I believe, a warning should be issued in such case.


I do not see a reason why caption is not allowed for examples.





Re: [Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-15 Thread Kaushal Modi
On Thu, Dec 15, 2022, 4:32 AM Ihor Radchenko  wrote:

> Johan Bolmsjö  writes:
>
> > #+caption: Caption 1
> > #+begin_src
> > foo bar baz
> > #+end_src
>
> There is an inconsistency here between Org parser and
> https://orgmode.org/worg/org-syntax.html + manual.
>
> The actual parser does allow empty lang in src blocks, setting :lang
> element property to nil.



Should we stop doing this and treat such src
> blocks as paragraphs?


I think that this would cause more of a surprise to the user when something
in a source block exports as a plain paragraph instead of in a  block
(for HTML exports).

Or should we allow empty lang and instead adapt
> the exporters to treat empty lang correctly?
>

I vote for this one. Then

#+begin_src
foo
#+end_src

will be analogous to this in Markdown:

```
foo
```


[Syntax discussion] Should we treat src blocks without LANG as paragraphs? (was: [BUG] ox-html does not export captions of source blocks without language)

2022-12-15 Thread Ihor Radchenko
Johan Bolmsjö  writes:

> #+caption: Caption 1
> #+begin_src
> foo bar baz
> #+end_src

There is an inconsistency here between Org parser and
https://orgmode.org/worg/org-syntax.html + manual.

The actual parser does allow empty lang in src blocks, setting :lang
element property to nil. Should we stop doing this and treat such src
blocks as paragraphs? Or should we allow empty lang and instead adapt
the exporters to treat empty lang correctly?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at