emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Differentiate source blocks in export?


From: John Kitchin
Subject: Re: Differentiate source blocks in export?
Date: Tue, 24 Nov 2020 11:15:54 -0500

Nice! Here is a little more compact way to do that I think:

@@html:<div class="myclass">@@
#+BEGIN_SRC python
print(5)
#+END_SRC
@@html:</div>@@


John

-----------------------------------
Professor John Kitchin 
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803


On Tue, Nov 24, 2020 at 11:08 AM Marvin ‘quintus’ Gü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
    <div class="myclass">
    #+END_EXPORT

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

    #+BEGIN_EXPORT html
    </div>
    #+END_EXPORT

    Normal codeblock without:

    #+BEGIN_SRC c
    #include <stdio.h>
    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ülker | https://mg.guelker.eu |    For security:
Passau, Germany      | kontakt@guelker.eu    | () Avoid HTML e-mail
European Union       | PGP: see homepage     | /\ http://asciiribbon.org


reply via email to

[Prev in Thread] Current Thread [Next in Thread]