Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Hacking a source filter into the #! line

by dcmertens (Scribe)
on Jul 25, 2014 at 02:28 UTC ( [id://1094980]=note: print w/replies, xml ) Need Help??


in reply to Hacking a source filter into the #! line

I have done some digging around LyX's source code and found some very interesting things. First, the LyX parser ignores commas, which means that the following is a valid (beginning of a) LyX source file:
#LyX 2.1 created this file. For more info see http://www.lyx.org/ \lyxformat, 474, \begin_document, \begin_header, \textclass, article, \begin_preamble, %ignore; use yX;

Notice the commas after every element? Those make it possible for perl to parse this document down to the "use yX", at which point the source filter can take over.

Unfortunately, I cannot find a way to override how LyX writes the contents of its files. Everything seems to boil down to calling the Buffer class's save method, which does not provide any runtime-modifiable hooks.

Perhaps I should take a different approach: defining a "Run Perl Source" output format. :-)

Replies are listed 'Best First'.
Re^2: Hacking a source filter into the #! line
by dcmertens (Scribe) on Jul 26, 2014 at 11:19 UTC
    To expand on the previous idea, LyX can produce lots of different document outputs including DVI, postscript, and PDF through multiple toolchains. I could add a "Run Perl" output document style, which would apply the source filter and run it. The problem is that the code is not run in a terminal (unless you started LyX in a terminal), so I would not be able to feed any arguments to the command. I tried invoking Prima, to see if I could provide a cross-platform mechanisms for getting user input, but encountered trouble. This still may be the best way to do things, but it'll be hard.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1094980]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found