March 10, 2007 will

BBCode Python Module

In the last few weeks I have been tinkering with a dynamic website created with Turbogears, but that's not what this blog entry is about. The website I have in mind is similar to a forum in that most of the content come from the users (can't tell you exactly what it is just yet). I wanted a way for users to post comments with simple formatting, but I didn't want to let them enter straight html - for all the problems that would cause. No doubt, some wise-guy would figure out that he could enter the <blink> tag! So I decided to implement something like BBCode, which I dubbed 'Post Markup'.

But once I came close to finishing Post Markup, I realised it was so much like BBCode, it was BBCode (which doesn't seem to have any strict definition anyway). My BBCode parser is deliberately quite relaxed, it will try to make sense of the BBCode rather than throwing errors. It will close open tags as well as handle overlapping tags so that it always produces valid XHTML snippets.

You can download postmarkup.py here. This code is 'politeware', you may use it for any purpose you want as long as you say 'thank you' and you promise not to sue me if it breaks! Let me know if you have any suggestions or bug-fixes.

Here's a quick example of basic use.

import postmarkup

markup = postmarkup.PostMarkup().default_tags()
bbcode = "[b]Hello, World![/b]"

print markup.render_to_html(bbcode)

There are comments in the module. If you have any questions, please email or (better) post a comment here so I can build up documentation.

The following is a cut and paste of the test output. It shows the basic tags (bold, italic etc) and more advanced tags.


[b]Hello[/b]
Hello
[s]Strike through[/s]
Strike through
[b]bold [i]bold and italic[/b] italic[/i]
bold bold and italic italic
[google]Will McGugan[/google]
Will McGugan [Google]
[wiki Will McGugan]Look up my name in Wikipedia[/wiki]
Look up my name in Wikipedia [Wikipedia]
[link http://www.willmcgugan.com]My homepage[/link]
My homepage [willmcgugan.com]
[link]http://www.willmcgugan.com[/link]
http://www.willmcgugan.com [willmcgugan.com]
[quote Will said...]BBCode is very cool[/quote]
Will said...

BBCode is very cool

[b]Long test[/b]

New lines characters are converted to breaks. Tags my be [b]ove[i]rl[/b]apped[/i].

[i]Open tags will be closed.
Long test

New lines characters are converted to breaks. Tags my be overlapped.

Open tags will be closed.
Use Markdown for formatting
*Italic* **Bold** `inline code` Links to [Google](http://www.google.com) > This is a quote > ```python import this ```
your comment will be previewed here
gravatar
Jan Pöschko

This is great! Thank you a lot!

gravatar
krys.ca

BBCode Python Module...

Will McGugan recently wrote about the BBCode python module he created.  This could useful for my (yet to be released) blog software ....

gravatar
BatCreat

Thank you! Your Module will be very useful for me.

gravatar
ugo pozo

Thank you a lot. This will save me a great amount of time!

gravatar
Mika

Thanks a lot! I love it!

gravatar
Werner Hartnagel

Thank you, your BBCode Parser works pretty fine.
There's a newer package around at: http://code.google.com/p/postmarkup/

gravatar
g4b

thanx a lot...! i can use this very well in my next django app...

everything i now need is the same for wiki syntax and i will rock the world! :D

gravatar
Luke

If the purpose of expanding BBCode into full HTML is to save effort, typing and learning then my favoured format for links is:

[http://www.somelink.com/|anchor text]

to expand into

anchor text

which is the method used on e2 http://everything2.com/

I am working on my own "html shorthand to longhand converter" and your approach has been helpful... thanks.

gravatar
Luke

ermm last post didnt work but you should get the idea

gravatar
django

Thanks (as required by the politeware license you stated), I'll be using this quite extensively :)

gravatar
BlackDropOS
A Thousand Thanks (and shall flowers blossom in your garden) !
Politeware… mmmh… neat licence for a neat work !
gravatar
nux
Thanxs a lot ! i think it will be very usefull for me !
good work !
gravatar
Markus Ullmann
Thanks much :) Will use it for our new clan page. Wondering if I should start contributing a C version of it for more speeeeeeeed :D
gravatar
tezro
Thanks, very useful. But is there any package for transforming html back to bbcode?
gravatar
Ahlywog
Thanks for this. I started writing my own and was starting to get a little frustrated when a friend pointed me to this site.

gravatar
Atkin
This will save me a lot of time :)
gravatar
resma k

Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles Python online Training

gravatar
mahesh manish

Informative blog. Thank you for sharing with us.. Data Science Online Training Python Online Training

gravatar
IORI

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work.cat grooming miami

gravatar
IORI

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work.ku casino

gravatar
IORI

Fantastic Site with useful and unique content looking forward to the next update thank you.Yorkie For Sale USA

gravatar
lella keerthi

Nice post .. thanks for sharing nice information.. https://www.kitsonlinetrainings.com/course/salesforce-online-training http://www.kitsonlinetrainings.com/course/devops-online-training

gravatar
IORI

Fantastic Site with useful and unique content looking forward to the next update thank you.cambodia online casino

gravatar
IORI

Fantastic Site with useful and unique content looking forward to the next update thank you.sa gaming

gravatar
IORI

Fantastic Site with useful and unique content looking forward to the next update thank you.savage grow plus reviews

gravatar
IORI

Fantastic Site with useful and unique content looking forward to the next update thank you.t? l? cá cu?c bóng dá

gravatar
IORI

Fantastic Site with useful and unique content looking forward to the next update thank you.เว็บ พนัน ออนไลน์

gravatar
IORI

Fantastic Site with useful and unique content looking forward to the next update thank you.Sbobet Asia

gravatar
IORI

Our website is a one stop shop where you can buy all types of Psychedelics like , MUSHROOMS , MDMA , DMT and others at very affordable prices with discrete and overnight shipping available . We sell high quality and lab tested psychedelic products for very affordable prices . We are 100% legit and efficient. Packaging is 100% discreet and we hold a 100% delivery success record.Buy Psychedelic Online

gravatar
Hamza Khan

Thanks for suggestion of this site! nid de frelon

gravatar
Hamza Khan

Best site! éradication nid de frelons

gravatar
Anzalna

I stumbled across your blog and wanted to say thatLG party speaker

gravatar
Anzalna

It’s super webpage, I was looking for something like thisThe Weeknd x Vlone Bat Country T-shirt White

gravatar
Donardo Jack

Miracle apoteck is an online pharmacy that specilizes in private medicine supplies and give information on various medications. We also give counselling and first aid advice as far as certain pharma products are concerned. Most especially, we sell various pharmaceutical products and medications to buyers all over the globe.

Buy Percocet 10 mg in the USA Køb Oxycodone 30 mg i Danmark Köp Modafinil 200 mg i Sverige Kjøp Oxynorm 20 mg i Norge Kjøp Stilnoct 12.5 mg i Norge Köp Oxynorm 20 mg i Sverige Köp Sobril 25mg i Sverige Köp Oxynorm 20 mg i Sverige Köpa Ritalin 30mg i Sverige Köp Stilnoct 12.5 mg i Sverige

gravatar
Anzalna

It’s super webpage, I was looking for something like thiswaec expo

gravatar
Anzalna

That’s a great article The neatly organized content is good to see. Can I quote a blog and write it on my blog.jewelry and loan

gravatar
Anzalna

I think this is an useful site check it out and click here:2021 waec dubs https://gurustab.net/best-waec-expo/

gravatar
vlone brand

Vlone Brand is the official store for real Vlone fans, Get Amazing Vlone Hoodies, Shirts, and more all over the world. ✅ Big Discounts.

vlone brand vlone shirt

gravatar
Lil Peep Merchandise

amazing post i am very happy to post. thanks for sharing such a super article lil peep store

gravatar
travisscott merchshop

amazing post i am very happy to post. thanks for sharing such a super article Travis scott merch

gravatar
vlone stock

Vlone Merch best Product from the Official Vlone Stock website, Buy Hoodies, Shirts, Jackets Vlone with Fast Shipping around the world.✅ Big Discount.

vlone stock

gravatar
Tyler the creator merch

Tyler the Creator Merch Official website for crazy fans. Get Tyler the creator of Merchandise Hoodies, T-shirts, Sweatshirts. Tyler the creator merch

gravatar
Ted Fred

MEDICAL PHARMACY FOR RESEARCH CHEMICALS. OPIOIDS AND ADHD We all know that pharmaceutical market is extremely competitive, with innumerable online drugstores and pharmacies competing for leadership in this particular field of e-commerce. We believe that the advantages we possess over other players on the market will allow us to assert and maintain a strong competitive edge... for best online store click here https://jayhealthcare.com Tel; +1 661 927 6232 Wickr; teddy67874 fredted052@gmail.com where to buy JWH-018 online Buy Adderall Xr Online where to buy CBD Isolate Powder online purchase 5F-MDMB-2201online best quality 4F-ADB online 4F-BCA for sale online order 5CL-ADB-A online Kamagra/Viagra100mg – 200 Pills where to buy anadrol 50mg near me anavar for weight loss order primobolan depot online how much does sustanon 250 cost purchase TRENBOLONE ENANTHATE online Buy Opana (E40) 40mg Buy Vicodin (ES)7.5/750mg purchase Codeine online order Oxycontin (Oxycodone) 40mg online purchase Codeine online where to buy mdma online etizolam powder supplier where to buy Pure Powder Cocaine online where to buy Nembutal Powder online MDMA Crystal for sale online order LSD 100 MCG BLOTTERS online where to buy Ketamine Powder online purchase HEXEN CRYSTAL online where to buy 3 CMC online Fentanyl Powder for sale online order ANALOG 4 MMC HQ online Dilaudid (Hydromorphone) 4mg Soma for sale online Percocet for sale near me OXYCODONE for sale near me best quality HiTech Codeine Syrup online Buy Vyvanse Online Where to buy Adderall 20mg without presciption Price of Adderall 30mg

gravatar
Ted Fred

MEDICAL PHARMACY FOR RESEARCH CHEMICALS. OPIOIDS AND ADHD

We all know that pharmaceutical market is extremely competitive, with innumerable online drugstores and pharmacies competing for leadership in this particular field of e-commerce. We believe that the advantages we possess over other players on the market will allow us to assert and maintain a strong competitive edge... for best online store click here

where to order tramadol online

buy nembutal powder online

where to order nembutal pills online

cheap nembutal liquid for sale online

propionat 100 copy for sale in USA

buy oxa max online

buy bk 2c b online

where to buy ambien zolpidem online

percocet for sale in USA

buy methadone online UK

cheap adderall for sale online

where to buy green xanax online

restoril temazepam for sale

order sibutramine online

best quality oxycodone forr sale online

best quality oxycodone for sale online

lunesta for sale online

belsomra for sale

best vimax for sale

original levitra for sale

best online pharmacy to buy belsomra

order stayxn online

get cialis for man powere(sex)

methylone bk mdma for sale

buy jwh-018 online

butylone bk mbdb for sale online

mephedrone for sale

best online pharmacy to by ethylone big crystal

where to buy mdpv online

where to buy etizolam online in USA

Buy Mexedrone Powder Online

Buy AB-FUBINACA Online

Buy A-PVP Online

buy bath salt online

Buy AM-2201 Online

Buy Carfentanil Online

Buy U-47700 Online

Buy Soma Online

Buy Crystal Meth Online

Buy Alprazolam Powder Online

Buy Ritalin (Methylphenidate) 10 Mg Online

Buy Arimidex Online

Buy Ecstasy Online

Buy Nembutal Online

Buy Roxicodone Online

Buy Contrave Online

Buy Belviq 10mg Online

Buy Hydrocodone Online

Buy Norco 10mg Online

Buy Xanax 2mg Online

Buy Ketamine Online

Buy Valium (Diazepam) Online

Buy Orlistat 120mg Online

PROMIFEN (CLOMIPHENE CITRATE – CLOMID)

Buy QSYMIA Online

Buy LIV.52 Online

Buy Exemestane (Aromasin) online

Buy Letromina (Letrozole) Online

TRETIZEN 20 (ISOTRETINOIN – ACCUTANE) – ZENLABS

Buy Exemestane (Aromasin) online

Buy QSYMIA Online

Buy LIV.52 Online

DIMETHAZINE (PROHORMONE)

MODALERT 200

PRIMO TABS (METHENOLONE ACETATE – PRIMOBOLAN)

DANABOL DS 10 (METHANDIENONE ORAL – DIANABOL)

MODAFIN (MODAFINIL)

Buy Oxydrolone (Oxymetholone – Anadrol) online

MAX-DROL

Buy Provironum (Mesterolone) online

ANDRIOL TESTOCAPS

TURINABOL 10

purchase METAPRIME online uk

N-LONE-D 100 (NANDROLONE DECANOATE DECA)

MASTEBOLIN (DROSTANOLONE PROPIONATE – MASTERON)

TRENBOLIN (VIAL) (TRENBOLONE ENANTHATE) – ALPHA PHARMA

where to buy ALPHABOLIN online usa

where to buy REXOBOL-10 online

where to buy ALPHABOL online

order REXOBOL-10 online

where to buy MAX-ONE online

where to buy ALPHABOL online

order testobase-testosterone-suspension

TESTOVORIN DEPOT-250

PARABOLAN 100

TRITREN 150

PROPIONAT 100

SUSTANON 350

STANOPRIME (STANOZOLOL INJECTION – WINSTROL DEPOT) – EMINENCE LABS

order ENANTHAT 250 online

where to buy PROMINATE 100 online

purchase MASTERON 100 online

purchase DECA 300 online canada

PROPRIME (TESTOSTERONE PROPIONATE) – EMINENCE LABS

TRENOPRIME (TRENBOLONE ACETATE) – EMINENCE LABS

TREN-ACE-MAX VIAL (TRENBOLONE ACETATE) – MAXTREME

CYPIONAT 250

TESTOVIRON-250 (TESTOSTERONE ENANTHATE)

TRENBOLONE-75 (ACETATE)

CYPOPRIME (TESTOSTERONE CYPIONATE)

TESTOBOLIN (VIAL) (TESTOSTERONE ENANTHATE)

SUSTAVIRON-250 (SUSTANON TESTOSTERONE MIX)

REXOGIN (STANOZOLOL INJECTION – WINSTROL DEPOT)

TESTOCYP (TESTOSTERONE CYPIONATE) – ALPHA PHARMA

N-LONE-D 300 (NANDROLONE DECANOATE DECA) – MAXTREME

MAX-PRO (DROSTANOLONE PROPIONATE MASTERON) – MAXTREME

BOLD-ONE BOLDENONE UNDECYLENATE EQUIPOSE– MAXTREME

gravatar
Anzalna

That’s a great article. If you are interested click here. dark web sites

gravatar
hilary cory

Hurrah, that’s what I was looking for, what a information! present here at this web site, thanks admin of this site. Buy Concerta Methylphenidate 54mg Online Best ADHD Medications

gravatar
hilary cory

Hurrah, that’s what I was looking for, what a information! present here at this web site, thanks admin of this site. Buy Concerta Methylphenidate 54mg Online Best ADHD Medications

gravatar
animalbonesandtusks

As one of the most popular driving license providers on earth, we assure you nothing but the best quality driving license which you can use to drive on public roads freely without any fears. We give you the liberty to get the real driving license without going to schools and taking test. Is that not amazing? Order now. WhatsApp us +17193579832

<a href=https://www.legitsdocumentts.com/passport-for-sale/">passport for sale <a href=https://www.legitsdocumentts.com/german-drivers-license-for-sale-2/">german drivers license for sale <a href=https://www.legitsdocumentts.com/georgia-driving-license-for-sale/">georgia driving license for sale <a href=https://www.legitsdocumentts.com/french-drivers-license-for-sale/">french drivers license for sale <a href=https://www.legitsdocumentts.com/portugal-passport-for-sale/">portugal passport for sale <a href=https://www.legitsdocumentts.com/buy-fake-drivers-license-online/">buy fake drivers license online <a href=https://www.legitsdocumentts.com/passport-production-services-online/">passport production services online <a href=https://www.legitsdocumentts.com/buy-nclex-rn-usmle-license/">buy nclex rn usmle license <a href=https://www.legitsdocumentts.com/nclex-license-for-sale-online-now/">nclex license for sale online now <a href=https://www.legitsdocumentts.com/general-culinart-certificate-for-sale/">general culinart certificate for sale <a href=https://www.legitsdocumentts.com/celpip-certificate-for-sale/">celpip certificate for sale <a href=https://www.legitsdocumentts.com/drivers-license-for-sale/">drivers license for sale <a href=https://www.legitsdocumentts.com/identity-cards-for-sale-online/">identity cards for sale online <a href=https://www.legitsdocumentts.com/green-card-for-sale/">green card for sale <a href=https://www.legitsdocumentts.com/resident-permit-card-for-sale/">resident permit card for sale

gravatar
Agnes minler

Welcome to legit documents. Here you can buy all types of real and also novelty passports. We work effortlessly to ensure we provide the best for you. WhatsApp us on +17193579832 so we can discuss further or visit our website https://legitsdocumentts.com

<a href=https://www.legitsdocumentts.com/genuine-passport-for-sale-online/">genuine passport for sale online <a href=https://www.legitsdocumentts.com/portugal-passport-for-sale/">portugal passport for sale <a href=https://www.legitsdocumentts.com/fake-passports-for-sale-online/">fake passport for sale online <a href=https://www.legitsdocumentts.com/passport-production-services-online/">passport production service online <a href=https://www.legitsdocumentts.com/valid-passports-online/">valid passport online <a href=https://www.legitsdocumentts.com/real-passport-for-sale/">real passport for sale online <a href=https://www.legitsdocumentts.com/british-national-passport-for-sale/">British national passport for sale <a href=https://www.legitsdocumentts.com/buy-novelty-passports-online/">buy novelty passports online <a href=https://www.legitsdocumentts.com/passports-for-sale-online/">passport for sale online <a href=https://www.legitsdocumentts.com/buy-fake-passports-online/">Buy fake passports online <a href=https://www.legitsdocumentts.com/passport-services-online/">Passport services online <a href=https://www.legitsdocumentts.com/fake-passports-for-sale/">fake passport for sale <a href=https://www.legitsdocumentts.com/authentic-passports-for-sale/">Authentic passport for sale <a href=https://www.legitsdocumentts.com/get-real-passports-online/">Get real passports online <a href=https://www.legitsdocumentts.com/all-types-of-passports-for-sale/">All types of passports for sale <a href=https://www.legitsdocumentts.com/where-to-buy-passports/">Where to buy passport <a href=https://www.legitsdocumentts.com/buy-real-passports-online/">Buy real passport online <a href=https://www.legitsdocumentts.com/zimbabwean-passport-for-sale/">Zimbabwean passport for sale <a href=https://www.legitsdocumentts.com/ukrainian-passport-for-sale/">Ukraine passport for sale