* Re: not-quite-literal blocks
2012-04-03 1:32 not-quite-literal blocks Thomas Lord
@ 2012-04-03 0:26 ` Eric Schulte
2012-04-04 2:11 ` Thomas Lord
2012-04-03 7:07 ` Thorsten
1 sibling, 1 reply; 4+ messages in thread
From: Eric Schulte @ 2012-04-03 0:26 UTC (permalink / raw)
To: Thomas Lord; +Cc: emacs-orgmode
Thomas Lord <lord@emf.net> 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:
>
> <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>
>
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 <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);
> ...
> }
>
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* not-quite-literal blocks
@ 2012-04-03 1:32 Thomas Lord
2012-04-03 0:26 ` Eric Schulte
2012-04-03 7:07 ` Thorsten
0 siblings, 2 replies; 4+ messages in thread
From: Thomas Lord @ 2012-04-03 1:32 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: not-quite-literal blocks
2012-04-03 1:32 not-quite-literal blocks Thomas Lord
2012-04-03 0:26 ` Eric Schulte
@ 2012-04-03 7:07 ` Thorsten
1 sibling, 0 replies; 4+ messages in thread
From: Thorsten @ 2012-04-03 7:07 UTC (permalink / raw)
To: emacs-orgmode
Thomas Lord <lord@emf.net> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: not-quite-literal blocks
2012-04-03 0:26 ` Eric Schulte
@ 2012-04-04 2:11 ` Thomas Lord
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lord @ 2012-04-04 2:11 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
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 <lord@emf.net> 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:
> >
> > <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>
> >
>
> 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 <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);
> > ...
> > }
> >
>
> 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
> >
> >
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-04 2:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-03 1:32 not-quite-literal blocks Thomas Lord
2012-04-03 0:26 ` Eric Schulte
2012-04-04 2:11 ` Thomas Lord
2012-04-03 7:07 ` Thorsten
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).