Re: How to export to the simplest possible HTML?

2023-06-28 Thread Marcin Borkowski


On 2023-06-27, at 13:00, Max Nikulin  wrote:

>>> On 08/06/2023 22:18, Thomas Redelberger wrote:
   http://web222.webclient5.de/doc/swdev/emacs/orgmode/html
>>>
>>> At this page:
>>>
 #+BIND: org-html-viewport nil
 I do not need viewport information in the HTML.
>
> On 26/06/2023 02:56, Marcin Borkowski wrote:
>> Do you mean this?
>> https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag
>
> Yes, I do. Browser development tools allows to test adaptive design
> (to simulate specific mobile devices).

Thanks.

> I was surprised that somebody may intentionally disable the feature
> supported by Org on a site that at first glance does not require
> special viewport settings. Since you are in the process of refreshing
> your site, I decided to draw your attention to this setting of HTML
> pages.

I did not plan to do anything with https://mbork.pl, but I'll look into
it.  (I'm working on another site.)

Thanks,

-- 
Marcin Borkowski
http://mbork.pl



Re: How to export to the simplest possible HTML?

2023-06-27 Thread Max Nikulin

On 08/06/2023 22:18, Thomas Redelberger wrote:

  http://web222.webclient5.de/doc/swdev/emacs/orgmode/html


At this page:


#+BIND: org-html-viewport nil
I do not need viewport information in the HTML.


On 26/06/2023 02:56, Marcin Borkowski wrote:

Do you mean this?
https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag


Yes, I do. Browser development tools allows to test adaptive design (to 
simulate specific mobile devices).


I was surprised that somebody may intentionally disable the feature 
supported by Org on a site that at first glance does not require special 
viewport settings. Since you are in the process of refreshing your site, 
I decided to draw your attention to this setting of HTML pages.






Re: How to export to the simplest possible HTML?

2023-06-25 Thread Marcin Borkowski


On 2023-06-24, at 17:04, Max Nikulin  wrote:

> On 08/06/2023 22:18, Thomas Redelberger wrote:
>> I had a similar requirement for "simplest HTML" and have documented
>> how I tackled this under
>>  http://web222.webclient5.de/doc/swdev/emacs/orgmode/html
>
> At this page:
>
>> #+BIND: org-html-viewport nil
>> I do not need viewport information in the HTML. 
>
> From my point of view it sounds strange. I do not see a real reason to
> intentionally make a site inconvenient for users of mobile devices.
>
> Marcin, viewport is missed on your site as well.

Do you mean this?
https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag

I think the reason is that the site was designed (in terms of HTML and
CSS) well over 15 years ago...

Thanks,

-- 
Marcin Borkowski
http://mbork.pl



Re: How to export to the simplest possible HTML?

2023-06-24 Thread Max Nikulin

On 08/06/2023 22:18, Thomas Redelberger wrote:


I had a similar requirement for "simplest HTML" and have documented how 
I tackled this under

  http://web222.webclient5.de/doc/swdev/emacs/orgmode/html


At this page:


#+BIND: org-html-viewport nil

I do not need viewport information in the HTML. 


From my point of view it sounds strange. I do not see a real reason to 
intentionally make a site inconvenient for users of mobile devices.


Marcin, viewport is missed on your site as well.




Re: How to export to the simplest possible HTML?

2023-06-24 Thread Marcin Borkowski


On 2023-06-24, at 15:34, Ihor Radchenko  wrote:

> Marcin Borkowski  writes:
>
>>> Org export passes the actual parsed and filtered AST that will be
>>> exported to `org-export-filter-parse-tree-functions'. You can modify and
>>> traverse the parse tree as you need.
>>
>> Yeah, that I do understand.  Problem is, I don't know how the AST is
>> structured, what functions operate on it etc.  I am aware that I could
>> learn all of that from the source and experimenting, but it would
>> probably be a bit time-consuming, and other ways turned out to be much
>> easier (which means better for me – I want something simple).
>
> I tried to provide a summary in my recent patch.
> https://list.orgmode.org/874jnudps5.fsf@localhost/3-a.txt

Thanks, this looks interesting, I'll take a look!

> You can also refer to
> https://orgmode.org/worg/dev/org-element-api.html

This one I know, of course, but it's a bit more high-level, I think.
>
>> As an aside, inspecting deeply nested structures in Elisp seems a pain
>> in the neck.  Does anyone know a good method of interactively inspecting
>> them?
>
> https://github.com/mmontone/emacs-inspector

Wow, this looks _great_!!!  I'll install it and try it out!

Thanks,

-- 
Marcin Borkowski
http://mbork.pl



Re: How to export to the simplest possible HTML?

2023-06-24 Thread Ihor Radchenko
Marcin Borkowski  writes:

>> Org export passes the actual parsed and filtered AST that will be
>> exported to `org-export-filter-parse-tree-functions'. You can modify and
>> traverse the parse tree as you need.
>
> Yeah, that I do understand.  Problem is, I don't know how the AST is
> structured, what functions operate on it etc.  I am aware that I could
> learn all of that from the source and experimenting, but it would
> probably be a bit time-consuming, and other ways turned out to be much
> easier (which means better for me – I want something simple).

I tried to provide a summary in my recent patch.
https://list.orgmode.org/874jnudps5.fsf@localhost/3-a.txt
You can also refer to https://orgmode.org/worg/dev/org-element-api.html

> As an aside, inspecting deeply nested structures in Elisp seems a pain
> in the neck.  Does anyone know a good method of interactively inspecting
> them?

https://github.com/mmontone/emacs-inspector

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



Re: How to export to the simplest possible HTML?

2023-06-24 Thread Marcin Borkowski


On 2023-06-03, at 10:37, Ihor Radchenko  wrote:

> Marcin Borkowski  writes:
>
>>> You can loop over links in the exported subtree and export any extra if
>>> necessary. For example, in the `org-export-filter-parse-tree-functions'.
>>
>> Interesting.  The main problem with it is that the docstring is rather
>> concise and I don't understand it well enough to use it.
>
> Org export passes the actual parsed and filtered AST that will be
> exported to `org-export-filter-parse-tree-functions'. You can modify and
> traverse the parse tree as you need.

Yeah, that I do understand.  Problem is, I don't know how the AST is
structured, what functions operate on it etc.  I am aware that I could
learn all of that from the source and experimenting, but it would
probably be a bit time-consuming, and other ways turned out to be much
easier (which means better for me – I want something simple).

As an aside, inspecting deeply nested structures in Elisp seems a pain
in the neck.  Does anyone know a good method of interactively inspecting
them?  My usual approach (Edebug) is next to useless when the value
displayed in the minibuffer is a deeply nested list with dozens or
hundreds of elements at different levels...

TIA,

-- 
Marcin Borkowski
http://mbork.pl



Re: How to export to the simplest possible HTML?

2023-06-24 Thread Marcin Borkowski


On 2023-06-10, at 10:25, Thomas Redelberger  wrote:

> Dear Marcin and everybody,
>
> I had a similar requirement for "simplest HTML" and have documented (incl. 
> source code) how I tackled this under
>  http://web222.webclient5.de/doc/swdev/emacs/orgmode/html
>
> In summary, my solution is
> - a few settings in init.el:
>   + org-html-text-markup-alist similar to below
>   + setting org-export-allow-bind-keywords to t
> - setting quite some org variables in-buffer/in the org file
> - elisp to steer a final XSLT transformation of the generated HTML
>
>
> I had coded a derived HTML export back-end (for Emacs 25.1) and used it quite 
> for some time.
> When I moved to Emacs 27.2, the derived back-end did not work any more, hence 
> I changed to above approach.

Thanks.

I settled for a custom (very simple) derived exporter and
`org-export-as` with `body-only' set to `t' (and I wrap the generated
HTML in tags like `' and `' myself then).

Best,

-- 
Marcin Borkowski
http://mbork.pl



Re: How to export to the simplest possible HTML?

2023-06-14 Thread Thomas Redelberger

Dear Marcin and everybody,

I had a similar requirement for "simplest HTML" and have documented how I 
tackled this under
 http://web222.webclient5.de/doc/swdev/emacs/orgmode/html

In summary, it is
- a few settings in init.el:
  + org-html-text-markup-alist similar to below
  + setting org-export-allow-bind-keywords to t
- seeting quite some org variables via in-buffer settings
- elisp to steer a final XSLT transformation of the generated HTML


I had coded a derived export back-end (for Emacs 25.1) and used it quite for 
some time. When I moved to Emacs 27.2, the derived back-end did not work any 
more, hence I changed to above aproach.

Best regards
Thomas


Am 2023-05-30 um 20:48 schrieb Marcin Borkowski:


On 2023-05-30, at 17:32, Max Nikulin  wrote:


On 30/05/2023 10:47, Marcin Borkowski wrote:

since I'm going to
call my exporting function in a loop over many elements.  I tried
(org-export-with-backend 'html (org-element-at-point (point)))


There is `org-export-string-as', but likely it is not suitable for
you. My guess is that you are going to export headings (blog posts) to
separate html files.


Correct, dear Holmes. ;-)


This is /italic/.
can become e.g.
This is italic.


I am curious whether  is more friendly to screen readers
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/em


Good point.  You're right, I'll probably go with `' then.  (The
reason I wanted `' was that I wan't somewhat atypical styling,
namely letterspace.  But of course css magic can make `' do this,
too.)


I'm considering writing a custom (derived) export backend, but maybe
that is an overkill?  Any ideas?


I just have noticed

(defcustom org-html-text-markup-alist
   '((bold . "%s")
 (code . "%s")
 (italic . "%s")
 (strike-through . "%s")
 (underline . "%s")
 (verbatim . "%s"))
   "Alist of HTML expressions to convert text markup.

You may look into ox-html customizations such as
(:html-doctype "HTML_DOCTYPE" nil org-html-doctype)
(:html-html5-fancy nil "html5-fancy" org-html-html5-fancy)

I have never tried ox-slimhtml:
Laszlo Elo. ox-slimhtml. Mon, 14 Dec 2020 00:48:27
-0500. https://list.orgmode.org/41d2e10d-bcff-4604-8417-b499514af...@bald.cat


Ah, that looks interesting, too.

Thanks!





Re: How to export to the simplest possible HTML?

2023-06-10 Thread Thomas Redelberger

Dear Marcin and everybody,

I had a similar requirement for "simplest HTML" and have documented (incl. 
source code) how I tackled this under
 http://web222.webclient5.de/doc/swdev/emacs/orgmode/html

In summary, my solution is
- a few settings in init.el:
  + org-html-text-markup-alist similar to below
  + setting org-export-allow-bind-keywords to t
- setting quite some org variables in-buffer/in the org file
- elisp to steer a final XSLT transformation of the generated HTML


I had coded a derived HTML export back-end (for Emacs 25.1) and used it quite 
for some time.
When I moved to Emacs 27.2, the derived back-end did not work any more, hence I 
changed to above approach.

Best regards
Thomas


On 2023-05-30, at 20:48, Marcin Borkowski wrote:


On 2023-05-30, at 17:32, Max Nikulin  wrote:


On 30/05/2023 10:47, Marcin Borkowski wrote:

since I'm going to
call my exporting function in a loop over many elements.  I tried
(org-export-with-backend 'html (org-element-at-point (point)))


There is `org-export-string-as', but likely it is not suitable for
you. My guess is that you are going to export headings (blog posts) to
separate html files.


Correct, dear Holmes. 


This is /italic/.
can become e.g.
This is italic.


I am curious whether  is more friendly to screen readers
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/em


Good point.  You're right, I'll probably go with `' then.  (The
reason I wanted `' was that I wan't somewhat atypical styling,
namely letterspace.  But of course css magic can make `' do this,
too.)


I'm considering writing a custom (derived) export backend, but maybe
that is an overkill?  Any ideas?


I just have noticed

(defcustom org-html-text-markup-alist
   '((bold . "%s")
 (code . "%s")
 (italic . "%s")
 (strike-through . "%s")
 (underline . "%s")
 (verbatim . "%s"))
   "Alist of HTML expressions to convert text markup.

You may look into ox-html customizations such as
(:html-doctype "HTML_DOCTYPE" nil org-html-doctype)
(:html-html5-fancy nil "html5-fancy" org-html-html5-fancy)

I have never tried ox-slimhtml:
Laszlo Elo. ox-slimhtml. Mon, 14 Dec 2020 00:48:27
-0500. https://list.orgmode.org/41d2e10d-bcff-4604-8417-b499514af...@bald.cat


Ah, that looks interesting, too.

Thanks!





Re: How to export to the simplest possible HTML?

2023-06-03 Thread Ihor Radchenko
Marcin Borkowski  writes:

>> You can loop over links in the exported subtree and export any extra if
>> necessary. For example, in the `org-export-filter-parse-tree-functions'.
>
> Interesting.  The main problem with it is that the docstring is rather
> concise and I don't understand it well enough to use it.

Org export passes the actual parsed and filtered AST that will be
exported to `org-export-filter-parse-tree-functions'. You can modify and
traverse the parse tree as you need.

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



Re: How to export to the simplest possible HTML?

2023-06-03 Thread Marcin Borkowski


On 2023-06-03, at 07:08, Ihor Radchenko  wrote:

> Marcin Borkowski  writes:
>
>> On 2023-05-30, at 20:45, Marcin Borkowski  wrote:
>>
 Just use `org-export-as'.
>>>
>>> Thanks again, I didn't know about that function!
>>
>> I tried playing around with it, but it has one drawback - I can't use it
>> to export a subtree containing a link to another subtree, and that is
>> something I will definitely need.  (I can see why it works that way -
>> for that to work, I have to somehow make sure that subtrees containing
>> targets of those links are also exported at some point in time - but
>> I need another behavior...)
>
> AFAIR, ox-hugo implements what you want here.

I know, but after a long consideration and some experiments I decided
against Hugo - I want something (even) simpler and I plan to cook myself
a pure Elisp solution.

>> My current idea is to go with a custom exporter derived from the HTML
>> one, indeed.  Is there a better approach?
>
> You can loop over links in the exported subtree and export any extra if
> necessary. For example, in the `org-export-filter-parse-tree-functions'.

Interesting.  The main problem with it is that the docstring is rather
concise and I don't understand it well enough to use it.  I will perform
some experiments, but if they fail, I think a derived exporter with
a custom link-exporting function can also be helpful.

Thanks,

-- 
Marcin Borkowski
http://mbork.pl



Re: How to export to the simplest possible HTML?

2023-06-02 Thread Ihor Radchenko
Marcin Borkowski  writes:

> On 2023-05-30, at 20:45, Marcin Borkowski  wrote:
>
>>> Just use `org-export-as'.
>>
>> Thanks again, I didn't know about that function!
>
> I tried playing around with it, but it has one drawback - I can't use it
> to export a subtree containing a link to another subtree, and that is
> something I will definitely need.  (I can see why it works that way -
> for that to work, I have to somehow make sure that subtrees containing
> targets of those links are also exported at some point in time - but
> I need another behavior...)

AFAIR, ox-hugo implements what you want here.

> My current idea is to go with a custom exporter derived from the HTML
> one, indeed.  Is there a better approach?

You can loop over links in the exported subtree and export any extra if
necessary. For example, in the `org-export-filter-parse-tree-functions'.

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



Re: How to export to the simplest possible HTML?

2023-06-02 Thread Marcin Borkowski


On 2023-05-30, at 20:45, Marcin Borkowski  wrote:

>> Just use `org-export-as'.
>
> Thanks again, I didn't know about that function!

I tried playing around with it, but it has one drawback - I can't use it
to export a subtree containing a link to another subtree, and that is
something I will definitely need.  (I can see why it works that way -
for that to work, I have to somehow make sure that subtrees containing
targets of those links are also exported at some point in time - but
I need another behavior...)

My current idea is to go with a custom exporter derived from the HTML
one, indeed.  Is there a better approach?

Best,

-- 
Marcin Borkowski
http://mbork.pl



Re: How to export to the simplest possible HTML?

2023-05-30 Thread Marcin Borkowski


On 2023-05-30, at 17:32, Max Nikulin  wrote:

> On 30/05/2023 10:47, Marcin Borkowski wrote:
>> since I'm going to
>> call my exporting function in a loop over many elements.  I tried
>> (org-export-with-backend 'html (org-element-at-point (point)))
>
> There is `org-export-string-as', but likely it is not suitable for
> you. My guess is that you are going to export headings (blog posts) to
> separate html files.

Correct, dear Holmes. ;-)

