Introduction

Installation

Limitations of the "file" protocol

Frequently asked questions

Syntax, keywords and built-in functions

Standard distribution

import implementation

Brython packages

Browser interface

Introduction - DOM API
Creating a document
Accessing elements
Attributes, properties and methods

Events
Mouse events
Keyboard events
Focus events
Drag events

Query string

Interactions with Javascript

Brython-specific built-in modules

browser
browser.aio
browser.ajax
browser.html
browser.local_storage
browser.markdown
browser.object_storage
browser.session_storage
browser.svg
browser.template
browser.timer
browser.webcomponent
browser.websocket
browser.worker

Widgets
browser.widgets.dialog
browser.widgets.menu

interpreter
javascript

Working with Brython

Execution options
Testing and debugging
Deploying an application

Cookbook

Hello world !
Insert content in an element
HTML markup (bold,italic...)
HTML table
Bind and unbind events
Handle options in a SELECT
Drag and drop
Get the content of an element
Read the content of a file
Store objects locally
Example of onmouseover
 

module browser.markdown

markdown is a mode of text formatting adapted to publication on Internet, more simple to edit than HTML.

A complete description is available on the markdown site. The module markdown is a slightly adapted version to enrich the rendering options:

  • the markdown tags _text_ and *text* match two different HTML tags: <I> and <EM>
  • __text__ and **text** match <B> and <STRONG>
  • underscores inside a word are left unchanged

Lines that start with ``` followed by a text (eg. ```python) are translated to a <PRE> element with the text as class name (<PRE class="python">)

The module exposes a single function :

mark(src)
src is a string holding text formatted with the markdown syntax. The function returns a 2-element tuple : html, scripts where html is the HTML code generated from the source, and scripts is a list of all the source code of scripts found in the page.

The example below shows how to get the content of a markdown file at address url, fill a zone in the document with the matching HTML code, and run all the scripts in the page. This technique is used in these documentation pages.

from browser import document, markdown

mk, scripts = markdown.mark(open(url).read())
document['zone'].html = mk
for script in scripts:
    exec(script, globals())
</blockquote>