[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] example filter for code blocks?
From: |
Marcin Borkowski |
Subject: |
Re: [O] example filter for code blocks? |
Date: |
Thu, 26 Sep 2013 11:04:01 +0200 |
Dnia 2013-09-25, o godz. 20:03:10
John Kitchin <address@hidden> napisaĆ(a):
> Hi everyone,
>
> I have an idea for putting links in a pdf that would open python code
> blocks in an editor. To do that, I need to modify what happens when an
> org-file is published to latex.
>
> Essentially I want it to do exactly what it already does in terms of
> running pygments, and making nicely formatted and syntax highlighted
> code blocks and output.
>
> After that though, I want to tangle the code block to a file in a
> directory, and insert a new link after the rendered code block. I
> would prefer not to have to put :tangle headings in each code block
> because there are many (e.g. hundreds) of them in course notes. It
> would be sufficient if they were just sequentially numbered as
> dir/1.py, dir/2.py, etc... and it is fine if these get overwritten on
> each export.
>
> the link that would go after the code block in the latex export would
> be something like:
> \LaunchPython{dir/1.py}{Open code}
>
> Then clicking on it would open dir/1.py in whatever editor your
> system is configured for. \LaunchPython is a newcommand I have
> defined that works already.
>
> It seems like the new export engine should make this easy to do, but
> I am not sure where to start. Could anyone point me to a starting
> place? Thanks!
I'm not 100% sure, but I think you can do this (maybe more easily,
maybe not) on the LaTeX side. Check out the etoolbox package, look at
the patching commands and remember that \begin{foo} ... \end{foo}
translate (more or less) into something like \begingroup\foo ...
\endfoo\endgroup, so patching \endfoo might be the way to go.
> John
hth
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University