Skip to main content

Simple structured text parser.

Project description

Par is a simple structured text parser, for new it supports google code wiki syntax(partial) and markdown syntax. And I also extend some new syntax for it.

Paring Markdown Programmly

Do like this:

from par.md import parseHtml

template = ‘’’<!doctype html> <html> <head> <title>%(title)s</title> </head> <body> %(body)s </body> </html>’’’

tag_class = {‘table’:’table’}

text = “”” # Test Markdown

This is a pragraph “””

print parseHtml(text, template, tag_class)

Markdown Syntax Expand

Table Support

do like this:

|| a || b || c || || c || d || e ||

will get this:

<table> <tr><td> a </td><td> b </td><td> c </td> </tr> <tr><td> b </td><td> c </td><td> d </td> </tr> </table>

Definition List support

do like this:

a –

abc

b –

cde

will get this:

<dl> <dt>a</dt> <dd><p>abc</p> </dd> <dt>b</dt> <dd><p>cde</p> </dd> </dl>

Other text decorators

Par.md also adds some new text decorators, such as:

^text^ <sup>text<sup> ,,text,, <sub>text<sub> ~~text~~ <span style=”text-decoration: line-through”>text</span> *text* <strong><em>text</em></strong> ___text___ <strong><em>text</em></strong>

Bootstrap Tab Pages

Support tab pages, the format is:

[[tabs(id=hello)]]:

` This is a test `

[[tabs(id=world)]]:
  • this is a list

  • test

Bootstrap Alert

[[alert(class=success)]]:

Success

[[alert(class=error)]]:

Error

[[alert(class=info)]]:

Info

[[alert]]:

Message

[[alert]]:

#### Alert Title This is alert message

[[alert(class=info,close)]]:

This is an alert. It’ll has a close button.

For bootstrap usage, you should invoke the code like this:

from par.md import parseHtml from par.bootstrap_ext import blocks

print parseHtml(text, template, block_callback=blocks)

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page