Verto
stable

Contents

  • Installing Verto
  • Using Verto
  • Using Processors
  • Available Processors
    • Blockquote
    • Boxed Text
    • Button Link
    • Comment
    • Conditional
    • External Link
    • Embed iframe
    • Glossary Link
    • Heading
    • Image
    • Inline Image
    • Interactive
    • Panel
    • Relative Link
      • Overriding HTML for Relative Links
    • Remove Title
    • Save Title
    • Scratch
    • Scratch (Inline)
    • Table of Contents
    • Video
  • Implicit Processors
  • Extensions
  • Contributing to Verto
  • Changelog
Verto
  • Docs »
  • Using Processors »
  • Relative Link
  • Edit on GitHub

Relative Link¶

Processor name: relative-link

This processor will find any relative links (a link that doesn’t start with http:), and prepend the link with a Django template placeholder. When the resulting HTML is rendered with Django, the Django system can insert the root URL into the template placeholder for correct rendering.

The default HTML for relative links is:

<a href='{{ "{{ base_path }}" }}{{ link_path }}{{ link_query }}'>{{ text }}</a>

Using the following example tag:

Check out this [resource](resource/134).

The resulting HTML would be:

<p>Check out this <a href="{{ base_path }}resource/134">resource</a>.</p>

Overriding HTML for Relative Links¶

When overriding the HTML for relative links, the following Jinja2 placeholders are available:

  • {{ link_path }} - The given link URL.
  • {{ link_query }} - The given link query parameters.

Example

For this example, we wish to create HTML to be used in a static site system (not Django). The relative link processor should append the website’s URL to each link.

For example, providing the following HTML template:

http://www.example.com/{{ link_path }}{{ link_query }}

with the following Markdown:

Check out this [resource](resource/556).

would result in:

<p>Check out this <a href="http://www.example.com/resource/556">resource</a>.</p>
Next Previous

© Copyright 2017 University of Canterbury Computer Science Education Research Group Revision fdc35dbf.

Built with Sphinx using a theme provided by Read the Docs.