From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id sILJDXo2vV9VdAAA0tVLHw (envelope-from ) for ; Tue, 24 Nov 2020 16:36:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id YAOsCXo2vV+WIQAA1q6Kng (envelope-from ) for ; Tue, 24 Nov 2020 16:36:10 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8318594006E for ; Tue, 24 Nov 2020 16:36:09 +0000 (UTC) Received: from localhost ([::1]:40898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khbIW-0002Wv-7M for larch@yhetil.org; Tue, 24 Nov 2020 11:36:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khb5z-0007Jw-8M for emacs-orgmode@gnu.org; Tue, 24 Nov 2020 11:23:11 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:41897) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1khb5u-0001lN-5P for emacs-orgmode@gnu.org; Tue, 24 Nov 2020 11:23:10 -0500 Received: by mail-ej1-x633.google.com with SMTP id gj5so29338115ejb.8 for ; Tue, 24 Nov 2020 08:23:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zzamboni-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QDYn+LOKOla5gNT8c6n8wHn5cEUBKTwN3ubLbtpqsIE=; b=s5XvZfnmvqKMhMMh+W/qRTJv0dDSZFxBWqJP3WVkS+eVbfgScATWjV4USrsd22CW77 ygk+CC45012p5EvzRfTZKyUrYqF5eugNfoxBQoLWAPfkYSDBFIF1Y0UYJZDeOz2ybLDQ dZbpkriBnQ5B7YchtwUQ1u6QAUMrDRuJVamdqN1rCPOMK52XRWnUovly9hxGyqgpiPgz uITVElCip2oOlS1xDG8Fy+WmVwRK5HmK1qnN0O/JOD0KyhSaE+ukMLFVdW1WsOfGadoC dEi4hfv99yua/HT7bdDS+auJFlPe6+GjTxdNV/PgrDDqs/lR/8kECXmDOQ6kQeJSeHvV S0NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QDYn+LOKOla5gNT8c6n8wHn5cEUBKTwN3ubLbtpqsIE=; b=UvOMGZIots7J9yDSZPnUjSt395NqeHGhstolGtbW9VHtioKO3U/xKXqgW7Z5W4wKkb XUiukZpgfo71jLaux9PGn8ZiBCvS8Ngxm2UcAk/2hDxG0NKBSVjpl7E3HqDkXQPgIrhD Rh2KX41tcu29WGK1Ucf51Q2KSMQKIu/2pGdXy4NvSWvkWentaGhDGaluPjRjovKEDnVo LbHFsnaUORzUR7gMMYi+vjB0RJlLLEuqoGMW1w2Ba8g29zFP3/UjXBAgT6UClD/1NTOI qVUfOhrkxqfTgGhTt2uQmQb6KBBoBXwJwDk76e8n1XFPJE/KoS3jKIqr2gbgwvhToimH kdaA== X-Gm-Message-State: AOAM533jz3+ELDd7O9si7oIKga1DX2tqoUsrmIbIV2y7dA478S1DuN8U /U1X8tORWPpmRWCng7evBTxnXWAqp3j57F7Dp0cWYg== X-Google-Smtp-Source: ABdhPJwdRY3JQdhsdKW31I9YUd9K0f7d3N0H11G8PvKCwcyEI8EJVkbJ0nBqqoCWZ7RFj2eCpBED0qEyYB1Pghq7R3Q= X-Received: by 2002:a17:906:4dd4:: with SMTP id f20mr4895455ejw.94.1606234984531; Tue, 24 Nov 2020 08:23:04 -0800 (PST) MIME-Version: 1.0 References: <87a6v7gdej.fsf@fastmail.fm> <87sg8yivr4.fsf@guelker.eu> In-Reply-To: From: Diego Zamboni Date: Tue, 24 Nov 2020 17:22:53 +0100 Message-ID: Subject: Re: Differentiate source blocks in export? To: John Kitchin Content-Type: multipart/alternative; boundary="000000000000ade74f05b4dcb976" Received-SPF: none client-ip=2a00:1450:4864:20::633; envelope-from=diego@zzamboni.org; helo=mail-ej1-x633.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: org-mode-email Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=zzamboni-org.20150623.gappssmtp.com header.s=20150623 header.b=s5XvZfnm; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.21 X-TUID: SmWRwOu9I9dE --000000000000ade74f05b4dcb976 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable And even (a bit) shorter: #+html:
#+BEGIN_SRC python print(5) #+END_SRC #+html:
--Diego On Tue, Nov 24, 2020 at 5:16 PM John Kitchin wrote: > Nice! Here is a little more compact way to do that I think: > > @@html:
@@ > #+BEGIN_SRC python > print(5) > #+END_SRC > @@html:
@@ > > > John > > ----------------------------------- > Professor John Kitchin > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu > > > > On Tue, Nov 24, 2020 at 11:08 AM Marvin =E2=80=98quintus=E2=80=99 G=C3=BC= lker < > post+orgmodeml@guelker.eu> wrote: > >> Hi! >> >> Am Dienstag, dem 24. November 2020 schrieb Joost Kremers: >> > I was wondering if there's a way to distinguish between different kind >> of source >> > code blocks when exporting to HTML. >> > >> > Specifically, I would like a way to mark certain code blocks in my Org >> file so >> > that those code blocks get a specific class in the HTML export. >> >> You can use the BEGIN_EXPORT/END_EXPORT pair to include a literal HTML >> DIV tag around your target code block. Try this: >> >> Wrapped code block in a div with a custom class: >> >> #+BEGIN_EXPORT html >>
>> #+END_EXPORT >> >> #+BEGIN_SRC c >> #include >> int main(int argc, char* argv[]) >> { >> printf("This is wrapped in the div\n"); >> return 0; >> } >> #+END_SRC >> >> #+BEGIN_EXPORT html >>
>> #+END_EXPORT >> >> Normal codeblock without: >> >> #+BEGIN_SRC c >> #include >> int main(int argc, char* argv[]) >> { >> printf("This is not wrapped in anything unusual\n"); >> return 0; >> } >> #+END_SRC >> >> Note how one of the EXPORT blocks wraps the opening tag of the DIV and >> the other one wraps the closing tag. >> >> -quintus >> >> -- >> Dipl.-Jur. M. G=C3=BClker | https://mg.guelker.eu | For security: >> Passau, Germany | kontakt@guelker.eu | () Avoid HTML e-mail >> European Union | PGP: see homepage | /\ http://asciiribbon.org >> >> --000000000000ade74f05b4dcb976 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
And even (a bit) shorter:

