def align_block(content, settings): """ There is space around each set of alignment statements, but not between the individual lines. Ths means divs are wrapped in an outer paragraph tag. """ lines = split_to_array(content, Config.aligns) out = [] for char, line in lines: class_name = { '.': 'text-left', ';': 'text-center', ',': 'text-right', ':': 'indent', '~': 'indent-hanging', }.get(char, '') out += [tag('div', line, class_name)] if len(out) > 0: return "".join([ '<div class="wr-align-block space">', '<span>', ''.join(out), '</span>', '</div>', ]) else: return ''
def html(self, renderer, settings): "Just wrap in a paragraph tag (with inline formatting)." if is_placeholder(self.content): html = settings.replace(self.content) else: html = tag('p', settings.replace(self.content)) return (html, settings)
def quote_block(content, settings): """ Config.quotes: > blockquote plus: = caption """ lines = split_to_array(content, prefixes=Config.quotes + Config.caption) out = [] for char, content in lines: if char == '>': out += [tag('blockquote', content)] elif char == Config.caption: out += [tag('p', content, 'caption')] if len(out) > 0: return "\n".join(out) else: return ""
def caption_block(content, settings): """ = Caption """ lines = split_to_array(content, prefixes=Config.caption) out = [] for char, content in lines: if char == Config.caption: out += [tag('p', content, 'caption')] if len(out) > 0: return "\n".join(out) else: return ""
def column_block(text, settings): """ Simple columns (maximum of 4): ] Column 1 ] Column 2 # Or 12-column grids? @todo # # ] 3 ] Col 1. # ] 9 ] Column Number Two. """ char = text[0] parts = split_to_array(text, prefixes=char) html = '' parts = parts[:4] # <-- max. 4 parts twelfths = round(12 / len(parts)) bootstrap_class = 'col-md-%d' % twelfths for char, content in parts: html += tag('p', content, 'float-left %s' % bootstrap_class) html += "<div style=\"clear: both\"></div>" return html
def subhead_line(part): char, text = part if char == '@': return tag('p', text, 'subhead') else: return alert(content)
def note_line(part): char, text = part if char == '"': return tag('p', text, 'note') else: return alert(content)