Пример #1
0
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 ''
Пример #2
0
 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)
Пример #3
0
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 ""
Пример #4
0
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 ""
Пример #5
0
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
Пример #6
0
 def subhead_line(part):
     char, text = part
     if char == '@':
         return tag('p', text, 'subhead')
     else:
         return alert(content)
Пример #7
0
 def note_line(part):
     char, text = part
     if char == '"':
         return tag('p', text, 'note')
     else:
         return alert(content)