#+html:<di= v class=3D"myclass">
#+BEGIN_SRC python
print(5)
#+EN= D_SRC
#+html:</div>

--Diego

On T= ue, Nov 24, 2020 at 5:16 PM John Kitchin <jkitchin@andrew.cmu.edu> wrote:
Nice! Here is a little= more compact way to do that I think:

@@html:<div cla= ss=3D"myclass">@@
#+BEGIN_SRC python
print(5)
#+END_S= RC
@@html:</div>@@


John

------= -----------------------------
Professor John Kitchin=C2=A0
Doherty Ha= ll A207F
Department of Chemical Engineering
Carnegie Mellon Universit= y
Pittsburgh, PA 15213
412-268-7803


On Tue, Nov 24, 2020 at 11:08 AM Marvin =E2=80=98quintus=E2=80=99 G=C3= =BClker <post+orgmodeml@guelker.eu> wrote:
Hi!

Am Dienstag, dem 24. November 2020 schrieb Joost Kremers:
> I was wondering if there's a way to distinguish between different = kind of source
> code blocks when exporting to HTML.
>
> Specifically, I would like a way to mark certain code blocks in my Org= file so
> that those code blocks get a specific class in the HTML export.

You can use the BEGIN_EXPORT/END_EXPORT pair to include a literal HTML
DIV tag around your target code block. Try this:

=C2=A0 =C2=A0 Wrapped code block in a div with a custom class:

=C2=A0 =C2=A0 #+BEGIN_EXPORT html
=C2=A0 =C2=A0 <div class=3D"myclass">
=C2=A0 =C2=A0 #+END_EXPORT

=C2=A0 =C2=A0 #+BEGIN_SRC c
=C2=A0 =C2=A0 #include <stdio.h>
=C2=A0 =C2=A0 int main(int argc, char* argv[])
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("This is wrapped in the div\n"= );
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
=C2=A0 =C2=A0 }
=C2=A0 =C2=A0 #+END_SRC

=C2=A0 =C2=A0 #+BEGIN_EXPORT html
=C2=A0 =C2=A0 </div>
=C2=A0 =C2=A0 #+END_EXPORT

=C2=A0 =C2=A0 Normal codeblock without:

=C2=A0 =C2=A0 #+BEGIN_SRC c
=C2=A0 =C2=A0 #include <stdio.h>
=C2=A0 =C2=A0 int main(int argc, char* argv[])
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("This is not wrapped in anything un= usual\n");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
=C2=A0 =C2=A0 }
=C2=A0 =C2=A0 #+END_SRC

Note how one of the EXPORT blocks wraps the opening tag of the DIV and
the other one wraps the closing tag.

=C2=A0 -quintus

--
Dipl.-Jur. M. G=C3=BClker | https://mg.guelker.eu |=C2=A0 =C2=A0 For securi= ty:
Passau, Germany=C2=A0 =C2=A0 =C2=A0 | kontakt@guelker.eu=C2=A0 =C2=A0 | () Avoid HTML e-ma= il
European Union=C2=A0 =C2=A0 =C2=A0 =C2=A0| PGP: see homepage=C2=A0 =C2=A0 = =C2=A0| /\ http://asciiribbon.org

--000000000000ade74f05b4dcb976--