emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: How to export to the simplest possible HTML?
@ 2023-06-10  8:25 Thomas Redelberger
  2023-06-24 13:16 ` Marcin Borkowski
  0 siblings, 1 reply; 19+ messages in thread
From: Thomas Redelberger @ 2023-06-10  8:25 UTC (permalink / raw)
  To: emacs-orgmode

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 <manikulin@gmail.com> 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 <span class="emphasize">italic</span>.
>>
>> I am curious whether <em> 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 `<em>' then.  (The
> reason I wanted `<span>' was that I wan't somewhat atypical styling,
> namely letterspace.  But of course css magic can make `<em>' 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 . "<b>%s</b>")
>>      (code . "<code>%s</code>")
>>      (italic . "<i>%s</i>")
>>      (strike-through . "<del>%s</del>")
>>      (underline . "<span class=\"underline\">%s</span>")
>>      (verbatim . "<code>%s</code>"))
>>    "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-B499514AF904@bald.cat
>
> Ah, that looks interesting, too.
>
> Thanks!
>


^ permalink raw reply	[flat|nested] 19+ messages in thread
* How to export to the simplest possible HTML?
@ 2023-05-30  3:47 Marcin Borkowski
  2023-05-30  6:21 ` Ihor Radchenko
  2023-05-30 15:32 ` Max Nikulin
  0 siblings, 2 replies; 19+ messages in thread
From: Marcin Borkowski @ 2023-05-30  3:47 UTC (permalink / raw)
  To: Org-Mode mailing list

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 <span class="emphasize">italic</span>.

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

TIA,

-- 
Marcin Borkowski
http://mbork.pl


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

end of thread, other threads:[~2023-06-28  9:05 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-10  8:25 How to export to the simplest possible HTML? Thomas Redelberger
2023-06-24 13:16 ` Marcin Borkowski
  -- strict thread matches above, loose matches on Subject: below --
2023-05-30  3:47 Marcin Borkowski
2023-05-30  6:21 ` Ihor Radchenko
2023-05-30 18:45   ` Marcin Borkowski
2023-06-03  3:36     ` Marcin Borkowski
2023-06-03  5:08       ` Ihor Radchenko
2023-06-03  6:24         ` Marcin Borkowski
2023-06-03  8:37           ` Ihor Radchenko
2023-06-24 13:25             ` Marcin Borkowski
2023-06-24 13:34               ` Ihor Radchenko
2023-06-24 13:48                 ` Marcin Borkowski
2023-05-30 15:32 ` Max Nikulin
2023-05-30 18:48   ` Marcin Borkowski
2023-06-08 15:18     ` Thomas Redelberger
2023-06-24 15:04       ` Max Nikulin
2023-06-25 19:56         ` Marcin Borkowski
2023-06-27 11:00           ` Max Nikulin
2023-06-28  9:03             ` Marcin Borkowski

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