>> This is /italic/.
>> can become e.g.
>> This is italic.
>
> I am curious whether  is more friendly to screen readers
> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/em

Good point.  You're right, I'll probably go with `' then.  (The
reason I wanted `' was that I wan't somewhat atypical styling,
namely letterspace.  But of course css magic can make `' do this,
too.)

>> I'm considering writing a custom (derived) export backend, but maybe
>> that is an overkill?  Any ideas?
>
> I just have noticed
>
> (defcustom org-html-text-markup-alist
>   '((bold . "%s")
> (code . "%s")
> (italic . "%s")
> (strike-through . "%s")
> (underline . "%s")
> (verbatim . "%s"))
>   "Alist of HTML expressions to convert text markup.
>
> You may look into ox-html customizations such as
> (:html-doctype "HTML_DOCTYPE" nil org-html-doctype)
> (:html-html5-fancy nil "html5-fancy" org-html-html5-fancy)
>
> I have never tried ox-slimhtml:
> Laszlo Elo. ox-slimhtml. Mon, 14 Dec 2020 00:48:27
> -0500. https://list.orgmode.org/41d2e10d-bcff-4604-8417-b499514af...@bald.cat

Ah, that looks interesting, too.

Thanks!

-- 
Marcin Borkowski
http://mbork.pl



Re: How to export to the simplest possible HTML?

2023-05-30 Thread Marcin Borkowski


On 2023-05-30, at 08:21, Ihor Radchenko  wrote:

> Marcin Borkowski  writes:
>
>> ... I tried this:
>>
>> (org-html-export-as-html nil nil nil t '(org-export-with-toc nil))
>
> You need (org-html-export-as-html nil nil nil t '(:with-toc nil))
> See `org-export-options-alist'.

