Skip to content

Latest commit

 

History

History
213 lines (145 loc) · 4.24 KB

wrap-results.org

File metadata and controls

213 lines (145 loc) · 4.24 KB

Using :wrap with Code Blocks

1 Examples of :wrap header

1.1 Use C-c C-v C-j w <tab> to create a :wrap header

  • Before
    #+begin_src sh :results scalar replace  
      echo "Hello World"
    #+end_src
    
    #+RESULTS:
    : Hello World
    
    
        
    echo "Hello World"
        
  • After
    #+begin_src sh :results scalar replace :wrap my_wrapper 
      echo "Hello World"
    #+end_src
    
    #+RESULTS:
    #+BEGIN_my_wrapper
    Hello World
    #+END_my_wrapper
    
    
        
    echo "Hello World"
        

1.2 Does :wrap header allow spaces?

  • Answer: Yes
    #+begin_src sh :wrap WORD1 WORD2
      echo "Does ~:wrap~ header allow spaces?"
    #+end_src
    
    #+RESULTS:
    #+BEGIN_WORD1 WORD2
    Does ~:wrap~ header allow spaces?
    #+END_WORD1
    
    
        
    echo "Does ~:wrap~ header allow spaces?"
        

1.3 Does :wrap header allow dynamic values?

  • Answer: Yes but must call dynamic values using elisp.
    #+NAME: a_named_comment
    #+BEGIN_COMMENT
    VALUE_FROM_NAMED_COMMENT
    #+END_COMMENT
    
    #+CALL: a_named_comment()
    
    #+RESULTS:
    : VALUE_FROM_NAMED_COMMENT
    
    #+begin_src sh :wrap (org-sbe a_named_comment)
      echo "Does ~:wrap~ header allow dynamic values?"
    #+end_src
    
    #+RESULTS:
    #+BEGIN_VALUE_FROM_NAMED_COMMENT
    Does ~:wrap~ header allow dynamic values?
    #+END_VALUE_FROM_NAMED_COMMENT
    
        
    echo "Does ~:wrap~ header allow dynamic values?"
        
    • Troubleshooting: What happens if don’t use elisp (org-sbe ) syntax, e.g. a_named_comment()

      Answer: Same results as passing a string value.

      # Try 1 
      
      #+begin_src sh :wrap a_named_comment()
        echo "Does ~:wrap~ header allow dynamic values?"
      #+end_src
      
      #+RESULTS:
      #+BEGIN_a_named_comment()
      Does ~:wrap~ header allow dynamic values?
      #+END_a_named_comment()
      
      # Try 2
      
      #+begin_src sh :wrap call_a_named_comment()
            echo "Does ~:wrap~ header allow dynamic values?"
      #+end_src
      
      #+RESULTS:
      #+BEGIN_call_a_named_comment()
      Does ~:wrap~ header allow dynamic values?
      #+END_call_a_named_comment()
      
      
              
      echo "Does ~:wrap~ header allow dynamic values?"
              
      echo "Does ~:wrap~ header allow dynamic values?"
              

2 Export Settings