From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Lord Subject: not-quite-literal blocks Date: Mon, 02 Apr 2012 18:32:08 -0700 Message-ID: <1333416728.2952.217.camel@dell-desktop.example.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:54984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEsbX-0004gC-7e for emacs-orgmode@gnu.org; Mon, 02 Apr 2012 21:32:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEsbU-000204-T8 for emacs-orgmode@gnu.org; Mon, 02 Apr 2012 21:32:14 -0400 Received: from smtp161.dfw.emailsrvr.com ([67.192.241.161]:48431) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEsbU-0001zY-Ly for emacs-orgmode@gnu.org; Mon, 02 Apr 2012 21:32:12 -0400 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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:
printf("hello world\n");
  
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 int main (int argc, char * argv[]) { //{{say goodnight, gracey}} return 0; } #+END_SRC and get: Say goodnight, Gracey.:
     printf ("Goodnight Gracey\n");
   
main routine:
     #include 
     int main (int argc, char * argv[])
     {
       //{say   goodnight,
gracey}}
       return 0;
     }
   
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 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 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: not-quite-literal blocks Date: Mon, 02 Apr 2012 20:26:42 -0400 Message-ID: <87wr5xbqyl.fsf@gmx.com> References: <1333416728.2952.217.camel@dell-desktop.example.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:47347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEtSU-0006C0-N1 for emacs-orgmode@gnu.org; Mon, 02 Apr 2012 22:27:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEtSS-0006Gl-Id for emacs-orgmode@gnu.org; Mon, 02 Apr 2012 22:26:58 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:33909) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SEtSS-0006GS-CI for emacs-orgmode@gnu.org; Mon, 02 Apr 2012 22:26:56 -0400 In-Reply-To: <1333416728.2952.217.camel@dell-desktop.example.com> (Thomas Lord's message of "Mon, 02 Apr 2012 18:32:08 -0700") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Thomas Lord Cc: emacs-orgmode@gnu.org Thomas Lord writes: > 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: > >
printf("hello world\n");
>   
> > 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 > int main (int argc, char * argv[]) > { > //{{say goodnight, gracey}} > return 0; > } > #+END_SRC > > and get: > > Say goodnight, Gracey.: >
>      printf ("Goodnight Gracey\n");
>    
> > main routine: >
>      #include 
>      int main (int argc, char * argv[])
>      {
>        //{say   goodnight,
> gracey}}
>        return 0;
>      }
>    
> This behavior should be fairly easily implemented through customizing the `org-babel-exp-code-template' variable, you can put any arbitrary Org-mode text into this template including literal HTML. See its documentation string for more information. > > > 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 > 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 > > > 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); > ... > } > If you're willing to hack ob-exp.el locally you could add specific header arguments to the `org-babel-exp-code-template' template. I'm not clear on a good way to do this for *any* header argument which would be general enough to push up to the main Org-mode trunk. Cheers, > > Thanks, > -t > > > -- Eric Schulte http://cs.unm.edu/~eschulte/ From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Subject: Re: not-quite-literal blocks Date: Tue, 03 Apr 2012 09:07:40 +0200 Message-ID: <871uo5s37n.fsf@googlemail.com> References: <1333416728.2952.217.camel@dell-desktop.example.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:49126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SExoi-0004KF-LN for emacs-orgmode@gnu.org; Tue, 03 Apr 2012 03:06:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SExoc-0004pH-4w for emacs-orgmode@gnu.org; Tue, 03 Apr 2012 03:06:12 -0400 Received: from plane.gmane.org ([80.91.229.3]:46304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SExob-0004pA-Tk for emacs-orgmode@gnu.org; Tue, 03 Apr 2012 03:06:06 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SExoa-0001sQ-IJ for emacs-orgmode@gnu.org; Tue, 03 Apr 2012 09:06:04 +0200 Received: from g231107245.adsl.alicedsl.de ([92.231.107.245]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 03 Apr 2012 09:06:04 +0200 Received: from quintfall by g231107245.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 03 Apr 2012 09:06:04 +0200 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Thomas Lord writes: Hi Thomas, > I am trying to piece together a simple > literate programming system that takes > HTML as input and spews out source files. are you aware of pandoc (http://johnmacfarlane.net/pandoc/)? Pandoc is capable to import html files and export them in Org-mode. ,------------------------------------------------------------------ | About pandoc | | If you need to convert files from one markup format into another, | pandoc is your swiss-army knife. Pandoc can convert documents in | markdown, reStructuredText, textile, HTML, or LaTeX to | | * HTML formats: XHTML, HTML5, and HTML slide shows using Slidy, | S5, or DZSlides. | * Word processor formats: Microsoft Word docx, OpenOffice/ | LibreOffice ODT, OpenDocument XML | * Ebooks: EPUB | * Documentation formats: DocBook, GNU TexInfo, Groff man pages | * TeX formats: LaTeX, ConTeXt, LaTeX Beamer slides | * PDF via LaTeX | * Lightweight markup formats: Markdown, reStructuredText, | AsciiDoc, MediaWiki markup, Emacs Org-Mode, Textile `------------------------------------------------------------------ Maybe it could take care of the html, leaving only the postprocessing to you? -- cheers, Thorsten From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Lord Subject: Re: not-quite-literal blocks Date: Tue, 03 Apr 2012 19:11:29 -0700 Message-ID: <1333505489.2877.657.camel@dell-desktop.example.com> References: <1333416728.2952.217.camel@dell-desktop.example.com> <87wr5xbqyl.fsf@gmx.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:38454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFFh6-0005cb-Qe for emacs-orgmode@gnu.org; Tue, 03 Apr 2012 22:11:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SFFh4-00028h-GL for emacs-orgmode@gnu.org; Tue, 03 Apr 2012 22:11:32 -0400 Received: from smtp181.dfw.emailsrvr.com ([67.192.241.181]:41545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFFh4-00028b-96 for emacs-orgmode@gnu.org; Tue, 03 Apr 2012 22:11:30 -0400 In-Reply-To: <87wr5xbqyl.fsf@gmx.com> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org Thanks Eric, that was helpful. As you said, customizing org-babel-exp-code-template was what I was looking for to name code blocks the way I had in mind -- I have it wrapping them in a custom div now. To locally hack together links from within code blocks, I found out I was able to do it in a few lines using htmlize-after-hook. -t On Mon, 2012-04-02 at 20:26 -0400, Eric Schulte wrote: > Thomas Lord writes: > > > 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: > > > >
printf("hello world\n");
> >   
> > > > 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 > > int main (int argc, char * argv[]) > > { > > //{{say goodnight, gracey}} > > return 0; > > } > > #+END_SRC > > > > and get: > > > > Say goodnight, Gracey.: > >
> >      printf ("Goodnight Gracey\n");
> >    
> > > > main routine: > >
> >      #include 
> >      int main (int argc, char * argv[])
> >      {
> >        //{say   goodnight,
> > gracey}}
> >        return 0;
> >      }
> >    
> > > > This behavior should be fairly easily implemented through customizing > the `org-babel-exp-code-template' variable, you can put any arbitrary > Org-mode text into this template including literal HTML. See its > documentation string for more information. > > > > > > > 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 > > 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 > > > > > > 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); > > ... > > } > > > > If you're willing to hack ob-exp.el locally you could add specific > header arguments to the `org-babel-exp-code-template' template. I'm not > clear on a good way to do this for *any* header argument which would be > general enough to push up to the main Org-mode trunk. > > Cheers, > > > > > Thanks, > > -t > > > > > > >