From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: Include sections of org document in tangled files Date: Wed, 7 Dec 2016 19:12:15 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cEp8B-0003Lw-Ja for emacs-orgmode@gnu.org; Wed, 07 Dec 2016 22:12:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cEp87-0003ho-K7 for emacs-orgmode@gnu.org; Wed, 07 Dec 2016 22:12:23 -0500 Received: from iport-acv5-out.ucsd.edu ([132.239.0.10]:32712) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1cEp87-0003gX-5g for emacs-orgmode@gnu.org; Wed, 07 Dec 2016 22:12:19 -0500 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: David Dynerman Cc: emacs-orgmode@gnu.org On Wed, 7 Dec 2016, David Dynerman wrote: > Dear Chuck, > > Your suggestion worked fantastically - I got it working and am very excited. > > Now, the next step is figuring out how to handle typesetting math in single way between org and python docstrings. Math in Python docstrings is usually done by RestructuredText markdown, e.g.: > > :math:`f(x) = x^2` > > while the org code should just be, for example, > > \[ > f(x) = x^2 > \] > > So the goal would be have noweb not only include a documentation block > in the python code, but also call a translation function that identifies > LaTeX fragments in the org source and converts them to ReST markdown. > This is do-able. First, look at (info "(org) Noweb reference syntax") and note that the noweb reference <> will call `my-src-block' with the `x' var set to "value_for_x" and insert the output into the current src block. Second, https://github.com/masayuko/ox-rst has a reStructuredText backend. So, you can install ox-rst.el, then write an emacs-lisp src block: #+NAME: export-body #+BEGIN_SRC emacs-lisp :var src-block-name="my-code" :results raw (save-excursion (org-babel-goto-named-src-block src-block-name) (org-export-string-as (org-babel-expand-src-block) 'rst t)) #+END_SRC and then a src-block like this #+BEGIN_SRC emacs-lisp :noweb yes :tangle yes <> #+END_SRC will insert the rst formatted text from the `my-code' src block when the latter src block is tangled. p.s. Untested with 'rst. HTH, Chuck