innoconv.extensions.copy_static

Extension that copies static files.

Content can include figures, images and videos. Static files can be included in a special folder named _static. The files will be copied to the output directory automatically.

Translation

It’s possible to have language-specific versions of a static file.

For that to work you need to have a _static folder beneath the language folder. Files in this folder will take precedence over the common _static folder for that language.

Example: en/_static/example.png takes precedence over _static/example.png in the English version.

Relative and absolute reference

Files can be referenced using relative or absolute paths.

Absolute paths are resolved to the root folder, either the common (_static) or language-specific (en/_static) folder.

Relative paths are resolved to the root folder but have the chapters path fragment appended.

Example

This example shows how a reference to an image is resolved. The references happen inside the section chapter01 in the English language version.

Type Resolution
Relative subdir/my_picture.pngen/_static/chapter01/subdir/my_picture.png
Absolute /subdir/my_picture.pngen/_static/subdir/my_picture.png
class innoconv.extensions.copy_static.CopyStatic(*args, **kwargs)[source]

Bases: innoconv.extensions.abstract.AbstractExtension

Copy static files to the output folder.

This extension copies checks the AST for references to static files and copies them from the content source directory to the output directory.

start(output_dir, source_dir)[source]

Remember directories.

pre_conversion(language)[source]

Remember current conversion language.

pre_process_file(path)[source]

Remember file path.

post_process_file(ast, _)[source]

Generate list of files to copy.

finish()[source]

Copy static files to the output folder.