Skip to content

This is a tool for inline citations in Jinja2. It'll create a small, numbered footnotes for references. 这是为 Jinja2 的行内引用设计的小工具。它可以创建一个参考资料的序号角标。

License

Notifications You must be signed in to change notification settings

linnowo/Reference_for_Jinja2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Reference for Jinja2

中文文档 / Chinese Document

The file refer.j2 is a tool for inline citations in Jinja2. It'll create a small, numbered footnotes for references.

This is designed for the sex education website KnowSex.net.

Preview image.

Usage

Import it on the page.

{% import "refer.j2" as refer%}

Use JSON create a reference variable in the specified format.

{% set data = [
    {
        "name": "A short name of this reference.",
        "caption": "Text content displayed in the references list.",
        "url": "(Optional)"
    }
]%}

For example:

{% set data = [
    {
        "name": "WCU2020",
        "caption": "United Nations, Department of Economic and Social Affairs, Population Division (2020). World Contraceptive Use 2020[DS/OL]",
        "url": "https://www.un.org/en/development/desa/population/publications/dataset/contraception/wcu2020.asp"
    },
    {
        "name": "SBHM",
        "caption": "Alfred Charles Kinsey, Wardell Baxter Pomeroy, Clyde Eugene Martin.Sexual Behavior in the Human Male[M].1948:511 - ISBN 978-0-253-33412-8"
    }
]%}

Use a macro for creating a mark.

{{ refer.mark(name , reference_variable[, page]) }}
Lorem ipsum dolor sit amet,{{ refer.mark('WCU2020', data) }} consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.{{ refer.mark('SBHM', data, 15) }}

It will display as:

Lorem ipsum dolor sit amet,[1] consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.[2]:15

Use this to place a reference list:

{{ refer.footer(reference_variable) }}

It will make the reference with <li> inside <ol class="reference-list">.

  1. ^Alfred Charles Kinsey, Wardell Baxter Pomeroy, Clyde Eugene Martin.Sexual Behavior in the Human Male[M].1948:511 - ISBN 978-0-253-33412-8.
  2. ^United Nations, Department of Economic and Social Affairs, Population Division (2020). World Contraceptive Use 2020[DS/OL]. https://www.un.org/en/development/desa/population/publications/dataset/contraception/wcu2020.asp.

中文文档

refer.j2 是为 Jinja2 的行内引用设计的。它可以创建一个参考资料的序号角标。

此工具为性教育网站“KnowSex ”设计。

示意图。

使用办法

在页面引用该文件。

{% import "refer.j2" as refer%}

像这样用 JSON 创建一个参考文献列表变量

{% set data = [
    {
        "name": "引用简称",
        "caption": "展示在参考列表的标题",
        "url": "(可选)链接"
    }
]%}

示例:

{% set data = [
    {
        "name": "WCU2020",
        "caption": "United Nations, Department of Economic and Social Affairs, Population Division (2020). World Contraceptive Use 2020[DS/OL]",
        "url": "https://www.un.org/en/development/desa/population/publications/dataset/contraception/wcu2020.asp"
    },
    {
        "name": "SBHM",
        "caption": "Alfred Charles Kinsey, Wardell Baxter Pomeroy, Clyde Eugene Martin.Sexual Behavior in the Human Male[M].1948:511 - ISBN 978-0-253-33412-8"
    }
]%}

使用创建角标:

{{ refer.mark(name , 参考文献列表变量[, 页码]) }}
Lorem ipsum dolor sit amet,{{ refer.mark('WCU2020', data) }} consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.{{ refer.mark('SBHM', data, 15) }}

生成后效果如下:

Lorem ipsum dolor sit amet,[1] consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.[2]:15

参考文献列表的生成使用如下:

{{ refer.footer(参考文献列表变量) }}

它将会在 <ol class="reference-list"> 元素中创建若干含有单条参考文献的 <li> 变量:

  1. ^Alfred Charles Kinsey, Wardell Baxter Pomeroy, Clyde Eugene Martin.Sexual Behavior in the Human Male[M].1948:511 - ISBN 978-0-253-33412-8.
  2. ^United Nations, Department of Economic and Social Affairs, Population Division (2020). World Contraceptive Use 2020[DS/OL]. https://www.un.org/en/development/desa/population/publications/dataset/contraception/wcu2020.asp.

About

This is a tool for inline citations in Jinja2. It'll create a small, numbered footnotes for references. 这是为 Jinja2 的行内引用设计的小工具。它可以创建一个参考资料的序号角标。

Topics

Resources

License

Stars

Watchers

Forks

Languages