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


Release history Release notifications

History Node

1.3.4

History Node

1.3.3

History Node

1.3.2

History Node

1.3.1

History Node

1.3

History Node

1.2

History Node

1.1

History Node

1.0

History Node

0.9.10

History Node

0.9.9

History Node

0.9.8

History Node

0.9.7

History Node

0.9.6

History Node

0.9.5

History Node

0.9.4

History Node

0.9.3

History Node

0.9.2

History Node

0.9.1

History Node

0.9

History Node

0.8

History Node

0.7

History Node

0.6

History Node

0.5

This version
History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.1

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page