Updated/completed JavaScript docs.

This commit is contained in:
Pouria Hadjibagheri 2017-07-10 11:26:11 +01:00
parent c82de56b84
commit ee38655cd5
49 changed files with 1716 additions and 1662 deletions

View file

@ -38,6 +38,7 @@ extensions = [
'sphinx.ext.githubpages',
'classycode',
'sphinxcontrib.autoanysrc',
'sphinx.ext.autosectionlabel'
# 'edit_on_github'
]

View file

@ -1,98 +1,237 @@
MarkdownX
---------
.. js:data:: GeneralEventHandlers
:JSON Object: General (document level) event handlers.
.. js:function:: inhibitDefault(event)
Routine tasks for event handlers (e.g. default preventions).
:param Event|KeyboardEvent event: The events to be inhibited.
:returns: event
:return type: Event
.. js:function:: onDragEnter (event)
Upon enter (when a file, e.g. an image, is dragged into the browser),
the defualt events are inhibited, and the drop event is set as `copy`.
:param DragEvent event: Drag event.
:returns: Inhibited drag event with `copy` added to the drop event.
:return type: Event
.. js:data:: keyboardEvents
:JSON Object: Keyboard events and their handlers.
.. js:attribute:: TAB
- (*string*) - represents: ``Tab``
.. js:attribute:: DUPLICATE
- (*string*) - represents: ``d``
.. js:attribute:: UNINDENT
- (*string*) - represents: ``[``
.. js:attribute:: INDENT
- (*string*) - represents: ``]``
.. js:function:: hub(event)
Mapping of hotkeys from keyboard events to their corresponding functions.
:param KeyboardEvent event: Keyboard event to be handled.
:return type: Function | Boolean
.. js:data:: Handlers
Handler functions, as mapped by :js:func:`hub`.
:JSON Object: Hotkey response functions.
.. note::
Properties receive a single argument ``properties``, which is an instance of :js:data:`properties`. See the
``markdownx`` class for additional details.
.. js:function:: applyTab(properties)
Smart application of tab indentations under various conditions.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: removeTab(properties)
Smart removal of tab indentations.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: _multiLineIndentation(properties)
**private**
Handles multi line indentations.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: applyIndentation(properties)
Smart application of indentation at the beginning of the line.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: removeIndentation(properties)
Smart removal of indentation from the beginning of the line.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: applyDuplication(properties)
Duplication of the current or selected lines.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: getHeight(element)
Returns either the height of an element as defined in the ``style`` attribute or CSS or its browser-computed height.
:param element HTMLElement: The element whose height is to be determined.
:returns: Height of the element.
:return type: number
.. js:function:: updateHeight(element)
Updates the height of an element based on its scroll height.
:param HTMLTextAreaElement editor: Editor element whose height is to be updated.
:return type: HTMLTextAreaElement
.. js:class:: MarkdownX(editor, preview)
**Example:**
MarkdownX initializer.
.. code-block:: javascript
:example:
.. code-block:: javascript
let editor = document.getElementById('MyMarkdownEditor'),
preview = document.getElementById('MyMarkdownPreview');
>>> let parent = document.getElementsByClassName('markdownx'),
... editor = parent.querySelector('.MyMarkdownEditor'),
... preview = parent.querySelector('.MyMarkdownPreview');
let mdx = new MarkdownX(editor, preview)
>>> let mdx = new MarkdownX(parent, editor, preview)
:param HTMLTextAreaElement editor: Markdown editor element.
:param HTMLElement preview: Markdown preview element.
:param HTMLElement parent: Markdown editor element.
:param HTMLTextAreaElement editor: Markdown editor element.
:param HTMLElement preview: Markdown preview element.
.. js:attribute:: editor
.. js:data:: properties
- (*HTMLTextAreaElement*) - Instance editor.
:JSON Object: Class variables.
.. js:attribute:: preview
.. js:attribute:: editor
- (*HMTLElement*) - Instance preview.
- (*HTMLTextAreaElement*) - Instance editor.
.. js:attribute:: timeout
.. js:attribute:: preview
- (*number* | *null*) - Private property; timeout settings.
- (*HMTLElement*) - Instance preview.
.. js:attribute:: _editorIsResizable
.. js:attribute:: parent
- (*Boolean*) - Private property; ``true`` if instance editor is resizable, otherwise ``false``.
- (*HMTLElement*) - Instance parent.
.. js:function:: _markdownify()
.. js:attribute:: _latency
Private settings for ``timeout``.
**private**
.. js:function:: _routineEventResponse(event)
- (*number* | *null*) - Private property; timeout settings.
Private routine tasks for event handlers (e.g. default preventions).
.. js:attribute:: _editorIsResizable
:param Event event: Event to be handled.
**private**
- (*Boolean*) - Private property; ``true`` if instance editor is resizable, otherwise ``false``.
.. js:function:: getEditorHeight(editor)
.. js:function:: _markdownify()
:param HTMLTextAreaElement editor: Markdown editor element.
:returns: The editor's height in pixels; e.g. ``"150px"``.
:return type: string
**private**
.. js:function:: inputChanged()
Settings for ``timeout``.
Event handlers in response to alterations in the instance editor.
.. js:function:: _routineEventResponse(event)
:param Event event: Event to be handled.
**private**
Routine tasks for event handlers (e.g. default preventions).
.. js:function:: onDragEnter(event)
:param Event event: Event to be handled.
Event handler for :guilabel:`dragEnter` events.
.. js:function:: getEditorHeight(editor)
:param Event event: Event to be handled.
:param HTMLTextAreaElement editor: Markdown editor element.
:returns: The editor's height in pixels; e.g. ``"150px"``.
:return type: string
.. js:function:: inputChanged()
.. js:function:: onDragLeave(event)
Event handlers in response to alterations in the instance editor.
Event handler for :guilabel:`dragLeave` events.
:param Event event: Event to be handled.
:param Event event: Event to be handled.
.. js:function:: onDragEnter(event)
Event handler for :guilabel:`dragEnter` events.
.. js:function:: onDrop(event)
:param Event event: Event to be handled.
Event handler for :guilabel:`drop` events (in drag and drops).
.. js:function:: onDragLeave(event)
:param Event event: Event to be handled.
Event handler for :guilabel:`dragLeave` events.
:param Event event: Event to be handled.
.. js:function:: onKeyDown(event)
.. js:function:: onDrop(event)
Event handler for :guilabel:`keyDown` events as registered in the instance editor.
Event handler for :guilabel:`drop` events (in drag and drops).
:param Event event: Event to be handled.
:returns: ``null`` if the key pressed is *Tab* (ASCII #9) else ``false``.
:return type: boolean | null
:param Event event: Event to be handled.
.. js:function:: sendFile()
.. js:function:: onKeyDown(event)
pass
Event handler for :guilabel:`keyDown` events as registered in the instance editor.
.. js:function:: getMarkdown()
:param Event event: Event to be handled.
:returns: ``null`` if the key pressed is *Tab* (ASCII #9) else ``false``.
:return type: boolean | null
pass
.. js:function:: sendFile(file)
.. js:function:: insertImage()
Uploading the ``file`` onto the server through an AJAX request.
pass
:param File file: File to be uploaded.
.. js:function:: getMarkdown()
Uploading the markdown text from :attr:`properties.editor` onto the server through an AJAX request, and upon
receiving the HTML encoded text in response, the response will be displayed in :attr:`properties.preview`.
.. js:function:: insertImage(textToInsert)
Inserts markdown encoded image URL into :attr:`properties.editor` where the cursor is located.
:param string textToInsert: Markdown text (with path to the image) to be inserted into the editor.

View file

@ -18,7 +18,62 @@ Utilities
not exist.
:param string name: The name of the cookie.
:returns: Value of the cookie with the key ``name`` or ``null``.
:returns: Value of the cookie with the key ``name`` or ``null``.
:return type: string | null
.. js:function:: zip(...rows)
JavaScript implementation of Python's ``zip`` function.
:param rows: Array or arrays to zipped together.
:returns: Array of zipped items.
:return type: Array[]
:example:
.. code-block:: javascript
>>> let zipped = zip([1, 'H'], [5, 'i']);
>>> zipped.map(row => row.reduce((m, n) => m + n))
// [6, "Hi"]
.. js:function:: mountEvents (...collections)
Mounts a set of events defined in an object onto the document.
:param collections: Must be JSON object and follow the structure outlined in the example.
:returns: Listeners
:return type: Event
:example:
.. code-block:: javascript
>>> let editorListeners = {
... object: document.getElementById('my-editor'),
... listeners: [
... { type: "input", capture: true , listener: inputChanged },
... { type: "compositionstart", capture: true , listener: onKeyDown }
... ]
... };
.. js:function:: triggerEvent(element, type)
Triggers an existing HTML event manually.
:param Element element: Element whose event is to be created and triggered.
:param string type: Type of the event to be triggered.
.. js:function:: triggerCustomEvent(type, element, args)
Triggers an already defined custom event manually.
:param Element|Document element: Element whose event is to be triggered.
:param string type: Type of the event to be triggered.
:param args: Values to be passed as custom argument to ``event.details``. (Default = ``null``)
.. js:function:: preparePostData(data)
@ -34,3 +89,129 @@ Utilities
:returns: A new instance **FormData** that incorporated the data embedded in ``data`` and the CSRF token in enabled.
:return type: FormData
.. js:function:: AJAXRequest()
Determines the supported AJAX requests API in IE6+ browsers.
:return type: XMLHttpRequest
:throws TypeError: AJAX request is not supported.
.. js:class:: Request(url, data)
An XMLHttpRequest wrapper object to initialize AJAX POST requests.
:example:
.. code-block:: javascript
>>> let value = "This is a test value",
postUrl = "https://example.com/";
>>> const xhr = new utils.Request(
... postUrl, // URL
... preparePostData({content: value}) // Data
... );
>>> xhr.success = response => console.log(response);
>>> xhr.error = response => console.error(response);
>>> xhr.progress = event => {
...
... if (event.lengthComputable)
... console.info(`${(event.loaded / event.total) * 100}% uploaded.`)
...
... };
>>> xhr.send();
.. js:attribute:: url
- (*string*) - URL to which the data is to be posted.
.. js:attribute:: data
- (*FormData*) - Data, as an instance of `FromData`, to be posted.
.. js:attribute:: xhr
**private**
- (*any*) - Value obtained automatically by calling :js:func:`AjaxRequest`.
.. js:function:: constructor(url, data)
:param string url: URL to which the data is to be posted.
:param FormData data: Data, as an instance of `FromData`, to be posted.
.. js:function:: progress(event)
Progress callback.
:param Event event: The entire event (see the example for additional information on usage).
.. js:function:: success(response)
Success callback.
:param any response: Success values; first available one of ``responseText``, ``responseXML``, or ``response``.
.. js:function:: error(response)
Error callback.
:param any response: Error value: ``responseText``.
.. js:function:: send()
Starts the transfer.
.. js:function:: addClass(element, ...classNames)
Given an instance of an element, adds classes to it.
:param Element element: Instance of an element.
:param string[] classNames: Can be a single string, or multiple strings.
:example:
.. code-block:: javascript
>>> addClass(document.getElementById('my-element'), 'className');
// or
>>> addClass(document.getElementById('my-element'), 'classA', 'classB', 'classC');
.. js:function:: hasClass(element, className)
Given an instance of an element, confirms whether or not the element has the class.
:param Element element: Instance of an element.
:param string[] className: Can be a single string, or multiple strings.
:returns: ``true`` if the element has the class, otherwise ``false``.
:return type: boolean
:example:
.. code-block:: javascript
>>> hasClass(document.getElementById('my-element'), 'className')
// returns True if the element with id "my-element" has the class "className", otherwise False.
.. js:function:: removeClass(element, ...classNames)
Given an instance of an element, removes classes to it.
:param Element element: Instance of an element.
:param string[] classNames: Can be a single string, or multiple strings.
:example:
.. code-block:: javascript
>>> removeClass(document.getElementById('my-element'), 'className');
// or
>>> removeClass(document.getElementById('my-element'), 'classA', 'classB', 'classC');

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Overview: module code &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Overview: module code &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../index.html"/>
<script src="../_static/js/modernizr.min.js"></script>
@ -202,7 +202,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -1,289 +0,0 @@
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>markdownx.exceptions &mdash; Django Markdownx 2.0.19 documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="up" title="Module code" href="../index.html"/>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../../index.html" class="icon icon-home"> Django Markdownx
</a>
<div class="version">
2.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../getting_started.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../example.html">Example</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../customization.html">Customization</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation.html">Translation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../js/js.html">JavaScript</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../markdownx/markdownx.html">MarkdownX Modules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contribution.html">Contributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../license.html">License</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">Django Markdownx</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html">Docs</a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>markdownx.exceptions</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for markdownx.exceptions</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">django.utils.translation</span> <span class="k">import</span> <span class="n">ugettext_lazy</span> <span class="k">as</span> <span class="n">_</span>
<span class="kn">from</span> <span class="nn">django.forms</span> <span class="k">import</span> <span class="n">ValidationError</span>
<div class="viewcode-block" id="MarkdownxImageUploadError"><a class="viewcode-back" href="../../markdownx/docs/exceptions.html#markdownx.exceptions.MarkdownxImageUploadError">[docs]</a><span class="k">class</span> <span class="nc">MarkdownxImageUploadError</span><span class="p">(</span><span class="n">ValidationError</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Custom **MarkdownX** exceptions. </span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="MarkdownxImageUploadError.not_uploaded"><a class="viewcode-back" href="../../markdownx/docs/exceptions.html#markdownx.exceptions.MarkdownxImageUploadError.not_uploaded">[docs]</a> <span class="k">def</span> <span class="nf">not_uploaded</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> No file is available to upload.</span>
<span class="sd"> :return: Locale compatible version of the error with the following message:</span>
<span class="sd"> </span>
<span class="sd"> - No files have been uploaded.</span>
<span class="sd"> </span>
<span class="sd"> :rtype: MarkdownxImageUploadError</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">MarkdownxImageUploadError</span><span class="p">(</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;No files have been uploaded.&#39;</span><span class="p">))</span></div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="MarkdownxImageUploadError.unsupported_format"><a class="viewcode-back" href="../../markdownx/docs/exceptions.html#markdownx.exceptions.MarkdownxImageUploadError.unsupported_format">[docs]</a> <span class="k">def</span> <span class="nf">unsupported_format</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> The file is of a format not defined in :guilabel:`settings.py`</span>
<span class="sd"> or if default, in :guilabel:`markdownx/settings.py`.</span>
<span class="sd"> :return: Locale compatible version of the error with the following message:</span>
<span class="sd"> </span>
<span class="sd"> - File type is not supported. </span>
<span class="sd"> </span>
<span class="sd"> :rtype: MarkdownxImageUploadError</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">MarkdownxImageUploadError</span><span class="p">(</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;File type is not supported.&#39;</span><span class="p">))</span></div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="MarkdownxImageUploadError.invalid_size"><a class="viewcode-back" href="../../markdownx/docs/exceptions.html#markdownx.exceptions.MarkdownxImageUploadError.invalid_size">[docs]</a> <span class="k">def</span> <span class="nf">invalid_size</span><span class="p">(</span><span class="n">current</span><span class="p">,</span> <span class="n">expected</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> The file is larger in size that the maximum allow in :guilabel:`settings.py` (or the default).</span>
<span class="sd"> :param current: Current size of the file.</span>
<span class="sd"> :type current: float, int</span>
<span class="sd"> :param expected: Expected (maximum permitted) size of the file.</span>
<span class="sd"> :type expected: float, int</span>
<span class="sd"> :return: Locale compatible version of the error with the following message:</span>
<span class="sd"> </span>
<span class="sd"> - Please keep file size under %(max)s. Current file size: %(current)s.&#39;</span>
<span class="sd"> </span>
<span class="sd"> :rtype: MarkdownxImageUploadError</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">django.template.defaultfilters</span> <span class="k">import</span> <span class="n">filesizeformat</span>
<span class="k">return</span> <span class="n">MarkdownxImageUploadError</span><span class="p">(</span>
<span class="n">_</span><span class="p">(</span><span class="s1">&#39;Please keep file size under </span><span class="si">%(max)s</span><span class="s1">. Current file size: </span><span class="si">%(current)s</span><span class="s1">.&#39;</span><span class="p">)</span> <span class="o">%</span> <span class="p">{</span>
<span class="s1">&#39;max&#39;</span><span class="p">:</span> <span class="n">filesizeformat</span><span class="p">(</span><span class="n">expected</span><span class="p">),</span>
<span class="s1">&#39;current&#39;</span><span class="p">:</span> <span class="n">filesizeformat</span><span class="p">(</span><span class="n">current</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">)</span></div></div>
</pre></div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2017 - Adi, Pouria Hadjibagheri.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>

View file

@ -1,421 +0,0 @@
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>markdownx.forms &mdash; Django Markdownx 2.0.19 documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="up" title="Module code" href="../index.html"/>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../../index.html" class="icon icon-home"> Django Markdownx
</a>
<div class="version">
2.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../getting_started.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../example.html">Example</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../customization.html">Customization</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation.html">Translation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../js/js.html">JavaScript</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../markdownx/markdownx.html">MarkdownX Modules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contribution.html">Contributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../license.html">License</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">Django Markdownx</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html">Docs</a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>markdownx.forms</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for markdownx.forms</h1><div class="highlight"><pre>
<span></span><span class="c1"># Python internal library.</span>
<span class="kn">from</span> <span class="nn">os</span> <span class="k">import</span> <span class="n">path</span><span class="p">,</span> <span class="n">SEEK_END</span>
<span class="kn">from</span> <span class="nn">uuid</span> <span class="k">import</span> <span class="n">uuid4</span>
<span class="kn">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">namedtuple</span>
<span class="c1"># Django library.</span>
<span class="kn">from</span> <span class="nn">django</span> <span class="k">import</span> <span class="n">forms</span>
<span class="kn">from</span> <span class="nn">django.utils.six</span> <span class="k">import</span> <span class="n">BytesIO</span>
<span class="kn">from</span> <span class="nn">django.core.files.storage</span> <span class="k">import</span> <span class="n">default_storage</span>
<span class="kn">from</span> <span class="nn">django.core.files.uploadedfile</span> <span class="k">import</span> <span class="n">InMemoryUploadedFile</span>
<span class="c1"># Internal.</span>
<span class="kn">from</span> <span class="nn">.utils</span> <span class="k">import</span> <span class="n">scale_and_crop</span><span class="p">,</span> <span class="n">xml_has_javascript</span>
<span class="kn">from</span> <span class="nn">.exceptions</span> <span class="k">import</span> <span class="n">MarkdownxImageUploadError</span>
<span class="kn">from</span> <span class="nn">.settings</span> <span class="k">import</span> <span class="p">(</span>
<span class="n">MARKDOWNX_IMAGE_MAX_SIZE</span><span class="p">,</span>
<span class="n">MARKDOWNX_MEDIA_PATH</span><span class="p">,</span>
<span class="n">MARKDOWNX_UPLOAD_CONTENT_TYPES</span><span class="p">,</span>
<span class="n">MARKDOWNX_UPLOAD_MAX_SIZE</span><span class="p">,</span>
<span class="n">MARKDOWNX_SVG_JAVASCRIPT_PROTECTION</span>
<span class="p">)</span>
<div class="viewcode-block" id="ImageForm"><a class="viewcode-back" href="../../markdownx/docs/forms.html#markdownx.forms.ImageForm">[docs]</a><span class="k">class</span> <span class="nc">ImageForm</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">Form</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Used for the handling of images uploaded using the editor through :guilabel:`AJAX`.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">forms</span><span class="o">.</span><span class="n">FileField</span><span class="p">()</span>
<span class="c1"># Separately defined as it needs to be</span>
<span class="c1"># processed a text file rather than image.</span>
<span class="n">_SVG_TYPE</span> <span class="o">=</span> <span class="s1">&#39;image/svg+xml&#39;</span>
<div class="viewcode-block" id="ImageForm.save"><a class="viewcode-back" href="../../markdownx/docs/forms.html#markdownx.forms.ImageForm.save">[docs]</a> <span class="k">def</span> <span class="nf">save</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">commit</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Saves the uploaded image in the designated location.</span>
<span class="sd"> If image type is not SVG, a byteIO of image content_type is created and</span>
<span class="sd"> subsequently save; otherwise, the SVG is saved in its existing ``charset``</span>
<span class="sd"> as an ``image/svg+xml``.</span>
<span class="sd"> *Note*: The dimension of image files (excluding SVG) are set using ``PIL``.</span>
<span class="sd"> :param commit: If ``True``, the file is saved to the disk;</span>
<span class="sd"> otherwise, it is held in the memory.</span>
<span class="sd"> :type commit: bool</span>
<span class="sd"> :return: An instance of saved image if ``commit is True``,</span>
<span class="sd"> else ``namedtuple(path, image)``.</span>
<span class="sd"> :rtype: bool, namedtuple</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">image</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">files</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;image&#39;</span><span class="p">)</span>
<span class="n">content_type</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">content_type</span>
<span class="n">file_name</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">name</span>
<span class="n">image_extension</span> <span class="o">=</span> <span class="n">content_type</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
<span class="n">image_size</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="s1">&#39;_size&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">content_type</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_SVG_TYPE</span><span class="p">:</span>
<span class="c1"># Processing the raster graphic image.</span>
<span class="c1"># Note that vector graphics in SVG format</span>
<span class="c1"># do not require additional processing and</span>
<span class="c1"># may be stored as uploaded.</span>
<span class="n">image</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process_raster</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">image_extension</span><span class="p">)</span>
<span class="n">image_size</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">tell</span><span class="p">()</span>
<span class="c1"># Processed file (or the actual file in the case of SVG) is now</span>
<span class="c1"># saved in the memory as a Django object.</span>
<span class="n">uploaded_image</span> <span class="o">=</span> <span class="n">InMemoryUploadedFile</span><span class="p">(</span>
<span class="n">file</span><span class="o">=</span><span class="n">image</span><span class="p">,</span>
<span class="n">field_name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">name</span><span class="o">=</span><span class="n">file_name</span><span class="p">,</span>
<span class="n">content_type</span><span class="o">=</span><span class="n">content_type</span><span class="p">,</span>
<span class="n">size</span><span class="o">=</span><span class="n">image_size</span><span class="p">,</span>
<span class="n">charset</span><span class="o">=</span><span class="kc">None</span>
<span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="n">content_type</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_SVG_TYPE</span>
<span class="ow">and</span> <span class="n">MARKDOWNX_SVG_JAVASCRIPT_PROTECTION</span>
<span class="ow">and</span> <span class="n">xml_has_javascript</span><span class="p">(</span><span class="n">uploaded_image</span><span class="o">.</span><span class="n">read</span><span class="p">())):</span>
<span class="k">raise</span> <span class="n">MarkdownxImageUploadError</span><span class="p">(</span>
<span class="s1">&#39;Failed security monitoring: SVG file contains JavaScript.&#39;</span>
<span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_save</span><span class="p">(</span><span class="n">uploaded_image</span><span class="p">,</span> <span class="n">file_name</span><span class="p">,</span> <span class="n">commit</span><span class="p">)</span></div>
<span class="k">def</span> <span class="nf">_save</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">image</span><span class="p">,</span> <span class="n">file_name</span><span class="p">,</span> <span class="n">commit</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Final saving process, called internally after processing tasks are complete.</span>
<span class="sd"> :param image: Prepared image</span>
<span class="sd"> :type image: django.core.files.uploadedfile.InMemoryUploadedFile</span>
<span class="sd"> :param file_name: Name of the file using which the image is to be saved.</span>
<span class="sd"> :type file_name: str</span>
<span class="sd"> :param commit: If ``True``, the image is saved onto the disk.</span>
<span class="sd"> :type commit: bool</span>
<span class="sd"> :return: URL of the uploaded image ``commit=True``, otherwise a namedtuple </span>
<span class="sd"> of ``(path, image)`` where ``path`` is the absolute path generated </span>
<span class="sd"> for saving the file, and ``image`` is the prepared image.</span>
<span class="sd"> :rtype: str, namedtuple</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># Defining a universally unique name for the file</span>
<span class="c1"># to be saved on the disk.</span>
<span class="n">unique_file_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_unique_file_name</span><span class="p">(</span><span class="n">file_name</span><span class="p">)</span>
<span class="n">full_path</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">MARKDOWNX_MEDIA_PATH</span><span class="p">,</span> <span class="n">unique_file_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">commit</span><span class="p">:</span>
<span class="n">default_storage</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">full_path</span><span class="p">,</span> <span class="n">image</span><span class="p">)</span>
<span class="k">return</span> <span class="n">default_storage</span><span class="o">.</span><span class="n">url</span><span class="p">(</span><span class="n">full_path</span><span class="p">)</span>
<span class="c1"># If `commit is False`, return the path and in-memory image.</span>
<span class="n">image_data</span> <span class="o">=</span> <span class="n">namedtuple</span><span class="p">(</span><span class="s1">&#39;image_data&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;path&#39;</span><span class="p">,</span> <span class="s1">&#39;image&#39;</span><span class="p">])</span>
<span class="k">return</span> <span class="n">image_data</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">full_path</span><span class="p">,</span> <span class="n">image</span><span class="o">=</span><span class="n">image</span><span class="p">)</span>
<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">_process_raster</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">extension</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Processing of raster graphic image using Python Imaging Library (PIL).</span>
<span class="sd"> This is where raster graphics are processed to the specifications</span>
<span class="sd"> as defined in ``settings.py``.</span>
<span class="sd"> *Note*: The file needs to be uploaded and saved temporarily in the</span>
<span class="sd"> memory to enable processing tasks using Python Imaging Library (PIL)</span>
<span class="sd"> to take place and subsequently retained until written onto the disk.</span>
<span class="sd"> :param image: Non-SVG image as processed by Django.</span>
<span class="sd"> :type image: django.forms.BaseForm.file</span>
<span class="sd"> :param extension: Image extension (e.g.: png, jpg, gif)</span>
<span class="sd"> :type extension: str</span>
<span class="sd"> :return: The image object ready to be written into a file.</span>
<span class="sd"> :rtype: BytesIO</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">thumb_io</span> <span class="o">=</span> <span class="n">BytesIO</span><span class="p">()</span>
<span class="n">preped_image</span> <span class="o">=</span> <span class="n">scale_and_crop</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="o">**</span><span class="n">MARKDOWNX_IMAGE_MAX_SIZE</span><span class="p">)</span>
<span class="n">preped_image</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">thumb_io</span><span class="p">,</span> <span class="n">extension</span><span class="p">)</span>
<span class="n">thumb_io</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">SEEK_END</span><span class="p">)</span>
<span class="k">return</span> <span class="n">thumb_io</span>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="ImageForm.get_unique_file_name"><a class="viewcode-back" href="../../markdownx/docs/forms.html#markdownx.forms.ImageForm.get_unique_file_name">[docs]</a> <span class="k">def</span> <span class="nf">get_unique_file_name</span><span class="p">(</span><span class="n">file_name</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Generates a universally unique ID using Python ``UUID`` and attaches the </span>
<span class="sd"> extension of file name to it.</span>
<span class="sd"> :param file_name: Name of the uploaded file, including the extension.</span>
<span class="sd"> :type file_name: str</span>
<span class="sd"> :return: Universally unique ID, ending with the extension extracted </span>
<span class="sd"> from ``file_name``.</span>
<span class="sd"> :rtype: str</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">extension</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">extension_dot_index</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">file_name</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">{unique_name}</span><span class="s2">.</span><span class="si">{extension}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
<span class="n">unique_name</span><span class="o">=</span><span class="n">uuid4</span><span class="p">(),</span>
<span class="n">extension</span><span class="o">=</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">file_name</span><span class="p">)[</span><span class="n">extension</span><span class="p">][</span><span class="n">extension_dot_index</span><span class="p">:]</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">file_name</span></div>
<div class="viewcode-block" id="ImageForm.clean"><a class="viewcode-back" href="../../markdownx/docs/forms.html#markdownx.forms.ImageForm.clean">[docs]</a> <span class="k">def</span> <span class="nf">clean</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Checks the upload against allowed extensions and maximum size.</span>
<span class="sd"> :return: Upload</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">upload</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cleaned_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;image&#39;</span><span class="p">)</span>
<span class="c1"># -----------------------------------------------</span>
<span class="c1"># See comments in `self._error_templates` for</span>
<span class="c1"># additional information on each error.</span>
<span class="c1"># -----------------------------------------------</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">upload</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">MarkdownxImageUploadError</span><span class="o">.</span><span class="n">not_uploaded</span><span class="p">()</span>
<span class="n">content_type</span> <span class="o">=</span> <span class="n">upload</span><span class="o">.</span><span class="n">content_type</span>
<span class="n">file_size</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">upload</span><span class="p">,</span> <span class="s1">&#39;_size&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">content_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">MARKDOWNX_UPLOAD_CONTENT_TYPES</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">MarkdownxImageUploadError</span><span class="o">.</span><span class="n">unsupported_format</span><span class="p">()</span>
<span class="k">elif</span> <span class="n">file_size</span> <span class="o">&gt;</span> <span class="n">MARKDOWNX_UPLOAD_MAX_SIZE</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">MarkdownxImageUploadError</span><span class="o">.</span><span class="n">invalid_size</span><span class="p">(</span>
<span class="n">current</span><span class="o">=</span><span class="n">file_size</span><span class="p">,</span>
<span class="n">expected</span><span class="o">=</span><span class="n">MARKDOWNX_UPLOAD_MAX_SIZE</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">upload</span></div></div>
</pre></div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2017 - Adi, Pouria Hadjibagheri.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>

View file

@ -1,413 +0,0 @@
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>markdownx.utils &mdash; Django Markdownx 2.0.19 documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="up" title="Module code" href="../index.html"/>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../../index.html" class="icon icon-home"> Django Markdownx
</a>
<div class="version">
2.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../getting_started.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../example.html">Example</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../customization.html">Customization</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation.html">Translation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../js/js.html">JavaScript</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../markdownx/markdownx.html">MarkdownX Modules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contribution.html">Contributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../license.html">License</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">Django Markdownx</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html">Docs</a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>markdownx.utils</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for markdownx.utils</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">markdown</span> <span class="k">import</span> <span class="n">markdown</span>
<span class="kn">from</span> <span class="nn">PIL</span> <span class="k">import</span> <span class="n">Image</span>
<span class="kn">from</span> <span class="nn">.settings</span> <span class="k">import</span> <span class="p">(</span>
<span class="n">MARKDOWNX_MARKDOWN_EXTENSIONS</span><span class="p">,</span>
<span class="n">MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS</span>
<span class="p">)</span>
<div class="viewcode-block" id="markdownify"><a class="viewcode-back" href="../../markdownx/docs/utilities.html#markdownx.utils.markdownify">[docs]</a><span class="k">def</span> <span class="nf">markdownify</span><span class="p">(</span><span class="n">content</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Trans-compiles Markdown text to HTML.</span>
<span class="sd"> :param content: Markdown text.</span>
<span class="sd"> :type content: str</span>
<span class="sd"> :return: HTML encoded text.</span>
<span class="sd"> :rtype: str</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">md</span> <span class="o">=</span> <span class="n">markdown</span><span class="p">(</span>
<span class="n">text</span><span class="o">=</span><span class="n">content</span><span class="p">,</span>
<span class="n">extensions</span><span class="o">=</span><span class="n">MARKDOWNX_MARKDOWN_EXTENSIONS</span><span class="p">,</span>
<span class="n">extension_configs</span><span class="o">=</span><span class="n">MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">md</span></div>
<span class="k">def</span> <span class="nf">_crop</span><span class="p">(</span><span class="n">im</span><span class="p">,</span> <span class="n">target_x</span><span class="p">,</span> <span class="n">target_y</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Crops the image to the given specifications.</span>
<span class="sd"> :param im: Instance of the image.</span>
<span class="sd"> :type im: PIL Image</span>
<span class="sd"> :param target_x: New x-axis.</span>
<span class="sd"> :type target_x: int</span>
<span class="sd"> :param target_y: New y-axis</span>
<span class="sd"> :type target_y: int</span>
<span class="sd"> :return: Cropped image.</span>
<span class="sd"> :rtype: PIL.Image</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># Use integer values now.</span>
<span class="n">source_x</span><span class="p">,</span> <span class="n">source_y</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">size</span>
<span class="c1"># Difference between new image size and requested size.</span>
<span class="n">diff_x</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">source_x</span> <span class="o">-</span> <span class="nb">min</span><span class="p">(</span><span class="n">source_x</span><span class="p">,</span> <span class="n">target_x</span><span class="p">))</span>
<span class="n">diff_y</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">source_y</span> <span class="o">-</span> <span class="nb">min</span><span class="p">(</span><span class="n">source_y</span><span class="p">,</span> <span class="n">target_y</span><span class="p">))</span>
<span class="k">if</span> <span class="n">diff_x</span> <span class="ow">or</span> <span class="n">diff_y</span><span class="p">:</span>
<span class="c1"># Center cropping (default).</span>
<span class="n">halfdiff_x</span><span class="p">,</span> <span class="n">halfdiff_y</span> <span class="o">=</span> <span class="n">diff_x</span> <span class="o">//</span> <span class="mi">2</span><span class="p">,</span> <span class="n">diff_y</span> <span class="o">//</span> <span class="mi">2</span>
<span class="n">box</span> <span class="o">=</span> <span class="p">[</span>
<span class="n">halfdiff_x</span><span class="p">,</span>
<span class="n">halfdiff_y</span><span class="p">,</span>
<span class="nb">min</span><span class="p">(</span><span class="n">source_x</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">target_x</span><span class="p">)</span> <span class="o">+</span> <span class="n">halfdiff_x</span><span class="p">),</span>
<span class="nb">min</span><span class="p">(</span><span class="n">source_y</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">target_y</span><span class="p">)</span> <span class="o">+</span> <span class="n">halfdiff_y</span><span class="p">)</span>
<span class="p">]</span>
<span class="c1"># Finally, crop the image!</span>
<span class="n">im</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">crop</span><span class="p">(</span><span class="n">box</span><span class="p">)</span>
<span class="k">return</span> <span class="n">im</span>
<span class="k">def</span> <span class="nf">_scale</span><span class="p">(</span><span class="n">im</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Scales the image to the given specifications.</span>
<span class="sd"> :param im: Instance of the image.</span>
<span class="sd"> :type im: PIL Image</span>
<span class="sd"> :param x: x-axis size.</span>
<span class="sd"> :type x: int</span>
<span class="sd"> :param y: y-axis size.</span>
<span class="sd"> :type y: int</span>
<span class="sd"> :return: Scaled image, re-sampled with anti-aliasing filter.</span>
<span class="sd"> :rtype: Image</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">im</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">resize</span><span class="p">(</span>
<span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">y</span><span class="p">)),</span>
<span class="n">resample</span><span class="o">=</span><span class="n">Image</span><span class="o">.</span><span class="n">ANTIALIAS</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">im</span>
<div class="viewcode-block" id="scale_and_crop"><a class="viewcode-back" href="../../markdownx/docs/utilities.html#markdownx.utils.scale_and_crop">[docs]</a><span class="k">def</span> <span class="nf">scale_and_crop</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">size</span><span class="p">,</span> <span class="n">crop</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">upscale</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">quality</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Modifies raster graphic images to the specifications.</span>
<span class="sd"> :param image: Raster graphic image.</span>
<span class="sd"> :type image: BytesIO</span>
<span class="sd"> :param size: New size.</span>
<span class="sd"> :type size: int</span>
<span class="sd"> :param crop: Perform cropping or not.</span>
<span class="sd"> :type crop: bool</span>
<span class="sd"> :param upscale: Whether or not to upscale the image.</span>
<span class="sd"> :type upscale: bool</span>
<span class="sd"> :param quality: Quality of the new image in DPI.</span>
<span class="sd"> :type quality: int</span>
<span class="sd"> :return: Raster graphic image modified to the given specifications.</span>
<span class="sd"> :rtype: BytesIO</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># Open image and store format/metadata.</span>
<span class="n">image</span><span class="o">.</span><span class="n">open</span><span class="p">()</span>
<span class="n">im</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">image</span><span class="p">)</span>
<span class="n">im_format</span><span class="p">,</span> <span class="n">im_info</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">format</span><span class="p">,</span> <span class="n">im</span><span class="o">.</span><span class="n">info</span>
<span class="k">if</span> <span class="n">quality</span><span class="p">:</span>
<span class="n">im_info</span><span class="p">[</span><span class="s1">&#39;quality&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">quality</span>
<span class="c1"># Force PIL to load image data.</span>
<span class="n">im</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
<span class="n">source_x</span><span class="p">,</span> <span class="n">source_y</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="nb">float</span><span class="p">,</span> <span class="n">im</span><span class="o">.</span><span class="n">size</span><span class="p">)</span>
<span class="n">target_x</span><span class="p">,</span> <span class="n">target_y</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="nb">float</span><span class="p">,</span> <span class="n">size</span><span class="p">)</span>
<span class="k">if</span> <span class="n">crop</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">target_x</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">target_y</span><span class="p">:</span>
<span class="n">scale</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">target_x</span> <span class="o">/</span> <span class="n">source_x</span><span class="p">,</span> <span class="n">target_y</span> <span class="o">/</span> <span class="n">source_y</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">scale</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">target_x</span> <span class="o">/</span> <span class="n">source_x</span><span class="p">,</span> <span class="n">target_y</span> <span class="o">/</span> <span class="n">source_y</span><span class="p">)</span>
<span class="c1"># Handle one-dimensional targets.</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">target_x</span><span class="p">:</span>
<span class="n">target_x</span> <span class="o">=</span> <span class="n">source_x</span> <span class="o">*</span> <span class="n">scale</span>
<span class="k">elif</span> <span class="ow">not</span> <span class="n">target_y</span><span class="p">:</span>
<span class="n">target_y</span> <span class="o">=</span> <span class="n">source_y</span> <span class="o">*</span> <span class="n">scale</span>
<span class="k">if</span> <span class="n">scale</span> <span class="o">&lt;</span> <span class="mf">1.0</span> <span class="ow">or</span> <span class="p">(</span><span class="n">scale</span> <span class="o">&gt;</span> <span class="mf">1.0</span> <span class="ow">and</span> <span class="n">upscale</span><span class="p">):</span>
<span class="n">im</span> <span class="o">=</span> <span class="n">_scale</span><span class="p">(</span><span class="n">im</span><span class="o">=</span><span class="n">im</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="n">source_x</span> <span class="o">*</span> <span class="n">scale</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="n">source_y</span> <span class="o">*</span> <span class="n">scale</span><span class="p">)</span>
<span class="k">if</span> <span class="n">crop</span><span class="p">:</span>
<span class="n">im</span> <span class="o">=</span> <span class="n">_crop</span><span class="p">(</span><span class="n">im</span><span class="o">=</span><span class="n">im</span><span class="p">,</span> <span class="n">target_x</span><span class="o">=</span><span class="n">target_x</span><span class="p">,</span> <span class="n">target_y</span><span class="o">=</span><span class="n">target_y</span><span class="p">)</span>
<span class="c1"># Close image and replace format/metadata, as PIL blows this away.</span>
<span class="n">im</span><span class="o">.</span><span class="n">format</span><span class="p">,</span> <span class="n">im</span><span class="o">.</span><span class="n">info</span> <span class="o">=</span> <span class="n">im_format</span><span class="p">,</span> <span class="n">im_info</span>
<span class="n">image</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="k">return</span> <span class="n">im</span></div>
<div class="viewcode-block" id="xml_has_javascript"><a class="viewcode-back" href="../../markdownx/docs/utilities.html#markdownx.utils.xml_has_javascript">[docs]</a><span class="k">def</span> <span class="nf">xml_has_javascript</span><span class="p">(</span><span class="n">data</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Checks XML for JavaScript. See &quot;security&quot; in :doc:`customization &lt;../../customization&gt;` for</span>
<span class="sd"> additional information.</span>
<span class="sd"> :param data: Contents to be monitored for JavaScript injection.</span>
<span class="sd"> :type data: str, bytes</span>
<span class="sd"> :return: ``True`` if **data** contains JavaScript tag(s), otherwise ``False``.</span>
<span class="sd"> :rtype: bool</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">re</span> <span class="k">import</span> <span class="n">search</span><span class="p">,</span> <span class="n">IGNORECASE</span><span class="p">,</span> <span class="n">MULTILINE</span>
<span class="n">data</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;UTF-8&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="c1"># ------------------------------------------------</span>
<span class="c1"># Handles JavaScript nodes and stringified nodes.</span>
<span class="c1"># ------------------------------------------------</span>
<span class="c1"># Filters against &quot;script&quot; / &quot;if&quot; / &quot;for&quot; within node attributes.</span>
<span class="n">pattern</span> <span class="o">=</span> <span class="s1">r&#39;(&lt;\s*\bscript\b.*&gt;.*)|(.*\bif\b\s*\(.?={2,3}.*\))|(.*\bfor\b\s*\(.*\))&#39;</span>
<span class="n">found</span> <span class="o">=</span> <span class="n">search</span><span class="p">(</span>
<span class="n">pattern</span><span class="o">=</span><span class="n">pattern</span><span class="p">,</span>
<span class="n">string</span><span class="o">=</span><span class="n">data</span><span class="p">,</span>
<span class="n">flags</span><span class="o">=</span><span class="n">IGNORECASE</span> <span class="o">|</span> <span class="n">MULTILINE</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">found</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="c1"># ------------------------------------------------</span>
<span class="c1"># Handles JavaScript injection into attributes</span>
<span class="c1"># for element creation.</span>
<span class="c1"># ------------------------------------------------</span>
<span class="kn">from</span> <span class="nn">xml.etree.ElementTree</span> <span class="k">import</span> <span class="n">fromstring</span>
<span class="n">parsed_xml</span> <span class="o">=</span> <span class="p">(</span>
<span class="p">(</span><span class="n">attribute</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<span class="k">for</span> <span class="n">elm</span> <span class="ow">in</span> <span class="n">fromstring</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="o">.</span><span class="n">iter</span><span class="p">()</span>
<span class="k">for</span> <span class="n">attribute</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">elm</span><span class="o">.</span><span class="n">attrib</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
<span class="p">)</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">parsed_xml</span><span class="p">:</span>
<span class="k">if</span> <span class="s1">&#39;&quot;&#39;</span> <span class="ow">in</span> <span class="n">val</span> <span class="ow">or</span> <span class="s2">&quot;&#39;&quot;</span> <span class="ow">in</span> <span class="n">val</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="c1"># It is (hopefully) safe.</span>
<span class="k">return</span> <span class="kc">False</span></div>
</pre></div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2017 - Adi, Pouria Hadjibagheri.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>

View file

@ -1,312 +0,0 @@
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>markdownx.views &mdash; Django Markdownx 2.0.19 documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="up" title="Module code" href="../index.html"/>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../../index.html" class="icon icon-home"> Django Markdownx
</a>
<div class="version">
2.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../getting_started.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../example.html">Example</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../customization.html">Customization</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation.html">Translation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../js/js.html">JavaScript</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../markdownx/markdownx.html">MarkdownX Modules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contribution.html">Contributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../license.html">License</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">Django Markdownx</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html">Docs</a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>markdownx.views</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for markdownx.views</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">django.http</span> <span class="k">import</span> <span class="n">HttpResponse</span><span class="p">,</span> <span class="n">JsonResponse</span>
<span class="kn">from</span> <span class="nn">django.utils.module_loading</span> <span class="k">import</span> <span class="n">import_string</span>
<span class="kn">from</span> <span class="nn">django.views.generic.edit</span> <span class="k">import</span> <span class="n">View</span><span class="p">,</span> <span class="n">BaseFormView</span>
<span class="kn">from</span> <span class="nn">.forms</span> <span class="k">import</span> <span class="n">ImageForm</span>
<span class="kn">from</span> <span class="nn">.settings</span> <span class="k">import</span> <span class="n">MARKDOWNX_MARKDOWNIFY_FUNCTION</span>
<div class="viewcode-block" id="MarkdownifyView"><a class="viewcode-back" href="../../markdownx/docs/views.html#markdownx.views.MarkdownifyView">[docs]</a><span class="k">class</span> <span class="nc">MarkdownifyView</span><span class="p">(</span><span class="n">View</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Conversion of Markdown to HTML.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<div class="viewcode-block" id="MarkdownifyView.post"><a class="viewcode-back" href="../../markdownx/docs/views.html#markdownx.views.MarkdownifyView.post">[docs]</a> <span class="k">def</span> <span class="nf">post</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Handling of the conversion from Markdown to HTML using the conversion</span>
<span class="sd"> function in settings under ``MARKDOWNX_MARKDOWNIFY_FUNCTION``.</span>
<span class="sd"> :param request: HTTP request.</span>
<span class="sd"> :param args: Default Django POST arguments.</span>
<span class="sd"> :param kwargs: Default Django POST keyword arguments.</span>
<span class="sd"> :return: HTTP response</span>
<span class="sd"> :rtype: django.http.HttpResponse</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">markdownify</span> <span class="o">=</span> <span class="n">import_string</span><span class="p">(</span><span class="n">MARKDOWNX_MARKDOWNIFY_FUNCTION</span><span class="p">)</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="n">markdownify</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">POST</span><span class="p">[</span><span class="s1">&#39;content&#39;</span><span class="p">]))</span></div></div>
<div class="viewcode-block" id="ImageUploadView"><a class="viewcode-back" href="../../markdownx/docs/views.html#markdownx.views.ImageUploadView">[docs]</a><span class="k">class</span> <span class="nc">ImageUploadView</span><span class="p">(</span><span class="n">BaseFormView</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Handling requests for uploading images.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># template_name = &quot;dummy.html&quot;</span>
<span class="n">form_class</span> <span class="o">=</span> <span class="n">ImageForm</span>
<span class="n">success_url</span> <span class="o">=</span> <span class="s1">&#39;/&#39;</span>
<div class="viewcode-block" id="ImageUploadView.form_invalid"><a class="viewcode-back" href="../../markdownx/docs/views.html#markdownx.views.ImageUploadView.form_invalid">[docs]</a> <span class="k">def</span> <span class="nf">form_invalid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">form</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Handling of invalid form events.</span>
<span class="sd"> :param form: Django form instance.</span>
<span class="sd"> :type form: django.forms.Form</span>
<span class="sd"> :return: JSON response with the HTTP-400 error message for AJAX requests</span>
<span class="sd"> and the default response for HTTP requests.</span>
<span class="sd"> :rtype: django.http.JsonResponse, django.http.HttpResponse</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">response</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">ImageUploadView</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">form_invalid</span><span class="p">(</span><span class="n">form</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">is_ajax</span><span class="p">():</span>
<span class="k">return</span> <span class="n">JsonResponse</span><span class="p">(</span><span class="n">form</span><span class="o">.</span><span class="n">errors</span><span class="p">,</span> <span class="n">status</span><span class="o">=</span><span class="mi">400</span><span class="p">)</span>
<span class="k">return</span> <span class="n">response</span></div>
<div class="viewcode-block" id="ImageUploadView.form_valid"><a class="viewcode-back" href="../../markdownx/docs/views.html#markdownx.views.ImageUploadView.form_valid">[docs]</a> <span class="k">def</span> <span class="nf">form_valid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">form</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> If the form is valid, the contents are saved.</span>
<span class="sd"> If the **POST** request is AJAX (image uploads), a JSON response will be</span>
<span class="sd"> produced containing the Markdown encoded image insertion tag with the URL</span>
<span class="sd"> using which the uploaded image may be accessed.</span>
<span class="sd"> JSON response would be as follows:</span>
<span class="sd"> .. code-block:: bash</span>
<span class="sd"> { image_code: &quot;![](/media/image_directory/123-4e6-ga3.png)&quot; }</span>
<span class="sd"> :param form: Django form instance.</span>
<span class="sd"> :type form: django.forms.Form</span>
<span class="sd"> :return: JSON encoded Markdown tag for AJAX requests, and an appropriate</span>
<span class="sd"> response for HTTP requests.</span>
<span class="sd"> :rtype: django.http.JsonResponse, django.http.HttpResponse</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">response</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">ImageUploadView</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">form_valid</span><span class="p">(</span><span class="n">form</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">is_ajax</span><span class="p">():</span>
<span class="n">image_path</span> <span class="o">=</span> <span class="n">form</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">commit</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">image_code</span> <span class="o">=</span> <span class="s1">&#39;![](</span><span class="si">{}</span><span class="s1">)&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">image_path</span><span class="p">)</span>
<span class="k">return</span> <span class="n">JsonResponse</span><span class="p">({</span><span class="s1">&#39;image_code&#39;</span><span class="p">:</span> <span class="n">image_code</span><span class="p">})</span>
<span class="k">return</span> <span class="n">response</span></div></div>
</pre></div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2017 - Adi, Pouria Hadjibagheri.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>

View file

@ -14,8 +14,11 @@ The default widget is as seen `here
If you would like to customise this; for instance, using `Bootstrap <https://getbootstrap.com>`_ to implement
side-by-side panes (as seen in :doc:`preview animation<index>`), you should override the default template by creating
your own template and saving it under ``markdownx/widget2.html`` (Django 1.11+) or ``markdownx/widget.html`` (Django
1.10 and below) in your project's :guilabel:`TEMPLATE_DIRS`.
your own template and saving it under ``markdownx/widget2.html`` (Django 1.11+), or ``markdownx/widget.html`` (Django
1.10 and below) in your project's :guilabel:`TEMPLATE_DIRS`.
.. Note::
In the case of Django 1.11+, you will need to `change the renderer`_ (Django docs) to ``TemplatesSetting``.
Here is an example of the contents:
@ -23,7 +26,10 @@ Here is an example of the contents:
<div class="markdownx row">
<div class="col-md-6">
<!-- Django 1.10 and below -->
{{ markdownx_editor }}
<!-- Django 1.11+ -->
{% include 'django/forms/widgets/textarea.html' %}
</div>
<div class="col-md-6">
<div class="markdownx-preview"></div>
@ -359,4 +365,5 @@ the number of CPUs, the amount memory, and how much you are willing to compromis
.. _XSS (Cross-site Scripting) attack: https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
.. _presentation: https://www.owasp.org/images/0/03/Mario_Heiderich_OWASP_Sweden_The_image_that_called_me.pdf
.. _documentations: https://docs.djangoproject.com/en/dev/topics/security/#cross-site-scripting-xss-protection
.. _CSRF protection middleware: https://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.csrf
.. _CSRF protection middleware: https://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.csrf
.. _change the renderer: https://docs.djangoproject.com/en/1.11/ref/forms/renderers/#overriding-built-in-widget-templates

View file

@ -1,98 +1,237 @@
MarkdownX
---------
.. js:data:: GeneralEventHandlers
:JSON Object: General (document level) event handlers.
.. js:function:: inhibitDefault(event)
Routine tasks for event handlers (e.g. default preventions).
:param Event|KeyboardEvent event: The events to be inhibited.
:returns: event
:return type: Event
.. js:function:: onDragEnter (event)
Upon enter (when a file, e.g. an image, is dragged into the browser),
the defualt events are inhibited, and the drop event is set as `copy`.
:param DragEvent event: Drag event.
:returns: Inhibited drag event with `copy` added to the drop event.
:return type: Event
.. js:data:: keyboardEvents
:JSON Object: Keyboard events and their handlers.
.. js:attribute:: TAB
- (*string*) - represents: ``Tab``
.. js:attribute:: DUPLICATE
- (*string*) - represents: ``d``
.. js:attribute:: UNINDENT
- (*string*) - represents: ``[``
.. js:attribute:: INDENT
- (*string*) - represents: ``]``
.. js:function:: hub(event)
Mapping of hotkeys from keyboard events to their corresponding functions.
:param KeyboardEvent event: Keyboard event to be handled.
:return type: Function | Boolean
.. js:data:: Handlers
Handler functions, as mapped by :js:func:`hub`.
:JSON Object: Hotkey response functions.
.. note::
Properties receive a single argument ``properties``, which is an instance of :js:data:`properties`. See the
``markdownx`` class for additional details.
.. js:function:: applyTab(properties)
Smart application of tab indentations under various conditions.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: removeTab(properties)
Smart removal of tab indentations.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: _multiLineIndentation(properties)
**private**
Handles multi line indentations.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: applyIndentation(properties)
Smart application of indentation at the beginning of the line.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: removeIndentation(properties)
Smart removal of indentation from the beginning of the line.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: applyDuplication(properties)
Duplication of the current or selected lines.
:param JSON properties: See object descriptions for details.
:return type: string
.. js:function:: getHeight(element)
Returns either the height of an element as defined in the ``style`` attribute or CSS or its browser-computed height.
:param element HTMLElement: The element whose height is to be determined.
:returns: Height of the element.
:return type: number
.. js:function:: updateHeight(element)
Updates the height of an element based on its scroll height.
:param HTMLTextAreaElement editor: Editor element whose height is to be updated.
:return type: HTMLTextAreaElement
.. js:class:: MarkdownX(editor, preview)
**Example:**
MarkdownX initializer.
.. code-block:: javascript
:example:
.. code-block:: javascript
let editor = document.getElementById('MyMarkdownEditor'),
preview = document.getElementById('MyMarkdownPreview');
>>> let parent = document.getElementsByClassName('markdownx'),
... editor = parent.querySelector('.MyMarkdownEditor'),
... preview = parent.querySelector('.MyMarkdownPreview');
let mdx = new MarkdownX(editor, preview)
>>> let mdx = new MarkdownX(parent, editor, preview)
:param HTMLTextAreaElement editor: Markdown editor element.
:param HTMLElement preview: Markdown preview element.
:param HTMLElement parent: Markdown editor element.
:param HTMLTextAreaElement editor: Markdown editor element.
:param HTMLElement preview: Markdown preview element.
.. js:attribute:: editor
.. js:data:: properties
- (*HTMLTextAreaElement*) - Instance editor.
:JSON Object: Class variables.
.. js:attribute:: preview
.. js:attribute:: editor
- (*HMTLElement*) - Instance preview.
- (*HTMLTextAreaElement*) - Instance editor.
.. js:attribute:: timeout
.. js:attribute:: preview
- (*number* | *null*) - Private property; timeout settings.
- (*HMTLElement*) - Instance preview.
.. js:attribute:: _editorIsResizable
.. js:attribute:: parent
- (*Boolean*) - Private property; ``true`` if instance editor is resizable, otherwise ``false``.
- (*HMTLElement*) - Instance parent.
.. js:function:: _markdownify()
.. js:attribute:: _latency
Private settings for ``timeout``.
**private**
.. js:function:: _routineEventResponse(event)
- (*number* | *null*) - Private property; timeout settings.
Private routine tasks for event handlers (e.g. default preventions).
.. js:attribute:: _editorIsResizable
:param Event event: Event to be handled.
**private**
- (*Boolean*) - Private property; ``true`` if instance editor is resizable, otherwise ``false``.
.. js:function:: getEditorHeight(editor)
.. js:function:: _markdownify()
:param HTMLTextAreaElement editor: Markdown editor element.
:returns: The editor's height in pixels; e.g. ``"150px"``.
:return type: string
**private**
.. js:function:: inputChanged()
Settings for ``timeout``.
Event handlers in response to alterations in the instance editor.
.. js:function:: _routineEventResponse(event)
:param Event event: Event to be handled.
**private**
Routine tasks for event handlers (e.g. default preventions).
.. js:function:: onDragEnter(event)
:param Event event: Event to be handled.
Event handler for :guilabel:`dragEnter` events.
.. js:function:: getEditorHeight(editor)
:param Event event: Event to be handled.
:param HTMLTextAreaElement editor: Markdown editor element.
:returns: The editor's height in pixels; e.g. ``"150px"``.
:return type: string
.. js:function:: inputChanged()
.. js:function:: onDragLeave(event)
Event handlers in response to alterations in the instance editor.
Event handler for :guilabel:`dragLeave` events.
:param Event event: Event to be handled.
:param Event event: Event to be handled.
.. js:function:: onDragEnter(event)
Event handler for :guilabel:`dragEnter` events.
.. js:function:: onDrop(event)
:param Event event: Event to be handled.
Event handler for :guilabel:`drop` events (in drag and drops).
.. js:function:: onDragLeave(event)
:param Event event: Event to be handled.
Event handler for :guilabel:`dragLeave` events.
:param Event event: Event to be handled.
.. js:function:: onKeyDown(event)
.. js:function:: onDrop(event)
Event handler for :guilabel:`keyDown` events as registered in the instance editor.
Event handler for :guilabel:`drop` events (in drag and drops).
:param Event event: Event to be handled.
:returns: ``null`` if the key pressed is *Tab* (ASCII #9) else ``false``.
:return type: boolean | null
:param Event event: Event to be handled.
.. js:function:: sendFile()
.. js:function:: onKeyDown(event)
pass
Event handler for :guilabel:`keyDown` events as registered in the instance editor.
.. js:function:: getMarkdown()
:param Event event: Event to be handled.
:returns: ``null`` if the key pressed is *Tab* (ASCII #9) else ``false``.
:return type: boolean | null
pass
.. js:function:: sendFile(file)
.. js:function:: insertImage()
Uploading the ``file`` onto the server through an AJAX request.
pass
:param File file: File to be uploaded.
.. js:function:: getMarkdown()
Uploading the markdown text from :attr:`properties.editor` onto the server through an AJAX request, and upon
receiving the HTML encoded text in response, the response will be displayed in :attr:`properties.preview`.
.. js:function:: insertImage(textToInsert)
Inserts markdown encoded image URL into :attr:`properties.editor` where the cursor is located.
:param string textToInsert: Markdown text (with path to the image) to be inserted into the editor.

View file

@ -18,7 +18,62 @@ Utilities
not exist.
:param string name: The name of the cookie.
:returns: Value of the cookie with the key ``name`` or ``null``.
:returns: Value of the cookie with the key ``name`` or ``null``.
:return type: string | null
.. js:function:: zip(...rows)
JavaScript implementation of Python's ``zip`` function.
:param rows: Array or arrays to zipped together.
:returns: Array of zipped items.
:return type: Array[]
:example:
.. code-block:: javascript
>>> let zipped = zip([1, 'H'], [5, 'i']);
>>> zipped.map(row => row.reduce((m, n) => m + n))
// [6, "Hi"]
.. js:function:: mountEvents (...collections)
Mounts a set of events defined in an object onto the document.
:param collections: Must be JSON object and follow the structure outlined in the example.
:returns: Listeners
:return type: Event
:example:
.. code-block:: javascript
>>> let editorListeners = {
... object: document.getElementById('my-editor'),
... listeners: [
... { type: "input", capture: true , listener: inputChanged },
... { type: "compositionstart", capture: true , listener: onKeyDown }
... ]
... };
.. js:function:: triggerEvent(element, type)
Triggers an existing HTML event manually.
:param Element element: Element whose event is to be created and triggered.
:param string type: Type of the event to be triggered.
.. js:function:: triggerCustomEvent(type, element, args)
Triggers an already defined custom event manually.
:param Element|Document element: Element whose event is to be triggered.
:param string type: Type of the event to be triggered.
:param args: Values to be passed as custom argument to ``event.details``. (Default = ``null``)
.. js:function:: preparePostData(data)
@ -34,3 +89,129 @@ Utilities
:returns: A new instance **FormData** that incorporated the data embedded in ``data`` and the CSRF token in enabled.
:return type: FormData
.. js:function:: AJAXRequest()
Determines the supported AJAX requests API in IE6+ browsers.
:return type: XMLHttpRequest
:throws TypeError: AJAX request is not supported.
.. js:class:: Request(url, data)
An XMLHttpRequest wrapper object to initialize AJAX POST requests.
:example:
.. code-block:: javascript
>>> let value = "This is a test value",
postUrl = "https://example.com/";
>>> const xhr = new utils.Request(
... postUrl, // URL
... preparePostData({content: value}) // Data
... );
>>> xhr.success = response => console.log(response);
>>> xhr.error = response => console.error(response);
>>> xhr.progress = event => {
...
... if (event.lengthComputable)
... console.info(`${(event.loaded / event.total) * 100}% uploaded.`)
...
... };
>>> xhr.send();
.. js:attribute:: url
- (*string*) - URL to which the data is to be posted.
.. js:attribute:: data
- (*FormData*) - Data, as an instance of `FromData`, to be posted.
.. js:attribute:: xhr
**private**
- (*any*) - Value obtained automatically by calling :js:func:`AjaxRequest`.
.. js:function:: constructor(url, data)
:param string url: URL to which the data is to be posted.
:param FormData data: Data, as an instance of `FromData`, to be posted.
.. js:function:: progress(event)
Progress callback.
:param Event event: The entire event (see the example for additional information on usage).
.. js:function:: success(response)
Success callback.
:param any response: Success values; first available one of ``responseText``, ``responseXML``, or ``response``.
.. js:function:: error(response)
Error callback.
:param any response: Error value: ``responseText``.
.. js:function:: send()
Starts the transfer.
.. js:function:: addClass(element, ...classNames)
Given an instance of an element, adds classes to it.
:param Element element: Instance of an element.
:param string[] classNames: Can be a single string, or multiple strings.
:example:
.. code-block:: javascript
>>> addClass(document.getElementById('my-element'), 'className');
// or
>>> addClass(document.getElementById('my-element'), 'classA', 'classB', 'classC');
.. js:function:: hasClass(element, className)
Given an instance of an element, confirms whether or not the element has the class.
:param Element element: Instance of an element.
:param string[] className: Can be a single string, or multiple strings.
:returns: ``true`` if the element has the class, otherwise ``false``.
:return type: boolean
:example:
.. code-block:: javascript
>>> hasClass(document.getElementById('my-element'), 'className')
// returns True if the element with id "my-element" has the class "className", otherwise False.
.. js:function:: removeClass(element, ...classNames)
Given an instance of an element, removes classes to it.
:param Element element: Instance of an element.
:param string[] classNames: Can be a single string, or multiple strings.
:example:
.. code-block:: javascript
>>> removeClass(document.getElementById('my-element'), 'className');
// or
>>> removeClass(document.getElementById('my-element'), 'classA', 'classB', 'classC');

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contributions &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Contributions &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
<link rel="next" title="License" href="license.html"/>
<link rel="prev" title="Views" href="markdownx/docs/views.html"/>
@ -413,7 +413,7 @@ whether to save the changes or discard them and hold onto the default.</p>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Customization &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Customization &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
<link rel="next" title="Translation" href="translation.html"/>
<link rel="prev" title="Example" href="example.html"/>
@ -195,12 +195,19 @@
<p>The default widget is as seen <a class="reference external" href="https://github.com/neutronX/django-markdownx/blob/master/markdownx/templates/markdownx/widget.html">here</a>.</p>
<p>If you would like to customise this; for instance, using <a class="reference external" href="https://getbootstrap.com">Bootstrap</a> to implement
side-by-side panes (as seen in <a class="reference internal" href="index.html"><span class="doc">preview animation</span></a>), you should override the default template by creating
your own template and saving it under <code class="docutils literal"><span class="pre">markdownx/widget2.html</span></code> (Django 1.11+) or <code class="docutils literal"><span class="pre">markdownx/widget.html</span></code> (Django
your own template and saving it under <code class="docutils literal"><span class="pre">markdownx/widget2.html</span></code> (Django 1.11+), or <code class="docutils literal"><span class="pre">markdownx/widget.html</span></code> (Django
1.10 and below) in your project&#8217;s <span class="guilabel">TEMPLATE_DIRS</span>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">In the case of Django 1.11+, you will need to <a class="reference external" href="https://docs.djangoproject.com/en/1.11/ref/forms/renderers/#overriding-built-in-widget-templates">change the renderer</a> (Django docs) to <code class="docutils literal"><span class="pre">TemplatesSetting</span></code>.</p>
</div>
<p>Here is an example of the contents:</p>
<div class="highlight-html"><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;markdownx row&quot;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;col-md-6&quot;</span><span class="p">&gt;</span>
<span class="c">&lt;!-- Django 1.10 and below --&gt;</span>
{{ markdownx_editor }}
<span class="c">&lt;!-- Django 1.11+ --&gt;</span>
{% include &#39;django/forms/widgets/textarea.html&#39; %}
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;col-md-6&quot;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;markdownx-preview&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
@ -606,7 +613,7 @@ the number of CPUs, the amount memory, and how much you are willing to compromis
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Example &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
<link rel="next" title="Customization" href="customization.html"/>
<link rel="prev" title="Getting Started" href="getting_started.html"/>
@ -286,7 +286,7 @@ your <span class="guilabel">app/admin.py</span> as follows:</p>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -9,7 +9,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Index &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Index &mdash; Django Markdownx 2.0.21 documentation</title>
@ -36,7 +36,7 @@
<link rel="index" title="Index"
href="#"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
<script src="_static/js/modernizr.min.js"></script>
@ -164,39 +164,83 @@
<div class="genindex-jumpbox">
<a href="#_"><strong>_</strong></a>
| <a href="#A"><strong>A</strong></a>
| <a href="#C"><strong>C</strong></a>
| <a href="#D"><strong>D</strong></a>
| <a href="#E"><strong>E</strong></a>
| <a href="#F"><strong>F</strong></a>
| <a href="#G"><strong>G</strong></a>
| <a href="#H"><strong>H</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#K"><strong>K</strong></a>
| <a href="#M"><strong>M</strong></a>
| <a href="#N"><strong>N</strong></a>
| <a href="#O"><strong>O</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#R"><strong>R</strong></a>
| <a href="#S"><strong>S</strong></a>
| <a href="#T"><strong>T</strong></a>
| <a href="#U"><strong>U</strong></a>
| <a href="#X"><strong>X</strong></a>
| <a href="#Z"><strong>Z</strong></a>
</div>
<h2 id="_">_</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#_editorIsResizable">_editorIsResizable (None attribute)</a>
</li>
<li><a href="js/docs/markdownx.html#_latency">_latency (None attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#_markdownify">_markdownify() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#_multiLineIndentation">_multiLineIndentation() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#_routineEventResponse">_routineEventResponse() (built-in function)</a>
</li>
</ul></td>
</tr></table>
<h2 id="A">A</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#addClass">addClass() (built-in function)</a>
</li>
<li><a href="js/docs/utils.html#AJAXRequest">AJAXRequest() (built-in function)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#applyDuplication">applyDuplication() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#applyIndentation">applyIndentation() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#applyTab">applyTab() (built-in function)</a>
</li>
</ul></td>
</tr></table>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="markdownx/docs/forms.html#markdownx.forms.ImageForm.clean">clean() (markdownx.forms.ImageForm method)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#constructor">constructor() (built-in function)</a>
</li>
</ul></td>
</tr></table>
<h2 id="D">D</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#data">data (None attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#DUPLICATE">DUPLICATE (None attribute)</a>
</li>
</ul></td>
</tr></table>
@ -205,6 +249,10 @@
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#editor">editor (None attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#error">error() (built-in function)</a>
</li>
</ul></td>
</tr></table>
@ -228,6 +276,8 @@
<h2 id="G">G</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#GeneralEventHandlers">GeneralEventHandlers (global variable or constant)</a>
</li>
<li><a href="markdownx/docs/forms.html#markdownx.forms.ImageForm.get_unique_file_name">get_unique_file_name() (markdownx.forms.ImageForm static method)</a>
</li>
<li><a href="js/docs/utils.html#getCookie">getCookie() (built-in function)</a>
@ -235,21 +285,41 @@
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#getEditorHeight">getEditorHeight() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#getHeight">getHeight() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#getMarkdown">getMarkdown() (built-in function)</a>
</li>
</ul></td>
</tr></table>
<h2 id="H">H</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#Handlers">Handlers (global variable or constant)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#hasClass">hasClass() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#hub">hub() (built-in function)</a>
</li>
</ul></td>
</tr></table>
<h2 id="I">I</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="markdownx/docs/forms.html#markdownx.forms.ImageForm">ImageForm (class in markdownx.forms)</a>
</li>
<li><a href="markdownx/docs/views.html#markdownx.views.ImageUploadView">ImageUploadView (class in markdownx.views)</a>
</li>
<li><a href="js/docs/markdownx.html#INDENT">INDENT (None attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#inhibitDefault">inhibitDefault() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#inputChanged">inputChanged() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#insertImage">insertImage() (built-in function)</a>
@ -259,6 +329,14 @@
</ul></td>
</tr></table>
<h2 id="K">K</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#keyboardEvents">keyboardEvents (global variable or constant)</a>
</li>
</ul></td>
</tr></table>
<h2 id="M">M</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
@ -295,6 +373,8 @@
<li><a href="markdownx/docs/exceptions.html#markdownx.exceptions.MarkdownxImageUploadError">MarkdownxImageUploadError</a>
</li>
<li><a href="markdownx/docs/admins.html#markdownx.admin.MarkdownxModelAdmin">MarkdownxModelAdmin (class in markdownx.admin)</a>
</li>
<li><a href="js/docs/utils.html#mountEvents">mountEvents() (built-in function)</a>
</li>
</ul></td>
</tr></table>
@ -310,7 +390,7 @@
<h2 id="O">O</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#onDragEnter">onDragEnter() (built-in function)</a>
<li><a href="js/docs/markdownx.html#onDragEnter">onDragEnter() (built-in function)</a>, <a href="js/docs/markdownx.html#onDragEnter">[1]</a>
</li>
<li><a href="js/docs/markdownx.html#onDragLeave">onDragLeave() (built-in function)</a>
</li>
@ -326,13 +406,35 @@
<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#parent">parent (None attribute)</a>
</li>
<li><a href="markdownx/docs/views.html#markdownx.views.MarkdownifyView.post">post() (markdownx.views.MarkdownifyView method)</a>
</li>
<li><a href="js/docs/utils.html#preparePostData">preparePostData() (built-in function)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#preparePostData">preparePostData() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#preview">preview (None attribute)</a>
</li>
<li><a href="js/docs/utils.html#progress">progress() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#properties">properties (global variable or constant)</a>
</li>
</ul></td>
</tr></table>
<h2 id="R">R</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#removeClass">removeClass() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#removeIndentation">removeIndentation() (built-in function)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#removeTab">removeTab() (built-in function)</a>
</li>
<li><a href="js/docs/utils.html#Request">Request() (class)</a>
</li>
</ul></td>
</tr></table>
@ -342,11 +444,15 @@
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="markdownx/docs/forms.html#markdownx.forms.ImageForm.save">save() (markdownx.forms.ImageForm method)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="markdownx/docs/utilities.html#markdownx.utils.scale_and_crop">scale_and_crop() (in module markdownx.utils)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#send">send() (built-in function)</a>
</li>
<li><a href="js/docs/markdownx.html#sendFile">sendFile() (built-in function)</a>
</li>
<li><a href="js/docs/utils.html#success">success() (built-in function)</a>
</li>
</ul></td>
</tr></table>
@ -354,7 +460,13 @@
<h2 id="T">T</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#timeout">timeout (None attribute)</a>
<li><a href="js/docs/markdownx.html#TAB">TAB (None attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#triggerCustomEvent">triggerCustomEvent() (built-in function)</a>
</li>
<li><a href="js/docs/utils.html#triggerEvent">triggerEvent() (built-in function)</a>
</li>
</ul></td>
</tr></table>
@ -362,19 +474,39 @@
<h2 id="U">U</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#UNINDENT">UNINDENT (None attribute)</a>
</li>
<li><a href="markdownx/docs/exceptions.html#markdownx.exceptions.MarkdownxImageUploadError.unsupported_format">unsupported_format() (markdownx.exceptions.MarkdownxImageUploadError static method)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/markdownx.html#updateHeight">updateHeight() (built-in function)</a>
</li>
<li><a href="js/docs/utils.html#url">url (None attribute)</a>
</li>
</ul></td>
</tr></table>
<h2 id="X">X</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#xhr">xhr (None attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="markdownx/docs/utilities.html#markdownx.utils.xml_has_javascript">xml_has_javascript() (in module markdownx.utils)</a>
</li>
</ul></td>
</tr></table>
<h2 id="Z">Z</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="js/docs/utils.html#zip">zip() (built-in function)</a>
</li>
</ul></td>
</tr></table>
</div>
@ -411,7 +543,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Getting Started &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Getting Started &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
<link rel="next" title="Example" href="example.html"/>
<link rel="prev" title="Installation" href="installation.html"/>
@ -253,7 +253,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Django MarkdownX &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Django MarkdownX &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="#"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="#"/>
<link rel="next" title="Installation" href="installation.html"/>
@ -305,7 +305,7 @@ found on our <a class="reference external" href="https://github.com/adi-/django-
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Installation &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Installation &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
<link rel="next" title="Getting Started" href="getting_started.html"/>
<link rel="prev" title="Django MarkdownX" href="index.html"/>
@ -243,7 +243,7 @@ you have multiple versions installed on your machine:</p>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Code &mdash; Django Markdownx 2.0.19 documentation</title>
<title>JavaScript Code &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../index.html"/>
<link rel="up" title="JavaScript" href="js.html"/>
<link rel="next" title="MarkdownX" href="docs/markdownx.html"/>
<link rel="prev" title="JavaScript" href="js.html"/>
@ -233,7 +233,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MarkdownX &mdash; Django Markdownx 2.0.19 documentation</title>
<title>MarkdownX &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../../index.html"/>
<link rel="up" title="JavaScript Code" href="../docs.html"/>
<link rel="next" title="Utilities" href="utils.html"/>
<link rel="prev" title="JavaScript Code" href="../docs.html"/>
@ -178,21 +178,333 @@
<div class="section" id="markdownx">
<h1>MarkdownX<a class="headerlink" href="#markdownx" title="Permalink to this headline"></a></h1>
<dl class="class">
<dt id="MarkdownX">
<em class="property">class </em><code class="descname">MarkdownX</code><span class="sig-paren">(</span><em>editor</em>, <em>preview</em><span class="sig-paren">)</span><a class="headerlink" href="#MarkdownX" title="Permalink to this definition"></a></dt>
<dd><p><strong>Example:</strong></p>
<div class="highlight-javascript"><div class="highlight"><pre><span></span><span class="kd">let</span> <span class="nx">editor</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;MyMarkdownEditor&#39;</span><span class="p">),</span>
<span class="nx">preview</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;MyMarkdownPreview&#39;</span><span class="p">);</span>
<span class="kd">let</span> <span class="nx">mdx</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">MarkdownX</span><span class="p">(</span><span class="nx">editor</span><span class="p">,</span> <span class="nx">preview</span><span class="p">)</span>
</pre></div>
</div>
<dl class="data">
<dt id="GeneralEventHandlers">
<code class="descname">GeneralEventHandlers</code><a class="headerlink" href="#GeneralEventHandlers" title="Permalink to this definition"></a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">JSON Object:</th><td class="field-body">General (document level) event handlers.</td>
</tr>
</tbody>
</table>
<dl class="function">
<dt id="inhibitDefault">
<code class="descname">inhibitDefault</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#inhibitDefault" title="Permalink to this definition"></a></dt>
<dd><p>Routine tasks for event handlers (e.g. default preventions).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>event</strong> (<em>Event|KeyboardEvent</em>) &#8211; The events to be inhibited.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">event</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">Event</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="onDragEnter">
<code class="descname">onDragEnter</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#onDragEnter" title="Permalink to this definition"></a></dt>
<dd><p>Upon enter (when a file, e.g. an image, is dragged into the browser),
the defualt events are inhibited, and the drop event is set as <cite>copy</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>event</strong> (<em>DragEvent</em>) &#8211; Drag event.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Inhibited drag event with <cite>copy</cite> added to the drop event.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">Event</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="data">
<dt id="keyboardEvents">
<code class="descname">keyboardEvents</code><a class="headerlink" href="#keyboardEvents" title="Permalink to this definition"></a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">JSON Object:</th><td class="field-body">Keyboard events and their handlers.</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="TAB">
<code class="descname">TAB</code><a class="headerlink" href="#TAB" title="Permalink to this definition"></a></dt>
<dd><ul class="simple">
<li>(<em>string</em>) - represents: <code class="docutils literal"><span class="pre">Tab</span></code></li>
</ul>
</dd></dl>
<dl class="attribute">
<dt id="DUPLICATE">
<code class="descname">DUPLICATE</code><a class="headerlink" href="#DUPLICATE" title="Permalink to this definition"></a></dt>
<dd><ul class="simple">
<li>(<em>string</em>) - represents: <code class="docutils literal"><span class="pre">d</span></code></li>
</ul>
</dd></dl>
<dl class="attribute">
<dt id="UNINDENT">
<code class="descname">UNINDENT</code><a class="headerlink" href="#UNINDENT" title="Permalink to this definition"></a></dt>
<dd><ul class="simple">
<li>(<em>string</em>) - represents: <code class="docutils literal"><span class="pre">[</span></code></li>
</ul>
</dd></dl>
<dl class="attribute">
<dt id="INDENT">
<code class="descname">INDENT</code><a class="headerlink" href="#INDENT" title="Permalink to this definition"></a></dt>
<dd><ul class="simple">
<li>(<em>string</em>) - represents: <code class="docutils literal"><span class="pre">]</span></code></li>
</ul>
</dd></dl>
<dl class="function">
<dt id="hub">
<code class="descname">hub</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#hub" title="Permalink to this definition"></a></dt>
<dd><p>Mapping of hotkeys from keyboard events to their corresponding functions.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>event</strong> (<em>KeyboardEvent</em>) &#8211; Keyboard event to be handled.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">Function | Boolean</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="data">
<dt id="Handlers">
<code class="descname">Handlers</code><a class="headerlink" href="#Handlers" title="Permalink to this definition"></a></dt>
<dd><p>Handler functions, as mapped by <a class="reference internal" href="#hub" title="hub"><code class="xref js js-func docutils literal"><span class="pre">hub()</span></code></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">JSON Object:</th><td class="field-body">Hotkey response functions.</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Properties receive a single argument <code class="docutils literal"><span class="pre">properties</span></code>, which is an instance of <a class="reference internal" href="#properties" title="properties"><code class="xref js js-data docutils literal"><span class="pre">properties</span></code></a>. See the
<code class="docutils literal"><span class="pre">markdownx</span></code> class for additional details.</p>
</div>
<dl class="function">
<dt id="applyTab">
<code class="descname">applyTab</code><span class="sig-paren">(</span><em>properties</em><span class="sig-paren">)</span><a class="headerlink" href="#applyTab" title="Permalink to this definition"></a></dt>
<dd><p>Smart application of tab indentations under various conditions.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>properties</strong> (<em>JSON</em>) &#8211; See object descriptions for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="removeTab">
<code class="descname">removeTab</code><span class="sig-paren">(</span><em>properties</em><span class="sig-paren">)</span><a class="headerlink" href="#removeTab" title="Permalink to this definition"></a></dt>
<dd><p>Smart removal of tab indentations.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>properties</strong> (<em>JSON</em>) &#8211; See object descriptions for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="_multiLineIndentation">
<code class="descname">_multiLineIndentation</code><span class="sig-paren">(</span><em>properties</em><span class="sig-paren">)</span><a class="headerlink" href="#_multiLineIndentation" title="Permalink to this definition"></a></dt>
<dd><p><strong>private</strong></p>
<p>Handles multi line indentations.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>properties</strong> (<em>JSON</em>) &#8211; See object descriptions for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="applyIndentation">
<code class="descname">applyIndentation</code><span class="sig-paren">(</span><em>properties</em><span class="sig-paren">)</span><a class="headerlink" href="#applyIndentation" title="Permalink to this definition"></a></dt>
<dd><p>Smart application of indentation at the beginning of the line.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>properties</strong> (<em>JSON</em>) &#8211; See object descriptions for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="removeIndentation">
<code class="descname">removeIndentation</code><span class="sig-paren">(</span><em>properties</em><span class="sig-paren">)</span><a class="headerlink" href="#removeIndentation" title="Permalink to this definition"></a></dt>
<dd><p>Smart removal of indentation from the beginning of the line.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>properties</strong> (<em>JSON</em>) &#8211; See object descriptions for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="applyDuplication">
<code class="descname">applyDuplication</code><span class="sig-paren">(</span><em>properties</em><span class="sig-paren">)</span><a class="headerlink" href="#applyDuplication" title="Permalink to this definition"></a></dt>
<dd><p>Duplication of the current or selected lines.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>properties</strong> (<em>JSON</em>) &#8211; See object descriptions for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="getHeight">
<code class="descname">getHeight</code><span class="sig-paren">(</span><em>element</em><span class="sig-paren">)</span><a class="headerlink" href="#getHeight" title="Permalink to this definition"></a></dt>
<dd><p>Returns either the height of an element as defined in the <code class="docutils literal"><span class="pre">style</span></code> attribute or CSS or its browser-computed height.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>HTMLElement</strong> (<em>element</em>) &#8211; The element whose height is to be determined.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Height of the element.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">number</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="updateHeight">
<code class="descname">updateHeight</code><span class="sig-paren">(</span><em>element</em><span class="sig-paren">)</span><a class="headerlink" href="#updateHeight" title="Permalink to this definition"></a></dt>
<dd><p>Updates the height of an element based on its scroll height.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>editor</strong> (<em>HTMLTextAreaElement</em>) &#8211; Editor element whose height is to be updated.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">HTMLTextAreaElement</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="MarkdownX">
<em class="property">class </em><code class="descname">MarkdownX</code><span class="sig-paren">(</span><em>editor</em>, <em>preview</em><span class="sig-paren">)</span><a class="headerlink" href="#MarkdownX" title="Permalink to this definition"></a></dt>
<dd><p>MarkdownX initializer.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"><div class="first highlight-javascript"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="kd">let</span> <span class="nx">parent</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByClassName</span><span class="p">(</span><span class="s1">&#39;markdownx&#39;</span><span class="p">),</span>
<span class="p">...</span> <span class="nx">editor</span> <span class="o">=</span> <span class="nx">parent</span><span class="p">.</span><span class="nx">querySelector</span><span class="p">(</span><span class="s1">&#39;.MyMarkdownEditor&#39;</span><span class="p">),</span>
<span class="p">...</span> <span class="nx">preview</span> <span class="o">=</span> <span class="nx">parent</span><span class="p">.</span><span class="nx">querySelector</span><span class="p">(</span><span class="s1">&#39;.MyMarkdownPreview&#39;</span><span class="p">);</span>
<span class="o">&gt;&gt;&gt;</span> <span class="kd">let</span> <span class="nx">mdx</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">MarkdownX</span><span class="p">(</span><span class="nx">parent</span><span class="p">,</span> <span class="nx">editor</span><span class="p">,</span> <span class="nx">preview</span><span class="p">)</span>
</pre></div>
</div>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>parent</strong> (<em>HTMLElement</em>) &#8211; Markdown editor element.</li>
<li><strong>editor</strong> (<em>HTMLTextAreaElement</em>) &#8211; Markdown editor element.</li>
<li><strong>preview</strong> (<em>HTMLElement</em>) &#8211; Markdown preview element.</li>
</ul>
@ -200,6 +512,17 @@
</tr>
</tbody>
</table>
<dl class="data">
<dt id="properties">
<code class="descname">properties</code><a class="headerlink" href="#properties" title="Permalink to this definition"></a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">JSON Object:</th><td class="field-body">Class variables.</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="editor">
<code class="descname">editor</code><a class="headerlink" href="#editor" title="Permalink to this definition"></a></dt>
@ -217,9 +540,18 @@
</dd></dl>
<dl class="attribute">
<dt id="timeout">
<code class="descname">timeout</code><a class="headerlink" href="#timeout" title="Permalink to this definition"></a></dt>
<dt id="parent">
<code class="descname">parent</code><a class="headerlink" href="#parent" title="Permalink to this definition"></a></dt>
<dd><ul class="simple">
<li>(<em>HMTLElement</em>) - Instance parent.</li>
</ul>
</dd></dl>
<dl class="attribute">
<dt id="_latency">
<code class="descname">_latency</code><a class="headerlink" href="#_latency" title="Permalink to this definition"></a></dt>
<dd><p><strong>private</strong></p>
<ul class="simple">
<li>(<em>number</em> | <em>null</em>) - Private property; timeout settings.</li>
</ul>
</dd></dl>
@ -227,21 +559,26 @@
<dl class="attribute">
<dt id="_editorIsResizable">
<code class="descname">_editorIsResizable</code><a class="headerlink" href="#_editorIsResizable" title="Permalink to this definition"></a></dt>
<dd><ul class="simple">
<dd><p><strong>private</strong></p>
<ul class="simple">
<li>(<em>Boolean</em>) - Private property; <code class="docutils literal"><span class="pre">true</span></code> if instance editor is resizable, otherwise <code class="docutils literal"><span class="pre">false</span></code>.</li>
</ul>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="_markdownify">
<code class="descname">_markdownify</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#_markdownify" title="Permalink to this definition"></a></dt>
<dd><p>Private settings for <code class="docutils literal"><span class="pre">timeout</span></code>.</p>
<dd><p><strong>private</strong></p>
<p>Settings for <code class="docutils literal"><span class="pre">timeout</span></code>.</p>
</dd></dl>
<dl class="function">
<dt id="_routineEventResponse">
<code class="descname">_routineEventResponse</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#_routineEventResponse" title="Permalink to this definition"></a></dt>
<dd><p>Private routine tasks for event handlers (e.g. default preventions).</p>
<dd><p><strong>private</strong></p>
<p>Routine tasks for event handlers (e.g. default preventions).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@ -295,8 +632,8 @@
</dd></dl>
<dl class="function">
<dt id="onDragEnter">
<code class="descname">onDragEnter</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#onDragEnter" title="Permalink to this definition"></a></dt>
<dt>
<code class="descname">onDragEnter</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span></dt>
<dd><p>Event handler for <span class="guilabel">dragEnter</span> events.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
@ -370,20 +707,43 @@
<dl class="function">
<dt id="sendFile">
<code class="descname">sendFile</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sendFile" title="Permalink to this definition"></a></dt>
<dd><p>pass</p>
<code class="descname">sendFile</code><span class="sig-paren">(</span><em>file</em><span class="sig-paren">)</span><a class="headerlink" href="#sendFile" title="Permalink to this definition"></a></dt>
<dd><p>Uploading the <code class="docutils literal"><span class="pre">file</span></code> onto the server through an AJAX request.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>file</strong> (<em>File</em>) &#8211; File to be uploaded.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="getMarkdown">
<code class="descname">getMarkdown</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getMarkdown" title="Permalink to this definition"></a></dt>
<dd><p>pass</p>
<dd><p>Uploading the markdown text from <code class="xref py py-attr docutils literal"><span class="pre">properties.editor</span></code> onto the server through an AJAX request, and upon
receiving the HTML encoded text in response, the response will be displayed in <code class="xref py py-attr docutils literal"><span class="pre">properties.preview</span></code>.</p>
</dd></dl>
<dl class="function">
<dt id="insertImage">
<code class="descname">insertImage</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#insertImage" title="Permalink to this definition"></a></dt>
<dd><p>pass</p>
<code class="descname">insertImage</code><span class="sig-paren">(</span><em>textToInsert</em><span class="sig-paren">)</span><a class="headerlink" href="#insertImage" title="Permalink to this definition"></a></dt>
<dd><p>Inserts markdown encoded image URL into <code class="xref py py-attr docutils literal"><span class="pre">properties.editor</span></code> where the cursor is located.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>textToInsert</strong> (<em>string</em>) &#8211; Markdown text (with path to the image) to be inserted into the editor.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
@ -434,7 +794,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Utilities &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Utilities &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../../index.html"/>
<link rel="up" title="JavaScript Code" href="../docs.html"/>
<link rel="next" title="Events" href="../events.html"/>
<link rel="prev" title="MarkdownX" href="markdownx.html"/>
@ -197,9 +197,116 @@ not exist.</p>
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>name</strong> (<em>string</em>) &#8211; The name of the cookie.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Value of the cookie with the key <code class="docutils literal"><span class="pre">name</span></code> or <code class="docutils literal"><span class="pre">null</span></code>.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string | null</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="zip">
<code class="descname">zip</code><span class="sig-paren">(</span><em>...rows</em><span class="sig-paren">)</span><a class="headerlink" href="#zip" title="Permalink to this definition"></a></dt>
<dd><p>JavaScript implementation of Python&#8217;s <code class="docutils literal"><span class="pre">zip</span></code> function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>rows</strong> &#8211; Array or arrays to zipped together.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array of zipped items.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">Array[]</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"><div class="first last highlight-javascript"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="kd">let</span> <span class="nx">zipped</span> <span class="o">=</span> <span class="nx">zip</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;H&#39;</span><span class="p">],</span> <span class="p">[</span><span class="mi">5</span><span class="p">,</span> <span class="s1">&#39;i&#39;</span><span class="p">]);</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nx">zipped</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">row</span> <span class="o">=&gt;</span> <span class="nx">row</span><span class="p">.</span><span class="nx">reduce</span><span class="p">((</span><span class="nx">m</span><span class="p">,</span> <span class="nx">n</span><span class="p">)</span> <span class="o">=&gt;</span> <span class="nx">m</span> <span class="o">+</span> <span class="nx">n</span><span class="p">))</span>
<span class="c1">// [6, &quot;Hi&quot;]</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="mountEvents">
<code class="descname">mountEvents</code><span class="sig-paren">(</span><em>...collections</em><span class="sig-paren">)</span><a class="headerlink" href="#mountEvents" title="Permalink to this definition"></a></dt>
<dd><p>Mounts a set of events defined in an object onto the document.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>collections</strong> &#8211; Must be JSON object and follow the structure outlined in the example.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Listeners</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">Event</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"><div class="first last highlight-javascript"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="kd">let</span> <span class="nx">editorListeners</span> <span class="o">=</span> <span class="p">{</span>
<span class="p">...</span> <span class="nx">object</span><span class="o">:</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;my-editor&#39;</span><span class="p">),</span>
<span class="p">...</span> <span class="nx">listeners</span><span class="o">:</span> <span class="p">[</span>
<span class="p">...</span> <span class="p">{</span> <span class="nx">type</span><span class="o">:</span> <span class="s2">&quot;input&quot;</span><span class="p">,</span> <span class="nx">capture</span><span class="o">:</span> <span class="kc">true</span> <span class="p">,</span> <span class="nx">listener</span><span class="o">:</span> <span class="nx">inputChanged</span> <span class="p">},</span>
<span class="p">...</span> <span class="p">{</span> <span class="nx">type</span><span class="o">:</span> <span class="s2">&quot;compositionstart&quot;</span><span class="p">,</span> <span class="nx">capture</span><span class="o">:</span> <span class="kc">true</span> <span class="p">,</span> <span class="nx">listener</span><span class="o">:</span> <span class="nx">onKeyDown</span> <span class="p">}</span>
<span class="p">...</span> <span class="p">]</span>
<span class="p">...</span> <span class="p">};</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="triggerEvent">
<code class="descname">triggerEvent</code><span class="sig-paren">(</span><em>element</em>, <em>type</em><span class="sig-paren">)</span><a class="headerlink" href="#triggerEvent" title="Permalink to this definition"></a></dt>
<dd><p>Triggers an existing HTML event manually.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>name</strong> (<em>string</em>) &#8211; The name of the cookie.
:returns: Value of the cookie with the key <code class="docutils literal"><span class="pre">name</span></code> or <code class="docutils literal"><span class="pre">null</span></code>.</li>
<li><strong>element</strong> (<em>Element</em>) &#8211; Element whose event is to be created and triggered.</li>
<li><strong>type</strong> (<em>string</em>) &#8211; Type of the event to be triggered.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="triggerCustomEvent">
<code class="descname">triggerCustomEvent</code><span class="sig-paren">(</span><em>type</em>, <em>element</em>, <em>args</em><span class="sig-paren">)</span><a class="headerlink" href="#triggerCustomEvent" title="Permalink to this definition"></a></dt>
<dd><p>Triggers an already defined custom event manually.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>element</strong> (<em>Element|Document</em>) &#8211; Element whose event is to be triggered.</li>
<li><strong>type</strong> (<em>string</em>) &#8211; Type of the event to be triggered.</li>
<li><strong>args</strong> &#8211; Values to be passed as custom argument to <code class="docutils literal"><span class="pre">event.details</span></code>. (Default = <code class="docutils literal"><span class="pre">null</span></code>)</li>
</ul>
</td>
</tr>
@ -234,6 +341,241 @@ Default is <code class="docutils literal"><span class="pre">true</span></code>.<
</table>
</dd></dl>
<dl class="function">
<dt id="AJAXRequest">
<code class="descname">AJAXRequest</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#AJAXRequest" title="Permalink to this definition"></a></dt>
<dd><p>Determines the supported AJAX requests API in IE6+ browsers.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">XMLHttpRequest</td>
</tr>
<tr class="field-even field"><th class="field-name">Throws:</th><td class="field-body"><strong>TypeError</strong> &#8211; AJAX request is not supported.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="Request">
<em class="property">class </em><code class="descname">Request</code><span class="sig-paren">(</span><em>url</em>, <em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#Request" title="Permalink to this definition"></a></dt>
<dd><p>An XMLHttpRequest wrapper object to initialize AJAX POST requests.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"><div class="first last highlight-javascript"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="kd">let</span> <span class="nx">value</span> <span class="o">=</span> <span class="s2">&quot;This is a test value&quot;</span><span class="p">,</span>
<span class="nx">postUrl</span> <span class="o">=</span> <span class="s2">&quot;https://example.com/&quot;</span><span class="p">;</span>
<span class="o">&gt;&gt;&gt;</span> <span class="kr">const</span> <span class="nx">xhr</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">utils</span><span class="p">.</span><span class="nx">Request</span><span class="p">(</span>
<span class="p">...</span> <span class="nx">postUrl</span><span class="p">,</span> <span class="c1">// URL</span>
<span class="p">...</span> <span class="nx">preparePostData</span><span class="p">({</span><span class="nx">content</span><span class="o">:</span> <span class="nx">value</span><span class="p">})</span> <span class="c1">// Data</span>
<span class="p">...</span> <span class="p">);</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nx">xhr</span><span class="p">.</span><span class="nx">success</span> <span class="o">=</span> <span class="nx">response</span> <span class="o">=&gt;</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">response</span><span class="p">);</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nx">xhr</span><span class="p">.</span><span class="nx">error</span> <span class="o">=</span> <span class="nx">response</span> <span class="o">=&gt;</span> <span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="nx">response</span><span class="p">);</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nx">xhr</span><span class="p">.</span><span class="nx">progress</span> <span class="o">=</span> <span class="nx">event</span> <span class="o">=&gt;</span> <span class="p">{</span>
<span class="p">...</span>
<span class="p">...</span> <span class="k">if</span> <span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">lengthComputable</span><span class="p">)</span>
<span class="p">...</span> <span class="nx">console</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="sb">`</span><span class="si">${</span><span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">loaded</span> <span class="o">/</span> <span class="nx">event</span><span class="p">.</span><span class="nx">total</span><span class="p">)</span> <span class="o">*</span> <span class="mi">100</span><span class="si">}</span><span class="sb">% uploaded.`</span><span class="p">)</span>
<span class="p">...</span>
<span class="p">...</span> <span class="p">};</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nx">xhr</span><span class="p">.</span><span class="nx">send</span><span class="p">();</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="url">
<code class="descname">url</code><a class="headerlink" href="#url" title="Permalink to this definition"></a></dt>
<dd><ul class="simple">
<li>(<em>string</em>) - URL to which the data is to be posted.</li>
</ul>
</dd></dl>
<dl class="attribute">
<dt id="data">
<code class="descname">data</code><a class="headerlink" href="#data" title="Permalink to this definition"></a></dt>
<dd><ul class="simple">
<li>(<em>FormData</em>) - Data, as an instance of <cite>FromData</cite>, to be posted.</li>
</ul>
</dd></dl>
<dl class="attribute">
<dt id="xhr">
<code class="descname">xhr</code><a class="headerlink" href="#xhr" title="Permalink to this definition"></a></dt>
<dd><p><strong>private</strong></p>
<ul class="simple">
<li>(<em>any</em>) - Value obtained automatically by calling <code class="xref js js-func docutils literal"><span class="pre">AjaxRequest()</span></code>.</li>
</ul>
</dd></dl>
<dl class="function">
<dt id="constructor">
<code class="descname">constructor</code><span class="sig-paren">(</span><em>url</em>, <em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#constructor" title="Permalink to this definition"></a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>url</strong> (<em>string</em>) &#8211; URL to which the data is to be posted.</li>
<li><strong>data</strong> (<em>FormData</em>) &#8211; Data, as an instance of <cite>FromData</cite>, to be posted.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="progress">
<code class="descname">progress</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="headerlink" href="#progress" title="Permalink to this definition"></a></dt>
<dd><p>Progress callback.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>event</strong> (<em>Event</em>) &#8211; The entire event (see the example for additional information on usage).</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="success">
<code class="descname">success</code><span class="sig-paren">(</span><em>response</em><span class="sig-paren">)</span><a class="headerlink" href="#success" title="Permalink to this definition"></a></dt>
<dd><p>Success callback.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>response</strong> (<em>any</em>) &#8211; Success values; first available one of <code class="docutils literal"><span class="pre">responseText</span></code>, <code class="docutils literal"><span class="pre">responseXML</span></code>, or <code class="docutils literal"><span class="pre">response</span></code>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="error">
<code class="descname">error</code><span class="sig-paren">(</span><em>response</em><span class="sig-paren">)</span><a class="headerlink" href="#error" title="Permalink to this definition"></a></dt>
<dd><p>Error callback.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>response</strong> (<em>any</em>) &#8211; Error value: <code class="docutils literal"><span class="pre">responseText</span></code>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="send">
<code class="descname">send</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#send" title="Permalink to this definition"></a></dt>
<dd><p>Starts the transfer.</p>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="addClass">
<code class="descname">addClass</code><span class="sig-paren">(</span><em>element</em>, <em>...classNames</em><span class="sig-paren">)</span><a class="headerlink" href="#addClass" title="Permalink to this definition"></a></dt>
<dd><p>Given an instance of an element, adds classes to it.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>element</strong> (<em>Element</em>) &#8211; Instance of an element.</li>
<li><strong>classNames</strong> (<em>string[]</em>) &#8211; Can be a single string, or multiple strings.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"><div class="first last highlight-javascript"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="nx">addClass</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;my-element&#39;</span><span class="p">),</span> <span class="s1">&#39;className&#39;</span><span class="p">);</span>
<span class="c1">// or</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nx">addClass</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;my-element&#39;</span><span class="p">),</span> <span class="s1">&#39;classA&#39;</span><span class="p">,</span> <span class="s1">&#39;classB&#39;</span><span class="p">,</span> <span class="s1">&#39;classC&#39;</span><span class="p">);</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="hasClass">
<code class="descname">hasClass</code><span class="sig-paren">(</span><em>element</em>, <em>className</em><span class="sig-paren">)</span><a class="headerlink" href="#hasClass" title="Permalink to this definition"></a></dt>
<dd><p>Given an instance of an element, confirms whether or not the element has the class.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>element</strong> (<em>Element</em>) &#8211; Instance of an element.</li>
<li><strong>className</strong> (<em>string[]</em>) &#8211; Can be a single string, or multiple strings.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><code class="docutils literal"><span class="pre">true</span></code> if the element has the class, otherwise <code class="docutils literal"><span class="pre">false</span></code>.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">boolean</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"><div class="first last highlight-javascript"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="nx">hasClass</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;my-element&#39;</span><span class="p">),</span> <span class="s1">&#39;className&#39;</span><span class="p">)</span>
<span class="c1">// returns True if the element with id &quot;my-element&quot; has the class &quot;className&quot;, otherwise False.</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="removeClass">
<code class="descname">removeClass</code><span class="sig-paren">(</span><em>element</em>, <em>...classNames</em><span class="sig-paren">)</span><a class="headerlink" href="#removeClass" title="Permalink to this definition"></a></dt>
<dd><p>Given an instance of an element, removes classes to it.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>element</strong> (<em>Element</em>) &#8211; Instance of an element.</li>
<li><strong>classNames</strong> (<em>string[]</em>) &#8211; Can be a single string, or multiple strings.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"><div class="first last highlight-javascript"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="nx">removeClass</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;my-element&#39;</span><span class="p">),</span> <span class="s1">&#39;className&#39;</span><span class="p">);</span>
<span class="c1">// or</span>
<span class="o">&gt;&gt;&gt;</span> <span class="nx">removeClass</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;my-element&#39;</span><span class="p">),</span> <span class="s1">&#39;classA&#39;</span><span class="p">,</span> <span class="s1">&#39;classB&#39;</span><span class="p">,</span> <span class="s1">&#39;classC&#39;</span><span class="p">);</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
@ -280,7 +622,7 @@ Default is <code class="docutils literal"><span class="pre">true</span></code>.<
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Events &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Events &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../index.html"/>
<link rel="up" title="JavaScript" href="js.html"/>
<link rel="next" title="MarkdownX Modules" href="../markdownx/markdownx.html"/>
<link rel="prev" title="Utilities" href="docs/utils.html"/>
@ -321,7 +321,7 @@ JavaScript, you may take advantage of event listeners as exemplified below.</p>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript &mdash; Django Markdownx 2.0.19 documentation</title>
<title>JavaScript &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../index.html"/>
<link rel="next" title="JavaScript Code" href="docs.html"/>
<link rel="prev" title="Translation" href="../translation.html"/>
@ -237,7 +237,7 @@ specifically IE 10+. See additional detailed on <a class="reference external" hr
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>License &mdash; Django Markdownx 2.0.19 documentation</title>
<title>License &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
<link rel="prev" title="Contributions" href="contribution.html"/>
@ -229,7 +229,7 @@ software, even if advised of the possibility of such damage.</p>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Admin &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../../index.html"/>
<link rel="up" title="MarkdownX Modules" href="../markdownx.html"/>
<link rel="next" title="Exceptions" href="exceptions.html"/>
<link rel="prev" title="MarkdownX Modules" href="../markdownx.html"/>
@ -184,7 +184,7 @@
<span id="admin"></span><h1>Admin<a class="headerlink" href="#module-markdownx.admin" title="Permalink to this headline"></a></h1>
<dl class="class">
<dt id="markdownx.admin.MarkdownxModelAdmin">
<em class="property">class </em><code class="descclassname">markdownx.admin.</code><code class="descname">MarkdownxModelAdmin</code><span class="sig-paren">(</span><em>model</em>, <em>admin_site</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/admin.html#MarkdownxModelAdmin"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.admin.MarkdownxModelAdmin" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="descclassname">markdownx.admin.</code><code class="descname">MarkdownxModelAdmin</code><span class="sig-paren">(</span><em>model</em>, <em>admin_site</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.admin.MarkdownxModelAdmin" title="Permalink to this definition"></a></dt>
<dd><p>Django admin representation for <code class="docutils literal"><span class="pre">MarkdownxField</span></code> in models.</p>
<p>See <strong>Django Admin</strong> in <a class="reference internal" href="../../example.html"><span class="doc">Example</span></a> for additional information.</p>
</dd></dl>
@ -235,7 +235,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exceptions &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Exceptions &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../../index.html"/>
<link rel="up" title="MarkdownX Modules" href="../markdownx.html"/>
<link rel="next" title="Fields" href="fields.html"/>
<link rel="prev" title="Admin" href="admins.html"/>
@ -184,11 +184,11 @@
<span id="exceptions"></span><h1>Exceptions<a class="headerlink" href="#module-markdownx.exceptions" title="Permalink to this headline"></a></h1>
<dl class="exception">
<dt id="markdownx.exceptions.MarkdownxImageUploadError">
<em class="property">exception </em><code class="descclassname">markdownx.exceptions.</code><code class="descname">MarkdownxImageUploadError</code><span class="sig-paren">(</span><em>message</em>, <em>code=None</em>, <em>params=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/exceptions.html#MarkdownxImageUploadError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.exceptions.MarkdownxImageUploadError" title="Permalink to this definition"></a></dt>
<em class="property">exception </em><code class="descclassname">markdownx.exceptions.</code><code class="descname">MarkdownxImageUploadError</code><span class="sig-paren">(</span><em>message</em>, <em>code=None</em>, <em>params=None</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.exceptions.MarkdownxImageUploadError" title="Permalink to this definition"></a></dt>
<dd><p>Custom <strong>MarkdownX</strong> exceptions.</p>
<dl class="staticmethod">
<dt id="markdownx.exceptions.MarkdownxImageUploadError.invalid_size">
<em class="property">static </em><code class="descname">invalid_size</code><span class="sig-paren">(</span><em>current</em>, <em>expected</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/exceptions.html#MarkdownxImageUploadError.invalid_size"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.exceptions.MarkdownxImageUploadError.invalid_size" title="Permalink to this definition"></a></dt>
<em class="property">static </em><code class="descname">invalid_size</code><span class="sig-paren">(</span><em>current</em>, <em>expected</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.exceptions.MarkdownxImageUploadError.invalid_size" title="Permalink to this definition"></a></dt>
<dd><p>The file is larger in size that the maximum allow in <span class="guilabel">settings.py</span> (or the default).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
@ -216,7 +216,7 @@
<dl class="staticmethod">
<dt id="markdownx.exceptions.MarkdownxImageUploadError.not_uploaded">
<em class="property">static </em><code class="descname">not_uploaded</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/exceptions.html#MarkdownxImageUploadError.not_uploaded"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.exceptions.MarkdownxImageUploadError.not_uploaded" title="Permalink to this definition"></a></dt>
<em class="property">static </em><code class="descname">not_uploaded</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.exceptions.MarkdownxImageUploadError.not_uploaded" title="Permalink to this definition"></a></dt>
<dd><p>No file is available to upload.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
@ -235,7 +235,7 @@
<dl class="staticmethod">
<dt id="markdownx.exceptions.MarkdownxImageUploadError.unsupported_format">
<em class="property">static </em><code class="descname">unsupported_format</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/exceptions.html#MarkdownxImageUploadError.unsupported_format"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.exceptions.MarkdownxImageUploadError.unsupported_format" title="Permalink to this definition"></a></dt>
<em class="property">static </em><code class="descname">unsupported_format</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.exceptions.MarkdownxImageUploadError.unsupported_format" title="Permalink to this definition"></a></dt>
<dd><p>The file is of a format not defined in <span class="guilabel">settings.py</span>
or if default, in <span class="guilabel">markdownx/settings.py</span>.</p>
<table class="docutils field-list" frame="void" rules="none">
@ -301,7 +301,7 @@ or if default, in <span class="guilabel">markdownx/settings.py</span>.</p>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fields &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Fields &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../../index.html"/>
<link rel="up" title="MarkdownX Modules" href="../markdownx.html"/>
<link rel="next" title="Form" href="forms.html"/>
<link rel="prev" title="Exceptions" href="exceptions.html"/>
@ -184,7 +184,7 @@
<span id="fields"></span><h1>Fields<a class="headerlink" href="#module-markdownx.fields" title="Permalink to this headline"></a></h1>
<dl class="class">
<dt id="markdownx.fields.MarkdownxFormField">
<em class="property">class </em><code class="descclassname">markdownx.fields.</code><code class="descname">MarkdownxFormField</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/fields.html#MarkdownxFormField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.fields.MarkdownxFormField" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="descclassname">markdownx.fields.</code><code class="descname">MarkdownxFormField</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.fields.MarkdownxFormField" title="Permalink to this definition"></a></dt>
<dd><p>Used in FormFields as a Markdown enabled replacement for <code class="docutils literal"><span class="pre">CharField</span></code>.</p>
</dd></dl>
@ -234,7 +234,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Form &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../../index.html"/>
<link rel="up" title="MarkdownX Modules" href="../markdownx.html"/>
<link rel="next" title="Models" href="models.html"/>
<link rel="prev" title="Fields" href="fields.html"/>
@ -184,11 +184,11 @@
<span id="form"></span><h1>Form<a class="headerlink" href="#module-markdownx.forms" title="Permalink to this headline"></a></h1>
<dl class="class">
<dt id="markdownx.forms.ImageForm">
<em class="property">class </em><code class="descclassname">markdownx.forms.</code><code class="descname">ImageForm</code><span class="sig-paren">(</span><em>data=None</em>, <em>files=None</em>, <em>auto_id='id_%s'</em>, <em>prefix=None</em>, <em>initial=None</em>, <em>error_class=&lt;class 'django.forms.utils.ErrorList'&gt;</em>, <em>label_suffix=None</em>, <em>empty_permitted=False</em>, <em>field_order=None</em>, <em>use_required_attribute=None</em>, <em>renderer=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/forms.html#ImageForm"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.forms.ImageForm" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="descclassname">markdownx.forms.</code><code class="descname">ImageForm</code><span class="sig-paren">(</span><em>data=None</em>, <em>files=None</em>, <em>auto_id='id_%s'</em>, <em>prefix=None</em>, <em>initial=None</em>, <em>error_class=&lt;class 'django.forms.utils.ErrorList'&gt;</em>, <em>label_suffix=None</em>, <em>empty_permitted=False</em>, <em>field_order=None</em>, <em>use_required_attribute=None</em>, <em>renderer=None</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.forms.ImageForm" title="Permalink to this definition"></a></dt>
<dd><p>Used for the handling of images uploaded using the editor through <span class="guilabel">AJAX</span>.</p>
<dl class="method">
<dt id="markdownx.forms.ImageForm.clean">
<code class="descname">clean</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/forms.html#ImageForm.clean"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.forms.ImageForm.clean" title="Permalink to this definition"></a></dt>
<code class="descname">clean</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.forms.ImageForm.clean" title="Permalink to this definition"></a></dt>
<dd><p>Checks the upload against allowed extensions and maximum size.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
@ -202,7 +202,7 @@
<dl class="staticmethod">
<dt id="markdownx.forms.ImageForm.get_unique_file_name">
<em class="property">static </em><code class="descname">get_unique_file_name</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/forms.html#ImageForm.get_unique_file_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.forms.ImageForm.get_unique_file_name" title="Permalink to this definition"></a></dt>
<em class="property">static </em><code class="descname">get_unique_file_name</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.forms.ImageForm.get_unique_file_name" title="Permalink to this definition"></a></dt>
<dd><p>Generates a universally unique ID using Python <code class="docutils literal"><span class="pre">UUID</span></code> and attaches the
extension of file name to it.</p>
<table class="docutils field-list" frame="void" rules="none">
@ -222,7 +222,7 @@ from <code class="docutils literal"><span class="pre">file_name</span></code>.</
<dl class="method">
<dt id="markdownx.forms.ImageForm.save">
<code class="descname">save</code><span class="sig-paren">(</span><em>commit=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/forms.html#ImageForm.save"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.forms.ImageForm.save" title="Permalink to this definition"></a></dt>
<code class="descname">save</code><span class="sig-paren">(</span><em>commit=True</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.forms.ImageForm.save" title="Permalink to this definition"></a></dt>
<dd><p>Saves the uploaded image in the designated location.</p>
<p>If image type is not SVG, a byteIO of image content_type is created and
subsequently save; otherwise, the SVG is saved in its existing <code class="docutils literal"><span class="pre">charset</span></code>
@ -292,7 +292,7 @@ else <code class="docutils literal"><span class="pre">namedtuple(path,</span> <s
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Models &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Models &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../../index.html"/>
<link rel="up" title="MarkdownX Modules" href="../markdownx.html"/>
<link rel="next" title="URLs" href="urls.html"/>
<link rel="prev" title="Form" href="forms.html"/>
@ -184,7 +184,7 @@
<span id="models"></span><h1>Models<a class="headerlink" href="#module-markdownx.models" title="Permalink to this headline"></a></h1>
<dl class="class">
<dt id="markdownx.models.MarkdownxField">
<em class="property">class </em><code class="descclassname">markdownx.models.</code><code class="descname">MarkdownxField</code><span class="sig-paren">(</span><em>verbose_name=None</em>, <em>name=None</em>, <em>primary_key=False</em>, <em>max_length=None</em>, <em>unique=False</em>, <em>blank=False</em>, <em>null=False</em>, <em>db_index=False</em>, <em>rel=None</em>, <em>default=&lt;class 'django.db.models.fields.NOT_PROVIDED'&gt;</em>, <em>editable=True</em>, <em>serialize=True</em>, <em>unique_for_date=None</em>, <em>unique_for_month=None</em>, <em>unique_for_year=None</em>, <em>choices=None</em>, <em>help_text=''</em>, <em>db_column=None</em>, <em>db_tablespace=None</em>, <em>auto_created=False</em>, <em>validators=()</em>, <em>error_messages=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/models.html#MarkdownxField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.models.MarkdownxField" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="descclassname">markdownx.models.</code><code class="descname">MarkdownxField</code><span class="sig-paren">(</span><em>verbose_name=None</em>, <em>name=None</em>, <em>primary_key=False</em>, <em>max_length=None</em>, <em>unique=False</em>, <em>blank=False</em>, <em>null=False</em>, <em>db_index=False</em>, <em>rel=None</em>, <em>default=&lt;class 'django.db.models.fields.NOT_PROVIDED'&gt;</em>, <em>editable=True</em>, <em>serialize=True</em>, <em>unique_for_date=None</em>, <em>unique_for_month=None</em>, <em>unique_for_year=None</em>, <em>choices=None</em>, <em>help_text=''</em>, <em>db_column=None</em>, <em>db_tablespace=None</em>, <em>auto_created=False</em>, <em>validators=()</em>, <em>error_messages=None</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.models.MarkdownxField" title="Permalink to this definition"></a></dt>
<dd><p>Custom Django field for Markdown text.</p>
<p>Parameters are identical to those of the ordinary Django <strong>TextField</strong> parameters for the model
fields. For consistency therefore, the descriptions have been borrowed from Django&#8217;s official
@ -221,7 +221,7 @@ information.</li>
</table>
<dl class="method">
<dt id="markdownx.models.MarkdownxField.formfield">
<code class="descname">formfield</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/models.html#MarkdownxField.formfield"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.models.MarkdownxField.formfield" title="Permalink to this definition"></a></dt>
<code class="descname">formfield</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.models.MarkdownxField.formfield" title="Permalink to this definition"></a></dt>
<dd><p>Customising the <code class="docutils literal"><span class="pre">form_class</span></code>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
@ -283,7 +283,7 @@ information.</li>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Utilities &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Utilities &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../../index.html"/>
<link rel="up" title="MarkdownX Modules" href="../markdownx.html"/>
<link rel="next" title="Views" href="views.html"/>
<link rel="prev" title="URLs" href="urls.html"/>
@ -184,7 +184,7 @@
<span id="utilities"></span><h1>Utilities<a class="headerlink" href="#module-markdownx.utils" title="Permalink to this headline"></a></h1>
<dl class="function">
<dt id="markdownx.utils.markdownify">
<code class="descclassname">markdownx.utils.</code><code class="descname">markdownify</code><span class="sig-paren">(</span><em>content</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/utils.html#markdownify"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.utils.markdownify" title="Permalink to this definition"></a></dt>
<code class="descclassname">markdownx.utils.</code><code class="descname">markdownify</code><span class="sig-paren">(</span><em>content</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.utils.markdownify" title="Permalink to this definition"></a></dt>
<dd><p>Trans-compiles Markdown text to HTML.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
@ -202,7 +202,7 @@
<dl class="function">
<dt id="markdownx.utils.scale_and_crop">
<code class="descclassname">markdownx.utils.</code><code class="descname">scale_and_crop</code><span class="sig-paren">(</span><em>image</em>, <em>size</em>, <em>crop=False</em>, <em>upscale=False</em>, <em>quality=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/utils.html#scale_and_crop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.utils.scale_and_crop" title="Permalink to this definition"></a></dt>
<code class="descclassname">markdownx.utils.</code><code class="descname">scale_and_crop</code><span class="sig-paren">(</span><em>image</em>, <em>size</em>, <em>crop=False</em>, <em>upscale=False</em>, <em>quality=None</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.utils.scale_and_crop" title="Permalink to this definition"></a></dt>
<dd><p>Modifies raster graphic images to the specifications.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
@ -229,7 +229,7 @@
<dl class="function">
<dt id="markdownx.utils.xml_has_javascript">
<code class="descclassname">markdownx.utils.</code><code class="descname">xml_has_javascript</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/utils.html#xml_has_javascript"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.utils.xml_has_javascript" title="Permalink to this definition"></a></dt>
<code class="descclassname">markdownx.utils.</code><code class="descname">xml_has_javascript</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.utils.xml_has_javascript" title="Permalink to this definition"></a></dt>
<dd><p>Checks XML for JavaScript. See &#8220;security&#8221; in <a class="reference internal" href="../../customization.html"><span class="doc">customization</span></a> for
additional information.</p>
<table class="docutils field-list" frame="void" rules="none">
@ -292,7 +292,7 @@ additional information.</p>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Views &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Views &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../../index.html"/>
<link rel="up" title="MarkdownX Modules" href="../markdownx.html"/>
<link rel="next" title="Contributions" href="../../contribution.html"/>
<link rel="prev" title="Utilities" href="utilities.html"/>
@ -184,7 +184,7 @@
<span id="views"></span><h1>Views<a class="headerlink" href="#module-markdownx.views" title="Permalink to this headline"></a></h1>
<dl class="class">
<dt id="markdownx.views.ImageUploadView">
<em class="property">class </em><code class="descclassname">markdownx.views.</code><code class="descname">ImageUploadView</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/views.html#ImageUploadView"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.views.ImageUploadView" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="descclassname">markdownx.views.</code><code class="descname">ImageUploadView</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.views.ImageUploadView" title="Permalink to this definition"></a></dt>
<dd><p>Handling requests for uploading images.</p>
<dl class="attribute">
<dt id="markdownx.views.ImageUploadView.form_class">
@ -194,7 +194,7 @@
<dl class="method">
<dt id="markdownx.views.ImageUploadView.form_invalid">
<code class="descname">form_invalid</code><span class="sig-paren">(</span><em>form</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/views.html#ImageUploadView.form_invalid"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.views.ImageUploadView.form_invalid" title="Permalink to this definition"></a></dt>
<code class="descname">form_invalid</code><span class="sig-paren">(</span><em>form</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.views.ImageUploadView.form_invalid" title="Permalink to this definition"></a></dt>
<dd><p>Handling of invalid form events.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
@ -213,7 +213,7 @@ and the default response for HTTP requests.</td>
<dl class="method">
<dt id="markdownx.views.ImageUploadView.form_valid">
<code class="descname">form_valid</code><span class="sig-paren">(</span><em>form</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/views.html#ImageUploadView.form_valid"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.views.ImageUploadView.form_valid" title="Permalink to this definition"></a></dt>
<code class="descname">form_valid</code><span class="sig-paren">(</span><em>form</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.views.ImageUploadView.form_valid" title="Permalink to this definition"></a></dt>
<dd><p>If the form is valid, the contents are saved.</p>
<p>If the <strong>POST</strong> request is AJAX (image uploads), a JSON response will be
produced containing the Markdown encoded image insertion tag with the URL
@ -241,11 +241,11 @@ response for HTTP requests.</td>
<dl class="class">
<dt id="markdownx.views.MarkdownifyView">
<em class="property">class </em><code class="descclassname">markdownx.views.</code><code class="descname">MarkdownifyView</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/views.html#MarkdownifyView"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.views.MarkdownifyView" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="descclassname">markdownx.views.</code><code class="descname">MarkdownifyView</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.views.MarkdownifyView" title="Permalink to this definition"></a></dt>
<dd><p>Conversion of Markdown to HTML.</p>
<dl class="method">
<dt id="markdownx.views.MarkdownifyView.post">
<code class="descname">post</code><span class="sig-paren">(</span><em>request</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/markdownx/views.html#MarkdownifyView.post"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#markdownx.views.MarkdownifyView.post" title="Permalink to this definition"></a></dt>
<code class="descname">post</code><span class="sig-paren">(</span><em>request</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#markdownx.views.MarkdownifyView.post" title="Permalink to this definition"></a></dt>
<dd><p>Handling of the conversion from Markdown to HTML using the conversion
function in settings under <code class="docutils literal"><span class="pre">MARKDOWNX_MARKDOWNIFY_FUNCTION</span></code>.</p>
<table class="docutils field-list" frame="void" rules="none">
@ -317,7 +317,7 @@ function in settings under <code class="docutils literal"><span class="pre">MARK
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MarkdownX Modules &mdash; Django Markdownx 2.0.19 documentation</title>
<title>MarkdownX Modules &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="../index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="../index.html"/>
<link rel="next" title="Admin" href="docs/admins.html"/>
<link rel="prev" title="Events" href="../js/events.html"/>
@ -232,7 +232,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

Binary file not shown.

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Python Module Index &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Python Module Index &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
@ -255,7 +255,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Search &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="#"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
<script src="_static/js/modernizr.min.js"></script>
@ -204,7 +204,7 @@
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Translation &mdash; Django Markdownx 2.0.19 documentation</title>
<title>Translation &mdash; Django Markdownx 2.0.21 documentation</title>
@ -35,7 +35,7 @@
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Django Markdownx 2.0.19 documentation" href="index.html"/>
<link rel="top" title="Django Markdownx 2.0.21 documentation" href="index.html"/>
<link rel="next" title="JavaScript" href="js/js.html"/>
<link rel="prev" title="Customization" href="customization.html"/>
@ -245,7 +245,7 @@ produced by <strong>MarkdownX</strong> to various languages.</p>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.19',
VERSION:'2.0.21',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,