Shortcodes are simple snippets that you can include in your markdown content files. VictorPy 0.1.32 will render it using a predefined template.
enable_shortcodes to False.
You can include shortcodes in your content using the following syntax:
{% the_shortcode_name %}
VictorPy 0.1.32 ships with a set of predefined shortcodes:
Generates a list of links to the pages of current section (useful for section's index page).
{% sectionpages %}
For example, this shortcode used in the current page outputs the following:
List of default templates included.
Learn how to define your own custom templates.
A list of available values in your templates.
context
mini-context
Shortcodes allow you to extend your markdown vocabulary.
advanced
customization
Allow you to show complete figure as a one-liner.
src: The address of the resource (may be something like "/static/images/my-image.jpg")alt: An alternative text for the resource (think accessibility…)caption: A descriptive text to show under the figure. If not provided, alt value will be used.{% figure src="//blog.lamaisondelamontagne.org/public/images/2011/Victor_Hugo_001.jpg" alt="Victor Hugo" %}
Figure – Victor Hugo
Generate ready-to-fly Amazon products links.
code_type: "url", "image" or "snippet"asin: The Amazon Standard Identification Number of the product to show.title: A title to display under the product (only for snippet).amazon_id parameter defined in your configuration file.
{% amazon image B072QZZDV7 %}
…outputs this:
Display a tweet.
id: The Twitter tweet id.{% tweet 860599072234844160 %}
The new mypy release is ready! https://t.co/82F7i51Q6d
— Guido van Rossum (@gvanrossum) May 5, 2017
To be documented.
To be documented.
To be documented.
To be documented.
You can create your own shortcodes in order to extend existing VictorPy 0.1.32 features:
shortcodes.py in your project directory.Every shortcode function gets a special context parameter, which contains the full context on the page using the shortcode.
def hello(context):
return "Hello, we're on {page_title}!".format(page_title=context['page']['title'])
{% hello %}
Here is the result, when used on the current page:
You can specify other parameters to customize your shortcodes behaviour.
Let's say we want to create a shortcode to display the factorial of a number. We'd like to use it this way, with a custom parameters to get the number to factorialize:
The factorial of number 4 is {% factorial 4 %}.
Let's go ahead and create the factorial function in our shortcodes.py file:
def factorial(context, n):
num = 1
n = int(n)
while n >= 1:
num = num * n
n = n - 1
return str(num)
The factorial of number 4 is {% factorial 4 %}.
Here is the result: