emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to escape # character in #+begin_src bash block for html export?
@ 2018-03-22 16:18 Abigaile Johannesburg
  2018-03-25  8:39 ` Michael Welle
  0 siblings, 1 reply; 4+ messages in thread
From: Abigaile Johannesburg @ 2018-03-22 16:18 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

Dear community,

I have a minor question about how to escape '#' character in #+begin_src bash block. For example, when I export the source code block for bash, I can use

#+begin_src bash
$<some bash command for normal user>
#+end_src

But if I want to use # for indicating commands for root or privileged user, if I use 

#+begin_src bash
#<some bash command for root user>
#+end_src 

then the commands after '#' will be in italics, i.e., they are treated as comments in html export.

How do I solve this problem?

Thanks in advance. 

Abi

[-- Attachment #2: Type: text/html, Size: 785 bytes --]

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

* Re: How to escape # character in #+begin_src bash block for html export?
  2018-03-22 16:18 How to escape # character in #+begin_src bash block for html export? Abigaile Johannesburg
@ 2018-03-25  8:39 ` Michael Welle
  2018-03-25 22:10   ` Nick Dokos
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Welle @ 2018-03-25  8:39 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Abigaile Johannesburg <abij@tuta.io> writes:

> Dear community,
>
> I have a minor question about how to escape '#' character in
> #+begin_src bash block. For example, when I export the source code
> block for bash, I can use
>
> #+begin_src bash
> $<some bash command for normal user>
> #+end_src
>
>
> But if I want to use # for indicating commands for root or privileged
> user, if I use
>
> #+begin_src bash
> #<some bash command for root user>
> #+end_src 
>
> then the commands after '#' will be in italics, i.e., they are treated
> as comments in html export.
>
> How do I solve this problem?
I'm not sure if I understand your problem correctly. # starts a comment
in shell, and $ denotes (among others maybe) a variable name. In that
sense 

#+begin_src bash
$ls
#+end_src

delivers the value of the variable ls. The semantic of $ is not to
execute the command ls as a non-root user. Same goes for #. If you want
to put your own semantics into $ and # it might be better to not use a
bash code block.

If you want to note that some commands in a script needs root privilege,
maybe something like this would do the trick:

#+begin_src bash
ls
su - -c 'fdisk /dev/rdsk/c0d1/p0'
emacs&
#+end_src

Regards
hmw

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

* Re: How to escape # character in #+begin_src bash block for html export?
  2018-03-25  8:39 ` Michael Welle
@ 2018-03-25 22:10   ` Nick Dokos
  2018-03-26  9:32     ` Michael Welle
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Dokos @ 2018-03-25 22:10 UTC (permalink / raw)
  To: emacs-orgmode

Michael Welle <mwe012008@gmx.net> writes:

> Hello,
>
> Abigaile Johannesburg <abij@tuta.io> writes:
>
>> Dear community,
>>
>> I have a minor question about how to escape '#' character in
>> #+begin_src bash block. For example, when I export the source code
>> block for bash, I can use
>>
>> #+begin_src bash
>> $<some bash command for normal user>
>> #+end_src
>>
>>
>> But if I want to use # for indicating commands for root or privileged
>> user, if I use
>>
>> #+begin_src bash
>> #<some bash command for root user>
>> #+end_src 
>>
>> then the commands after '#' will be in italics, i.e., they are treated
>> as comments in html export.
>>
>> How do I solve this problem?
> I'm not sure if I understand your problem correctly. # starts a comment
> in shell, and $ denotes (among others maybe) a variable name. In that
> sense 
>
> #+begin_src bash
> $ls
> #+end_src
>
>
> delivers the value of the variable ls. The semantic of $ is not to
> execute the command ls as a non-root user. Same goes for #. If you want
> to put your own semantics into $ and # it might be better to not use a
> bash code block.
>
> If you want to note that some commands in a script needs root privilege,
> maybe something like this would do the trick:
>
> #+begin_src bash
> ls
> su - -c 'fdisk /dev/rdsk/c0d1/p0'
> emacs&
> #+end_src
>
> Regards
> hmw
>
>

As Michael Welle points out

#+begin_src shell
# date
#+end_src

is a do-nothing source block since the command is commented out.

If you are trying to produce documentation and want to show commands
that the user should type then you probably need an example block:

#+begin_example 
# date
#+end_example

-- 
Nick

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

* Re: How to escape # character in #+begin_src bash block for html export?
  2018-03-25 22:10   ` Nick Dokos
@ 2018-03-26  9:32     ` Michael Welle
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Welle @ 2018-03-26  9:32 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Nick Dokos <ndokos@gmail.com> writes:
[...]
> Michael Welle <mwe012008@gmx.net> writes:

> If you are trying to produce documentation and want to show commands
> that the user should type then you probably need an example block:
>
> #+begin_example 
> # date
> #+end_example
another idea: How about using shell code blocks for root commands as
well and attaching a CSS class to the block and colour the background?

Regards
hmw

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

end of thread, other threads:[~2018-03-26  9:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22 16:18 How to escape # character in #+begin_src bash block for html export? Abigaile Johannesburg
2018-03-25  8:39 ` Michael Welle
2018-03-25 22:10   ` Nick Dokos
2018-03-26  9:32     ` Michael Welle

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