python-creole

Stellt hier eure Projekte vor.
Internetseiten, Skripte, und alles andere bzgl. Python.
Antworten
Benutzeravatar
jens
Python-Forum Veteran
Beiträge: 8502
Registriert: Dienstag 10. August 2004, 09:40
Wohnort: duisburg
Kontaktdaten:

2008 wollte ich einen Markupconverter programmieren: http://www.python-forum.de/viewtopic.php?f=3&t=16742

Raus gekommen ist dann python-creole

Nun hab ich gerade v1.3.0 veröffentlicht: http://pypi.python.org/pypi/python-creole/

Bild Bild Bild


Hab festgestellt, das es anscheinen keinen richtig Thread dafür gibt :lol:

python-creole ist mehr als "creole zu html" Konverter... Weil es auch rückwärts geht ;)

Somit kann man alle Markups nach creole konvertieren, in dem man den Zwischenschritt über html geht...

Beispiele:

Code: Alles auswählen

>>> from creole import creole2html
>>> creole2html("This is **creole //markup//**")
u'<p>This is <strong>creole <i>markup</i></strong></p>\n'
und zurück:

Code: Alles auswählen

>>> from creole import html2creole
>>> html2creole(u'<p>This is <strong>creole <i>markup</i></strong></p>\n')
u'This is **creole //markup//**'
Dann gibt es noch helfer für ReStructuredText:

Code: Alles auswählen

>>> from creole.rest2html.clean_writer import rest2html
>>> rest2html(u"A ReSt link to `PyLucid CMS <http://www.pylucid.org>`_ :)")
u'<p>A ReSt link to <a href="http://www.pylucid.org">PyLucid CMS</a> :)</p>\\n'

>>> from creole import html2rest
>>> html2rest(u'<p>This is <strong>ReStructuredText</strong> <em>markup</em>!</p>')
u'This is **ReStructuredText** *markup*!'
und ein nicht richtig fertiger html2textile:

Code: Alles auswählen

>>> from creole import html2textile
>>> html2textile(u'<p>This is <strong>textile <i>markup</i></strong>!</p>')
u'This is *textile __markup__*!'
Das ganze hat auch eine CLI und macro Unterstützung...

Mehr Informationen:

https://github.com/jedie/python-creole/

GitHub | Open HUB | Xing | Linked in
Bitcoins to: 1JEgSQepxGjdprNedC9tXQWLpS424AL8cd
Antworten