将.md页面作为Django视图。
django-markdown-view的Python项目详细描述
Django Markdown View
Serve.md页面作为Django视图。
这个包的目的是使Django站点上的.md文件更容易服务。在
目录
注意
- 这个包需要测试,并有Travis和工作服正确配置。在
Requirements
测试方法:
Tested With部分描述了有抱负的目标。
- Python:3.5、3.6、3.7、3.8
- Django:2.2,3.0
注意
- Django 2.2需要SQLite 3.8.3
- Django 2.2支持python3.5、3.6和3.7。在
- django3.0支持python3.6、3.7和3.8。在
我们强烈推荐并且仅正式支持每个系列的最新版本。在
Installation
使用pip install django-markdown-view安装。在
在将'markdown_view'添加到INSTALLED_APPS设置中。在
在INSTALLED_APPS=[...,'markdown_view',...]
- (可选)将MARKDOWN_VIEW_BASE_DIR或BASE_DIR添加到设置 应用程序库的字典。见下文Settings
例如,如果设置在config/settings中/基准.py,然后:
BASE_DIR=os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
Usage
Views
使用MarkdownView、LoggedInMarkdownView或^{tt8}之一$ 从markdown_view.views为.md文件提供服务
^{pr2}$Settings
所有设置都是可选的。有关默认值,请参见markdown_view/constants.py。在
降价查看和基本方向
在When present, the value is taken as a location to append to the list of dirs that Django’s django.template.utils.get_app_template_dirs will return when passed dirname=””. This is used to locate .md files in the root of the project, e.g., a README.md file. Looks for BASE_DIR if MARKDOWN_VIEW_BASE_DIR is not found.
降价查看加载器
在A list of loaders that locate .md files. The default list includes only markdown_view.loaders.MarkdownLoader which will by default try to load .md files from root directories in INSTALLED_APPS packages much the same as Django’s django.template.loaders.app_directories.Loader looks to load from “templates”.
降价查看加载器模板目录
在The name of the directories in INSTALLED_APPS packages in which to locate .md files. Defaults to “” in order to locate .md filed in the root directories.
降价查看扩展
在The extensions to enable. These extensions are enabled be default:
- toc:
- generates a Table of Contents. If toc is removed from extensions, then MARKDOWN_VIEW_TEMPLATE_USE_TOC must be set to False.
- tables:
- enables tables.
- fenced_code:
- enables code blocks. If fenced_code is removed from extensions, then MARKDOWN_VIEW_TEMPLATE_USE_HIGHLIGHT_JS, which provides the highlighting for code blocks, can be disabled.
- markdown_view.markdown_extensions.ImageExtension:
- makes images responsive in bootstrap4.
See https://python-markdown.github.io/extensions/ and https://github.com/Python-Markdown/markdown/wiki/Third-Party-Extensions for more extensions.
You can create your own extensions by following https://github.com/Python-Markdown/markdown/wiki/Tutorial-1—Writing-Extensions-for-Python-Markdown
降价查看模板
在The Django template that’ll be used to render the HTML that is generated from the Markdown. Set your own template to style your pages. Context includes:
- markdown_content:
- The HTML produced from the Markdown.
- use_highlight_js:
- If highlight.js is enabled.
- use_toc:
- If the table of contents should be rendered.
- markdown_toc:
- A table of contents from the headers of the Markdown. Not set when use_toc is False.
- page_title:
- A guess at a page title, for now it’s the first row of the TOC. Not set when use_toc is False.
降价查看模板使用目录
在Whether to render the TOC. If false, in the template context, use_toc is False and markdown_toc and page_title are not present.
降价查看模板使用高亮显示
在Whether to load and activate the highlight.js library in the template.
Experimental Settings
降价查看使用请求上下文
在If the request context should be used as a base when creating the context with which to render the Markdown internally. This is because the Markdown is rendered once first in order to prepend it with {% load static %}. This is not well tested; YMMV.
降价查看额外上下文
在Any extra context to send to the internal render of the Markdown. Can be used to expose context to template tags embedded in the Markdown. This is not well tested; YMMV.
Implementation
在高水平上,MarkdownView将:
- 使用模板加载器查找.md,该.md的名称为文件名
- 呈现为模板,.md文件的内容以 {%load static%}}到多个上下文变量中
- 使用上下文变量为MARKDOWN_VIEW_模板提供服务
Contributing
所有的贡献都是非常欢迎的。命题、问题、错误和 使用GitHub issues跟踪增强并提交修补程序 通过pull requests。在
我们使用Travis和{a34}作为连续的集成工具。在
Changelog
0.0.4 (2020-07-09)
- 一些没有加入0.0.3的文档
0.0.3 (2020-07-09)
- 更正错误自述文件.rst在
- 向模板中的节添加ID
- 使更多设置可配置
- 提供设置以禁用可选功能
- 在自述文件.rst在
- 将项目描述改为“视图”而不是“模板”
0.0.2 (2020-07-06)
- 拆下Django pre-2.2的支架
- 添加缺少文件降价查看/降价_扩展名.py在
0.0.1 (2020-06-16)
- 初始版本。在
- 项目
标签: