Changeset 1769
- Timestamp:
- 09/16/08 13:31:56 (18 months ago)
- Location:
- trunk/pylucid_project
- Files:
-
- 6 modified
-
media/PyLucid/internal_page/page_admin/markup_help_creole.html (modified) (1 diff)
-
media/PyLucid/internal_page/page_admin/tag_list.html (modified) (1 diff)
-
PyLucid/models/Page.py (modified) (2 diffs)
-
PyLucid/system/markups/creole.py (modified) (7 diffs)
-
PyLucid/system/markups/creole2html.py (modified) (3 diffs)
-
tests/markup_creole.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid_project/media/PyLucid/internal_page/page_admin/markup_help_creole.html
r1766 r1769 37 37 be interpreted as text, so every html characters would be escaped. 38 38 </li> 39 <li><b>django tags/blocktags:</b><br /> 40 You can insert django tags and blocktags. No extra decoration is not needed. 41 </li> 39 42 </ul> 40 43 -
trunk/pylucid_project/media/PyLucid/internal_page/page_admin/tag_list.html
r1689 r1769 20 20 </li> 21 21 {% endfor %} 22 </ul> 23 24 <h2 class="noanchor">Additional django template tags:</h2> 25 <ul id="django_tags"> 26 <li> 27 <p> 28 Hightlight sourcecode via Pygments (if Pygments available): 29 {% sourcecode py %} 30 ... 31 {% endsourcecode %}<br /> 32 <strong>Note:</strong> Works only in html mode (without markup) correctly! 33 </p> 34 </li> 22 35 </ul> 23 36 -
trunk/pylucid_project/PyLucid/models/Page.py
r1750 r1769 30 30 31 31 MARKUPS = ( 32 (6, u'Creole wiki markup'), 32 33 (0, u'html'), 33 34 (1, u'html + TinyMCE'), … … 36 37 (4, u'Markdown'), 37 38 (5, u'ReStructuredText'), 38 (6, u'Creole wiki markup'),39 39 ) 40 40 -
trunk/pylucid_project/PyLucid/system/markups/creole.py
r1766 r1769 50 50 ]] 51 51 )''' 52 53 # link = r'''(?P<link1> 54 # \[\[ 55 # (?P<link_target1>.+?)\|(?P<link_text1>.+?) 56 # ]] 57 # )|(?P<link2> 58 # \[\[ 59 # (?P<link_target2> (%s)://[^ ]+) \s* (?P<link_text2>.+?) 60 # ]] 61 # )| 62 # \[\[(?P<internal_link>.+)\]\] 63 # ''' % proto 52 64 53 65 #-------------------------------------------------------------------------- … … 113 125 114 126 # Pass-through all django template blocktags 115 passthrough = r'''^ \s*(?P<passthrough>127 passthrough_block = r'''^ \s*(?P<passthrough_block> 116 128 {%.*?%} 117 129 (.|\n)+? … … 119 131 ) \s*$ 120 132 ''' 133 passthrough_line = r'''(?P<passthrough_line> 134 ({%.*?%})| 135 ({{.*?}}) 136 )''' 121 137 #Pass-through html code lines 122 138 html = r'''(?P<html> … … 141 157 blockelements = ( 142 158 "head", "list", "pre", "code", "table", "separator", "macro", 143 "passthrough ", "html"159 "passthrough_block", "html" 144 160 ) 145 161 … … 161 177 block_re = re.compile( 162 178 '|'.join([ 163 Rules.passthrough, Rules.html, 179 Rules.passthrough_block, 180 Rules.html, 164 181 Rules.line, Rules.head, Rules.separator, Rules.pre, Rules.list, 165 182 Rules.table, Rules.text, … … 168 185 ) 169 186 # For inline elements: 170 inline_re = re.compile('|'.join([Rules.link, Rules.url, Rules.macro, 171 Rules.code, Rules.image, Rules.strong, Rules.emph, Rules.linebreak, 172 Rules.escape, Rules.char]), re.X | re.U) 187 inline_re = re.compile( 188 '|'.join([ 189 Rules.link, Rules.url, Rules.macro, 190 Rules.code, Rules.image, 191 Rules.passthrough_line, 192 Rules.strong, Rules.emph, Rules.linebreak, 193 Rules.escape, Rules.char 194 ]), 195 re.X | re.U 196 ) 173 197 174 198 def __init__(self, raw): … … 197 221 # same method needs several names, because of group names in regexps. 198 222 199 def _passthrough_ repl(self, groups):223 def _passthrough_block_repl(self, groups): 200 224 """ Pass-through all django template blocktags """ 201 225 self._upto_block() 202 DocNode("passthrough", self.root, groups["passthrough"]) 226 DocNode("passthrough_block", self.root, groups["passthrough_block"]) 227 self.text = None 228 229 def _passthrough_line_repl(self, groups): 230 """ Pass-through all django tags """ 231 DocNode("passthrough_line", self.cur, groups["passthrough_line"]) 203 232 self.text = None 204 233 -
trunk/pylucid_project/PyLucid/system/markups/creole2html.py
r1766 r1769 58 58 print node 59 59 60 60 from PyLucid.tools.utils import escape 61 61 class HtmlEmitter: 62 62 """ … … 82 82 83 83 def html_escape(self, text): 84 return text.replace('&', '&').replace('<', '<').replace('>', '>') 84 return escape(text) 85 #return text.replace('&', '&').replace('<', '<').replace('>', '>') 85 86 86 87 def attr_escape(self, text): … … 205 206 return u"<pre>\n%s\n</pre>\n" % self.html_escape(node.content) 206 207 207 def passthrough_ emit(self, node):208 def passthrough_block_emit(self, node): 208 209 """ Pass-through all django template blocktags and html code lines """ 209 210 return node.content + "\n" 210 html_emit = passthrough_emit 211 html_emit = passthrough_block_emit 212 213 def passthrough_line_emit(self, node): 214 """ Pass-through all django template tags """ 215 return node.content 211 216 212 217 def default_emit(self, node): -
trunk/pylucid_project/tests/markup_creole.py
r1766 r1769 84 84 #-------------------------------------------------------------------------- 85 85 86 def test_creole_basic 1(self):86 def test_creole_basic(self): 87 87 out_string = self._parse("a text line.") 88 88 self.assertEqual(out_string, "<p>a text line.</p>\n") 89 89 90 def test_creole_ basic2(self):90 def test_creole_linebreak(self): 91 91 self.assertCreole(r""" 92 92 Force\\linebreak … … 96 96 """) 97 97 98 def test_creole_basic3(self): 99 self.assertCreole(r""" 100 Here is [[a internal]] link. 101 This is [[http://domain.tld|external links]]. 102 A [[internal links|different]] link name. 103 """, """ 104 <p>Here is <a href="a internal">a internal</a> link.<br /> 105 This is <a href="http://domain.tld">external links</a>.<br /> 106 A <a href="internal links">different</a> link name.</p> 107 """) 98 def test_bold_italics(self): 99 self.assertCreole(r""" 100 **//bold italics//** 101 //**bold italics**// 102 //This is **also** good.// 103 """, """ 104 <p><strong><i>bold italics</i></strong><br /> 105 <i><strong>bold italics</strong></i><br /> 106 <i>This is <strong>also</strong> good.</i></p> 107 """) 108 109 def test_internal_links(self): 110 self.assertCreole(r""" 111 A [[internal]] link... 112 ...and [[/a internal]] link. 113 """, """ 114 <p>A <a href="internal">internal</a> link...<br /> 115 ...and <a href="/a internal">/a internal</a> link.</p> 116 """) 117 118 def test_external_links(self): 119 self.assertCreole(r""" 120 With pipe separator: 121 1 [[internal links|link A]] test. 122 2 [[http://domain.tld|link B]] test. 123 """, """ 124 <p>With pipe separator:<br /> 125 1 <a href="internal links">link A</a> test.<br /> 126 2 <a href="http://domain.tld">link B</a> test.</p> 127 """) 128 129 def test_bolditalic_links(self): 130 self.assertCreole(r""" 131 //[[a internal]]// 132 **[[Shortcut2|a page2]]** 133 //**[[Shortcut3|a page3]]**// 134 """, """ 135 <p><i><a href="a internal">a internal</a></i><br /> 136 <strong><a href="Shortcut2">a page2</a></strong><br /> 137 <i><strong><a href="Shortcut3">a page3</a></strong></i></p> 138 """) 139 140 108 141 109 142 def test_django1(self): … … 170 203 if (x[i] > 0) { 171 204 x[i]--; 172 }}}205 }}} 173 206 </pre> 174 207 """) … … 217 250 <a href="Link">Link</a><br /> 218 251 [[Link]]</p> 219 """)220 221 def test_bold_italics(self):222 self.assertCreole(r"""223 **//bold italics//**224 //**bold italics**//225 //This is **also** good.//226 227 //[[a page|this is italic]]//228 **[[a page]]**229 //**[[a page]]**//230 """, """231 <p><strong><i>bold italics</i></strong><br />232 <i><strong>bold italics</strong></i><br />233 <i>This is <strong>also</strong> good.</i></p>234 235 <p><i><a href="a page">this is italic</a></i><br />236 <strong><a href="a page">a page</a></strong><br />237 <i><strong><a href="a page">a page</a></strong></i></p>238 252 """) 239 253