emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thomas Lord <lord@emf.net>
To: emacs-orgmode@gnu.org
Subject: not-quite-literal blocks
Date: Mon, 02 Apr 2012 18:32:08 -0700	[thread overview]
Message-ID: <1333416728.2952.217.camel@dell-desktop.example.com> (raw)


I am trying to piece together a simple
literate programming system that takes
HTML as input and spews out source files.
The program that "tangles" code fragments
in the HTML into source text will be in XSLT.

Org mode is almost but not quite perfect for
generating the HTML I'd like.  

I'm writing  to ask if I'm overlooking features that
are close to what I want to do, or advice about
whether it makes sense to extend org this way
and, if so, what work is entailed.  (I'm aware
of the existing literate programming features
in org but they are pretty far from what I'm
looking for, I think.)

Right now, I can write something like this:

  #+BEGIN_SRC C
    printf ("hello world\n");
  #+END_SRC

and, via HTML export, get:

  <pre class="src src-C">printf("hello world\n");
  </pre>

What I'd really like is the ability to do this:

  #+BEGIN_SRC C name="Say goodnight, Gracey."
    printf ("Goodnight, Gracey\n"); 
  #+END_SRC 

  #+BEGIN_SRC C name="main routine" file="burns.c"
    #include <stdio.h>
    int main (int argc, char * argv[])
    {
      //{{say   goodnight, gracey}}
      return 0;
    } 
  #+END_SRC

and get:

   <i>Say goodnight, Gracey.</i>:
   <pre class="src src-C" id="say_goodnight_gracey">
     printf ("Goodnight Gracey\n");
   </pre>

   <i>main routine</i>:
   <pre class="src src-C" id="main_routine" file="burns.c">
     #include <stdio.h>
     int main (int argc, char * argv[])
     {
       <a href="#say_goodnight_gracey"><i>//{say   goodnight,
gracey}}</i></a>
       return 0;
     }
   </pre>


You can probably see how if I could get those mangled
"id" attributes in there, along with the hyperlinks,
it's pretty easy to tangle the result to produce a 
source file like:

    #include <stdio.h>
    int main (int argc, char * argv[])
    {
      printf ("Goodnight, Gracey\n");
      return 0;
    }

Any suggestions on what I would need to do 
to get code blocks like this?   The precise details of
the particular HTML mark-up are a little bit 
flexible.

Huge "bonus points" if I can specify arbitrary
attributes (not just "id" and "file") *and*
introduce spans with a specific "id" in code.
Like:

   #+BEGIN_SRC C id="print something" params="thing rest"
     printf (/*{thing}*/, /*{rest}*/);
   #+END_SRC

for 
    <pre ... id="print_something" params="thing rest">
      printf (<span ... name="thing">/*thing*/</span>, ...);
    </pre>

and

    #+BEGIN_SRC id="main routine" ...
    ...
    int main (int argc, char * argv[])
    {
      //{{print something}thing={"argc is %d\n"}rest={argc}}
      return 0;
    }
    #+END_SRC

for the obvious HTML expansion, all to ultimately generate
(through the XSLT code):

    ...
    int main (...)
    {
       printf ("argc is %d\n", argc);
       ...
    }

Thanks,
-t

             reply	other threads:[~2012-04-03  1:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-03  1:32 Thomas Lord [this message]
2012-04-03  0:26 ` not-quite-literal blocks Eric Schulte
2012-04-04  2:11   ` Thomas Lord
2012-04-03  7:07 ` Thorsten

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1333416728.2952.217.camel@dell-desktop.example.com \
    --to=lord@emf.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).