Search code examples
org-modemarkup

Is there a way to render a code/verbatim text with a grey background in orgmode markup language?


In markdown, when I put a text between two backsticks, the text will be rendered text with a grey background. I want to find a similar markup in orgmode, especially when it can be exported to other format and rendered correctly (ex: in HTML it would be <code>text</code>). The only answer that I found would be using the double = (=code=) or double ~ (~verbatim~). But when I tried exporting it to HTML, it's only rendered with verbatim text without the grey background.

It seems to be a very basic question and I've been looking around other Q&A but it doesn't seem to be mentionned anywhere.


Solution

  • The Org mode =this is code= construct is exported to HTML as <code>this is code</code> so you can use CSS to do whatever you want with that. E.g. try

    #+HTML_HEAD_EXTRA: <style>code {background-color: #ff0000}</style>
    
    * Foo
    This =code should have a red background=.
    

    This should work for HTML. Not sure whether you can do something generic that will work with any export that supports color.