In Scribble how can I get the path to the current file being processed?

40 views Asked by At

I'm using Scribble to pull in parts of files that are stored in other files (not written in Racket). Reading the files and getting the content in works fine, but I don't know how to figure out where the file that the function is being invoked is in, so the only way to get it to work is to pass in a path relative to the root of the document, which is unpleasant.

i.e., I have a directory structure like:

...
hw/
  hwN/
     assignment.scrbl
     template.EXT
...

And in assignment.scrbl, I want to pull in parts of template.EXT, but currently I have to write hw/hwN/template.ext. It would be a lot nicer to, as I can do with @include-section, be able to write just template.EXT, so that if I rearrange the directories I won't break all of these paths.

1

There are 1 answers

1
Sorawee Porncharoenwase On BEST ANSWER

This is not really specific to Scribble. In Racket, you would do:

(require racket/runtime-path)
(define-runtime-path template.EXT "template.EXT")

then you can use template.EXT to refer to the file.