Inline code in org-mode

前端 未结 2 355
耶瑟儿~
耶瑟儿~ 2021-01-30 01:22

Markdown allows for embedded code. How can this be done in org-mode?

I know about source-code blocks:

#+begin_example
blah-blah         


        
相关标签:
2条回答
  • 2021-01-30 01:45

    You can enclose the text within = or ~ signs to have it typeset in monospaced font and export it verbatim (which means it is not processed for org-specific syntax):

    This is =verbatim text= or ~code~.
    

    You'll find all information about org-mode markup elements in the relevant section of the manual.

    0 讨论(0)
  • 2021-01-30 01:49

    While monospaced is good enough for most cases, inline code blocks have the form src_LANG[headers]{your code}. For example, src_xml[:exports code]{<tag>text</tag>}.

    Edit: Code highlighting of inline code is certainly possible, albeit with patching org.el itself: The answer given here https://stackoverflow.com/a/20652913/594138 works as advertised, turning

    - Inline code src_sh[:exports code]{echo -e "test"}
    

    Into

    in html-export. And the winning answer in this post, https://stackoverflow.com/a/28059832/594138, achieves the same without the need to patch org.el, but you will have to adapt it if you don't like the optics during editing.

    0 讨论(0)
提交回复
热议问题