2

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 Answers1

1

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.

Sorawee Porncharoenwase
  • 6,305
  • 1
  • 14
  • 28
  • 1
    Just to clarify for anyone reading this, in scribble syntax, this would be, for example (and works perfectly): ```@require[racket/runtime-path] @define-runtime-path[hw-file "template.rkt"] ``` – Daniel Patterson Dec 14 '22 at 14:41