Pass string and booleans to render callbacks.
This commit is contained in:
parent
cc8edf95ab
commit
1e1ff0e6aa
|
@ -305,16 +305,16 @@ class BaseRenderer:
|
|||
# flags: LIST_ORDERED, LI_BLOCK.
|
||||
def _w_list(self, ob, content, flags, data):
|
||||
content = to_string(content)
|
||||
flags = int(flags)
|
||||
result = self.list(content, flags)
|
||||
is_ordered = int(flags) & LIST_ORDERED != 0
|
||||
result = self.list(content, is_ordered)
|
||||
if result:
|
||||
lib.hoedown_buffer_puts(ob, result.encode('utf-8'))
|
||||
|
||||
# flags: LIST_ORDERED, LI_BLOCK.
|
||||
def _w_listitem(self, ob, content, flags, data):
|
||||
content = to_string(content)
|
||||
flags = int(flags)
|
||||
result = self.listitem(content, flags)
|
||||
is_ordered = int(flags) & LIST_ORDERED != 0
|
||||
result = self.listitem(content, is_ordered)
|
||||
if result:
|
||||
lib.hoedown_buffer_puts(ob, result.encode('utf-8'))
|
||||
|
||||
|
@ -353,7 +353,19 @@ class BaseRenderer:
|
|||
def _w_table_cell(self, ob, content, flags, data):
|
||||
content = to_string(content)
|
||||
flags = int(flags)
|
||||
result = self.table_cell(content, flags)
|
||||
is_header = flags & TABLE_HEADER != 0
|
||||
align_bit = flags & TABLE_ALIGNMASK
|
||||
|
||||
if align_bit == TABLE_ALIGN_CENTER:
|
||||
align = 'center'
|
||||
elif align_bit == TABLE_ALIGN_LEFT:
|
||||
align = 'left'
|
||||
elif align_bit == TABLE_ALIGN_RIGHT:
|
||||
align = 'right'
|
||||
else:
|
||||
align = ''
|
||||
|
||||
result = self.table_cell(content, align, is_header)
|
||||
if result:
|
||||
lib.hoedown_buffer_puts(ob, result.encode('utf-8'))
|
||||
|
||||
|
|
|
@ -207,16 +207,16 @@ class TestRenderer(m.BaseRenderer):
|
|||
def hrule(self):
|
||||
return '[HRULE]'
|
||||
|
||||
def list(self, content, flags):
|
||||
if flags & m.LIST_ORDERED:
|
||||
def list(self, content, ordered):
|
||||
if ordered:
|
||||
ordered = 'true'
|
||||
else:
|
||||
ordered = 'false'
|
||||
|
||||
return '[LIST ordered={1}]\n{0}'.format(content, ordered)
|
||||
|
||||
def listitem(self, content, flags):
|
||||
if flags & m.LIST_ORDERED:
|
||||
def listitem(self, content, is_ordered):
|
||||
if is_ordered:
|
||||
ordered = 'true'
|
||||
else:
|
||||
ordered = 'false'
|
||||
|
@ -238,19 +238,11 @@ class TestRenderer(m.BaseRenderer):
|
|||
def table_row(self, content):
|
||||
return '[TABLE_ROW]\n{0}\n'.format(content)
|
||||
|
||||
def table_cell(self, text, flags):
|
||||
align_bit = flags & m.TABLE_ALIGNMASK
|
||||
def table_cell(self, text, align, is_header):
|
||||
if align:
|
||||
align = 'align={} '.format(align)
|
||||
|
||||
if align_bit == m.TABLE_ALIGN_CENTER:
|
||||
align = 'align=center '
|
||||
elif align_bit == m.TABLE_ALIGN_LEFT:
|
||||
align = 'align=left '
|
||||
elif align_bit == m.TABLE_ALIGN_RIGHT:
|
||||
align = 'align=right '
|
||||
else:
|
||||
align = ''
|
||||
|
||||
if flags & m.TABLE_HEADER:
|
||||
if is_header:
|
||||
header = 'header=true '
|
||||
else:
|
||||
header = ''
|
||||
|
|
Loading…
Reference in New Issue