# Textile: a Vellum plugin # Implements a subset of Dean Allen's Textile web text generator import vellum.hooks import sys,re html = [] false = 0; true = not false # block level rHeader = re.compile(r'\s*h(?P[1-6]).\s+') rBlockquote = re.compile(r'\s*bq.\s+') rUL = re.compile(r'\s*\*\s+') rOL = re.compile(r'\s*#\s+') # inline rEM = re.compile(r'\b_([^ \t\n\r\f\v_]+)_\b') rStrong = re.compile(r'\*([^ \t\n\r\f\v*]+)\*') rCite = re.compile(r'\?\?([^ \t\n\r\f\v?]+)\?\?') # pure HTML rJustHTML = re.compile('^(<[^>]+>)+$') def parseText(entry,form): if not form.has_key("textile"): return txt = entry.body ls = txt.splitlines() # inFoo flags inOL = false; inUL = false html = [] for l in ls: # Inline ll = rEM.sub(r'1円',l) ll = rStrong.sub(r'1円',ll) ll = rCite.sub(r'1円',ll) # Block modifiers isHead = rHeader.match(ll) isBlockquote = rBlockquote.match(ll) isUL = rUL.match(ll) isOL = rOL.match(ll) isJustHTML = rJustHTML.match(ll) # Check for list terminations if inUL and not isUL: html.append('') inUL = false if inOL and not isOL: html.append('') inOL = false if isHead: h = isHead.group("h") html.append('%s' % (h,ll[len(isHead.group(0)):],h)) elif isBlockquote: html.append('
%s
' % (ll[len(isBlockquote.group(0)):])) elif isUL: if not inUL: html.append('') inUL = false if inOL: html.append('') inOL = false entry.body = '\n'.join(html) vellum.hooks.register_hook("entry-new-save",parseText) def printDetails(): print '''

Textile

Block modifiers

Header: hn.

Blockquote: bq.

Numeric list: #

Bulleted list: *

Enable Textile parsing?

''' vellum.hooks.register_hook("entry-new-print",printDetails)

AltStyle によって変換されたページ (->オリジナル) /