projects
/
zzz-pokedex.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make Pokemon.form an actual relation
[zzz-pokedex.git]
/
pokedex
/
db
/
markdown.py
diff --git
a/pokedex/db/markdown.py
b/pokedex/db/markdown.py
index
616830a
..
1ad304c
100644
(file)
--- a/
pokedex/db/markdown.py
+++ b/
pokedex/db/markdown.py
@@
-5,8
+5,9
@@
The language used is a variation of Markdown and Markdown Extra. There are
docs for each at http://daringfireball.net/projects/markdown/ and
http://michelf.com/projects/php-markdown/extra/ respectively.
docs for each at http://daringfireball.net/projects/markdown/ and
http://michelf.com/projects/php-markdown/extra/ respectively.
-Pokédex links are represented with the extended syntax `[name]{type}`, e.g.,
-`[Eevee]{pokemon}`. The actual code that parses these is in spline-pokedex.
+Pokédex links are represented with the syntax `[text]{type:identifier}`, e.g.,
+`[Eevee]{pokemon:eevee}`. The actual code that parses these is in
+spline-pokedex.
"""
from __future__ import absolute_import
"""
from __future__ import absolute_import
@@
-31,11
+32,17
@@
class MarkdownString(object):
def __unicode__(self):
return self.source_text
def __unicode__(self):
return self.source_text
+ def __str__(self):
+ return unicode(self.source_text).encode()
+
+ def __html__(self):
+ return self.as_html
+
@property
def as_html(self):
"""Returns the string as HTML4."""
@property
def as_html(self):
"""Returns the string as HTML4."""
- if self._as_html:
+ if self._as_html
is not None
:
return self._as_html
md = markdown.Markdown(
return self._as_html
md = markdown.Markdown(
@@
-106,6
+113,9
@@
class MarkdownColumn(sqlalchemy.types.TypeDecorator):
impl = sqlalchemy.types.Unicode
def process_bind_param(self, value, dialect):
impl = sqlalchemy.types.Unicode
def process_bind_param(self, value, dialect):
+ if value is None:
+ return None
+
if not isinstance(value, basestring):
# Can't assign, e.g., MarkdownString objects yet
raise NotImplementedError
if not isinstance(value, basestring):
# Can't assign, e.g., MarkdownString objects yet
raise NotImplementedError
@@
-113,4
+123,7
@@
class MarkdownColumn(sqlalchemy.types.TypeDecorator):
return unicode(value)
def process_result_value(self, value, dialect):
return unicode(value)
def process_result_value(self, value, dialect):
+ if value is None:
+ return None
+
return MarkdownString(value)
return MarkdownString(value)