Thanks.  So apparently I mixed "options" with "variables".

>> but the ToC still appears in the output.  Also, I'd prefer to do it
>> a bit "less interactively" - for example, setting the current buffer to
>> the one with export results is unnecessary for me, since I'm going to
>> call my exporting function in a loop over many elements.  I tried
>>
>> (org-export-with-backend 'html (org-element-at-point (point)))
>
> Just use `org-export-as'.

Thanks again, I didn't know about that function!

>> but it errored out:
>>
>> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>>   org-html-headline((headline (:raw-value ...)) ...)
>>   org-export-with-backend(html (headline (:raw-value ...)))
>
> Because `org-element-at-point' does not return a parsed subtree. Just a
> partial one without children.

I don't understand this distinction, but now that I know about
`org-export-as' it doesn't matter.

>> I also want to supply my custom formatting for italics & friends, so
>> that
>>
>> This is /italic/.
>>
>> can become e.g.
>>
>> This is italic.
>>
>> I'm considering writing a custom (derived) export backend, but maybe
>> that is an overkill?  Any ideas?
>
> Derived backend will be the easiest. It is not even hard. Just a few
> lines of code.

I know, I wrote one a few years ago, but I still think it might be a bit
overhead.  Well, I'll definitely consider that option.

Thanks,

-- 
Marcin Borkowski
http://mbork.pl



Re: How to export to the simplest possible HTML?

2023-05-30 Thread Max Nikulin

On 30/05/2023 10:47, Marcin Borkowski wrote:

since I'm going to
call my exporting function in a loop over many elements.  I tried

(org-export-with-backend 'html (org-element-at-point (point)))


There is `org-export-string-as', but likely it is not suitable for you. 
My guess is that you are going to export headings (blog posts) to 
separate html files.



This is /italic/.

can become e.g.

This is italic.


I am curious whether  is more friendly to screen readers
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/em


I'm considering writing a custom (derived) export backend, but maybe
that is an overkill?  Any ideas?


I just have noticed

(defcustom org-html-text-markup-alist
  '((bold . "%s")
(code . "%s")
(italic . "%s")
(strike-through . "%s")
(underline . "%s")
(verbatim . "%s"))
  "Alist of HTML expressions to convert text markup.

You may look into ox-html customizations such as
(:html-doctype "HTML_DOCTYPE" nil org-html-doctype)
(:html-html5-fancy nil "html5-fancy" org-html-html5-fancy)

I have never tried ox-slimhtml:
Laszlo Elo. ox-slimhtml. Mon, 14 Dec 2020 00:48:27 -0500. 
https://list.orgmode.org/41d2e10d-bcff-4604-8417-b499514af...@bald.cat





Re: How to export to the simplest possible HTML?

2023-05-30 Thread Ihor Radchenko
Marcin Borkowski  writes:

> ... I tried this:
>
> (org-html-export-as-html nil nil nil t '(org-export-with-toc nil))

You need (org-html-export-as-html nil nil nil t '(:with-toc nil))
See `org-export-options-alist'.

> but the ToC still appears in the output.  Also, I'd prefer to do it
> a bit "less interactively" - for example, setting the current buffer to
> the one with export results is unnecessary for me, since I'm going to
> call my exporting function in a loop over many elements.  I tried
>
> (org-export-with-backend 'html (org-element-at-point (point)))

Just use `org-export-as'.

> but it errored out:
>
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>   org-html-headline((headline (:raw-value ...)) ...)
>   org-export-with-backend(html (headline (:raw-value ...)))

Because `org-element-at-point' does not return a parsed subtree. Just a
partial one without children.

> I also want to supply my custom formatting for italics & friends, so
> that
>
> This is /italic/.
>
> can become e.g.
>
> This is italic.
>
> I'm considering writing a custom (derived) export backend, but maybe
> that is an overkill?  Any ideas?

Derived backend will be the easiest. It is not even hard. Just a few
lines of code.

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



How to export to the simplest possible HTML?

2023-05-29 Thread Marcin Borkowski
Hello everyone,

I'd like to export an Org buffer (or portion of it) to the simplest HTML
possible, prgrammatically.  For example, I only want the body, I don't
want any generated IDs, and I don't want the ToC.  I tried this:

(org-html-export-as-html nil nil nil t '(org-export-with-toc nil))

but the ToC still appears in the output.  Also, I'd prefer to do it
a bit "less interactively" - for example, setting the current buffer to
the one with export results is unnecessary for me, since I'm going to
call my exporting function in a loop over many elements.  I tried

(org-export-with-backend 'html (org-element-at-point (point)))

but it errored out:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  org-html-headline((headline (:raw-value ...)) ...)
  org-export-with-backend(html (headline (:raw-value ...)))

I also want to supply my custom formatting for italics & friends, so
that

This is /italic/.

can become e.g.

This is italic.

I'm considering writing a custom (derived) export backend, but maybe
that is an overkill?  Any ideas?

TIA,

-- 
Marcin Borkowski
http://mbork.pl