Menu

#489 feature: interleave code and wikitext somehow

workingwiki
open
None
5
2014-02-15
2014-02-15
Lee Worden
No

Think of Sweave: it lets you write a latex document that's also an R program, where for example you define variables early, and use them later to generate derived quantities and plots.

Likewise in Sagetex you can do the same thing, but with Sage code doing live computations in your .tex document.

WW lets you put pieces of code in the source text of your wiki page, but they all stand alone. JD's R rules are one way to make them talk to each other; it doesn't communicate function definitions and imported libraries from one script to another, if I remember right, and my more rudimentary sage version of the same concept has similar limitations. When including bits of latex into wikitext we wish we could define macros and include packages and use them in later latex tags on the page.

Is there a way WW could allow Sweave-like coding, with the disjoint bits of code being evaluated in a shared context?

Discussion

  • Lee Worden

    Lee Worden - 2014-02-15

    I guess I could imagine writing a make rule that would find all the files of a certain suffix and run them all together. That would work in the existing WW.

    But it has the problem of knowing which things are on the same page, and in what order.

     
  • Lee Worden

    Lee Worden - 2014-02-15

    So one way would be along with $(WW_THIS_PROJECT_SOURCE_FILES) to also provide info about the arrangement of files on pages.

    Make's data structures are not powerful, but there are always ways to represent things... for example maybe

    $(WW_SOURCE_PAGE_INDICES) = '1 2'
    $(WW_SOURCE_PAGE_1) = 'MyProject'
    $(WW_SOURCE_PAGE_2) = 'MyProject/weird stuff'
    $(WW_SOURCE_FILES_ON_PAGE_1) = 'preamble.tex-math eqn1.tex-math eqn2.tex-math'
    $(WW_SOURCE_FILES_ON_PAGE_2) = 'exploratory-math.sage-snippet weird-plot.sage-snippet'

    So then you could write rules to run those things together if you wanted.

    Not sure how you would run things together and keep track of what's the output of each, though.

     
  • Anonymous

    Anonymous - 2014-02-15

    Can't log in for some reason ... maybe you can figure out who I am from context.

    My R rules do keep function definitions; not sure R why makes it so hard to keep libraries, but I agree it's a problem.

    I am already realizing a lot of the functionality envisioned here with manual make rules, e.g.

    #! /usr/bin/make
    manuscript.tex: top.texpart1.tex part2.tex bottom.tex
        cat $^ > $@
    

    We could make this more user friendly with little effort by:

    1) adding a make variable

    #! /usr/bin/make
    COMBINE = cat $^ > $@
    

    2) Make this work in the .step framework, so that you could do something like

    <source-file filename="manuscript.tex.step" display="source">
    # consists: top.texpart1.tex part2.tex bottom.tex
    </source-file>
    

    and combine with other .step functionality.

    I understand this is not quite what you have in mind, and I'll mention that there is a connection here with things I wanted to do manually many years ago by allowing non-delimited source files (in other words, turning a whole wiki page into a source file).

     

Anonymous
Anonymous

Add attachments
Cancel