将.md页面作为Django视图。

django-markdown-view的Python项目详细描述


Django Markdown View

https://travis-ci.org/rgs258/django-markdown-view.svg?branch=masterhttps://coveralls.io/repos/github/rgs258/django-markdown-view/badge.svg?branch=master

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

  1. 使用pip install django-markdown-view安装。在

  2. 'markdown_view'添加到INSTALLED_APPS设置中。在

    INSTALLED_APPS=[...,'markdown_view',...]
  3. (可选)将MARKDOWN_VIEW_BASE_DIRBASE_DIR添加到设置
    应用程序库的字典。见下文Settings

    例如,如果设置在config/settings中/基准.py,然后:

    BASE_DIR=os.path.dirname(os.path.dirname(os.path.dirname(__file__)))

Usage

Views

使用MarkdownViewLoggedInMarkdownView或^{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将:

  1. 使用模板加载器查找.md,该.md的名称为文件名
  2. 呈现为模板,.md文件的内容以 {%load static%}}到多个上下文变量中
  3. 使用上下文变量为MARKDOWN_VIEW_模板提供服务

Contributing

所有的贡献都是非常欢迎的。命题、问题、错误和 使用GitHub issues跟踪增强并提交修补程序 通过pull requests。在

我们使用Travis和{a34}作为连续的集成工具。在

Authors

Wharton Computing

  • 瑞安·J·沙利文

Changelog

0.0.4 (2020-07-09)

  1. 一些没有加入0.0.3的文档

0.0.3 (2020-07-09)

  1. 更正错误自述文件.rst在
  2. 向模板中的节添加ID
  3. 使更多设置可配置
  4. 提供设置以禁用可选功能
  5. 在自述文件.rst在
  6. 将项目描述改为“视图”而不是“模板”

0.0.2 (2020-07-06)

  1. 拆下Django pre-2.2的支架
  2. 添加缺少文件降价查看/降价_扩展名.py在

0.0.1 (2020-06-16)

  1. 初始版本。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在wicket中创建元素<a>   java如何将字节/整数转换为十六进制以雕刻文件   javajavafx:为什么不管我传递给'textArea'的是什么类型的'changeListener'都无法编译。getKeyPressedProperty()。addListener`   java自定义Listview性能不佳,Listview项名称从数据库转换   单元测试java。lang.AssertionError:响应内容   java如何使用highchart缩放条形图?   RouterFunction中的java Why谓词字段。DefaultRouterFunction<T extends ServerResponse>类获取DefaultErrorWebExceptionHandler?   java我可以用Map<String,Integer>覆盖Map<Integer,Integer>吗?   java Log4j文件已创建但为空   java无法解析JavaCV中的导入   Sun PKCS11实现的java 64位替代方案   java Hibernate与JDO makeTransient的等价物是什么   java从嵌套的switch语句退出到外部switch语句   java Android保留一个位图作为更改色调、对比度、饱和度等的源   java Mule ESB 3.5创建ws-client时出错   java数组循环将自身乘以1024   java数据库自动更新失败   java递归ConcurrentHashMap。ComputeFabSent()调用永远不会终止。Bug还是“功能”?   java是否为调用方方法中正在处理的异常执行hibernate回滚事务?