14 Module reference
14.1 Cache
14.2 Core
14.3 Decode
14.4 File
14.5 Pagetree
14.6 Render
14.7 Setup
14.8 Tag
14.9 Template
14.10 Top
On this page:
preproc-source?
markup-source?
markdown-source?
null-source?
scribble-source?
pagetree-source?
->preproc-source-path
->markup-source-path
->markdown-source-path
->null-source-path
->scribble-source-path
get-source
get-markup-source
get-markdown-source
get-preproc-source
get-null-source
get-scribble-source
->output-path
6.3.90.900

14.4 File

 (require pollen/file) package: pollen

A utility module that provides functions for working with Pollen source and output files. In ordinary use, you probably won’t need these. But if you want to do more elaborate Pollen hacking, here they are.

Pollen handles six kinds of source files:

The functions in this module rely on file extensions specified in pollen/setup. These extensions can be overridden within a project — see How to override setup values.

For each kind of Pollen source file, the corresponding output file name is derived by removing the extension from the name of the source file. So the preprocessor source file "default.css.pp" would become "default.css". (See Saving & naming your source file if this rings no bells.)

Scribble files work differently — the corresponding output file is the source file but with an "html" extension rather than "scrbl". So "pollen.scrbl" would become "pollen.html".

For more about Pollen’s file model, see File formats.

procedure

(preproc-source? val)  boolean?

  val : any/c

procedure

(markup-source? val)  boolean?

  val : any/c

procedure

(markdown-source? val)  boolean?

  val : any/c

procedure

(null-source? val)  boolean?

  val : any/c

procedure

(scribble-source? val)  boolean?

  val : any/c

procedure

(pagetree-source? val)  boolean?

  val : any/c
Test whether val is a path representing a source file of the specified type, based on its file extension. Does not check whether val exists.

Examples:
> (preproc-source? "main.css.pp")

#t

> (markup-source? "default.html.pm")

#t

> (markdown-source? "default.html.pmd")

#t

> (null-source? "index.html.p")

#t

> (scribble-source? "file.scrbl")

#t

> (pagetree-source? "index.ptree")

#t

procedure

(->preproc-source-path p)  path?

  p : pathish?

procedure

(->markup-source-path p)  path?

  p : pathish?

procedure

(->markdown-source-path p)  path?

  p : pathish?

procedure

(->null-source-path p)  path?

  p : pathish?

procedure

(->scribble-source-path p)  path?

  p : pathish?
Convert an output path p into the source path of the specified type that would produce this output path. This function simply generates a corresponding source path — it does not ask whether this source path exists. (If you want a guarantee that the file exists, use get-source.)

Examples:
> (define name "default.html")
> (->preproc-source-path name)

#<path:default.html.pp>

> (->markup-source-path name)

#<path:default.html.pm>

> (->markdown-source-path name)

#<path:default.html.pmd>

> (->scribble-source-path name)

#<path:default.scrbl>

> (->null-source-path name)

#<path:default.html.p>

procedure

(get-source p)  (or/c #f path?)

  p : pathish?

procedure

(get-markup-source p)  (or/c #f path?)

  p : pathish?

procedure

(get-markdown-source p)  (or/c #f path?)

  p : pathish?

procedure

(get-preproc-source p)  (or/c #f path?)

  p : pathish?

procedure

(get-null-source p)  (or/c #f path?)

  p : pathish?

procedure

(get-scribble-source p)  (or/c #f path?)

  p : pathish?
Find an existing source path that would produce the output path p.

The omnibus get-source will check source formats in this order: get-markup-source, get-markdown-source, get-preproc-source, get-null-source, and get-scribble-source.

The type-specific variants will, of course, only return a source file of the specified type.

In all cases, if there is no corresponding source, return #f.

procedure

(->output-path p)  path?

  p : pathish?
Convert a source path p into its corresponding output path. This function simply generates a path for a file — it does not ask whether the file exists.

If p has a poly output type, then ->output-path uses current-poly-target as the output-path extension.

Otherwise, there are no type-specific variants for this function because the output path of a Pollen source file is determined by its name.

Examples:
> (->output-path "main.css.pp")

#<path:main.css>

> (->output-path "default.html.pm")

#<path:default.html>

> (->output-path "index.html.p")

#<path:index.html>

> (->output-path "file.scrbl")

#<path:file.html>