Very cool!  I'm looking forward to trying this out?  Does LyX-Code
support syntax highlighting?

--Chris

On Sat, Jun 28, 2014 at 1:06 AM, David Mertens <[email protected]> wrote:
> Hey everyone,
>
> Today I was about to sit down to do some research and I thought, "Gee, it
> sure would be nice if there was a better way to integrate my code and my
> typeset thoughts." I use LyX for all of my writing, so that was where I
> turned. (As you might have guessed, I didn't get any research done after
> this idea wormed its way into my head.) After a few ideas fizzled, I came up
> with the rather novel idea of creating a source filter for LyX files. The
> source filter extracts the text from any LyX-Code sections of the document.
>
> The code is remarkably simple and short. It almost feels like a hack, but
> I've written a handful of tests that show it works for fairly normal forms
> of code. It's very easy to add new tests (just add a lyx file to the t/
> directory) so adding tests for edge cases and LyX weirdness will be very
> easy. Hacking a solution will probably be equally simple.
>
> To use this, you simply create a new LyX document. Type in it just as you
> would any other LyX document. Then add a "paragraph" using the style
> "LyX-Code" (instead of Standard) and type in some real Perl code. A simple
> Hello World printout is sufficient. (Note that LyX has support for tab
> indentation in LyX-Code sections, but no more than one new level per line.
> Spaces are not limited.) After saving the file, you can execute that code by
> saying
>
> perl -MyX the-file.lyx
>
> The module is currently available on Github. Simply clone and then run the
> normal incantation of Build, Build test, and Build install. A simple example
> provides the Fibonacci series, along with commentary on its behavior for
> non-integer inputs.
>
> If you use LyX, please check this out and let me know what you think. In
> particular, let me know if you hit bugs or strange behavior.
>
> Happy science!
> David
>
> P. S. LyX lets you put math-mode equations in LyX-Code. Within 10 minutes of
> figuring that out, I made it possible to have Perl variable names that
> include subscripts! Of course, there are many ways for math-mode within Perl
> code to go wrong, and I'll have to code defensively for that, but variable
> names with subscripts is pretty sweet! :-D
>
> --
>  "Debugging is twice as hard as writing the code in the first place.
>   Therefore, if you write the code as cleverly as possible, you are,
>   by definition, not smart enough to debug it." -- Brian Kernighan
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to