fix bold re. adding suport for slide alignment

This commit is contained in:
q
2016-06-19 22:01:57 +03:00
parent 7a63b46cab
commit 7fdaf6a23a
2 changed files with 14 additions and 7 deletions

View File

@@ -302,12 +302,19 @@ def page_print(reader,opts,offset):
scrsize=opts.size scrsize=opts.size
# clear page # clear page
bc.clear() bc.clear()
if False: # Placeholder for 80x25 center alignment
align_x_offset=scrsize[1]/2-40
align_pad=" "*align_x_offset
align_y_offset=scrsize[0]/2-12
bc.down_line(align_y_offset)
else:
align_pad=""
# Print header # Print header
if opts.dark_colors: if opts.dark_colors:
coloring="${b}${U}" coloring="${b}${U}"
else: else:
coloring="${U}${Y}" coloring="${U}${Y}"
print(colorify(coloring+page[0],opts)) print(align_pad+colorify(coloring+page[0],opts)+bc.Z)
# Print page rows # Print page rows
parsed=md_color.parse(page) parsed=md_color.parse(page)
@@ -332,7 +339,7 @@ def page_print(reader,opts,offset):
colored_row=colored[row_i]#=colorify(row,opts) colored_row=colored[row_i]#=colorify(row,opts)
if offset[1]==r+1+offset[0]: if offset[1]==r+1+offset[0]:
colored_row=add_highlight(row,opts) colored_row=add_highlight(row,opts)
sys.stdout.write(colored_row) sys.stdout.write(align_pad+colored_row)
if r>=scrsize[0]-2: if r>=scrsize[0]-2:
break break
@@ -478,7 +485,7 @@ def colorify(s,opts):
""" Add colors to string """ """ Add colors to string """
if not opts.color: if not opts.color:
return bc.nocolor_string(s) return bc.nocolor_string(s)
c=bc.color_string(s)+bc.Z c=bc.color_string(s)#+bc.Z
return c return c
def cut_line(s,i): def cut_line(s,i):

View File

@@ -142,10 +142,10 @@ block_match={
blocks=['block_quote', 'multiline_code','hrule', 'heading','lheading','list_bullet', 'block_code', 'text', 'empty'] blocks=['block_quote', 'multiline_code','hrule', 'heading','lheading','list_bullet', 'block_code', 'text', 'empty']
inline_match={ inline_match={
'bold1': {'re':re.compile(r'(^| )(_[^_]+_)'), 'bold1': {'re':re.compile(r'(^| |})(_[^_]+_)'),
'bc':'${W}\\1\\2','dc':'${W}\\1\\2'}, # _bold_ 'bc':'\\1${W}\\2','dc':'${W}\\1\\2'}, # _bold_
'bold2': {'re':re.compile(r'(^| )(\*{1,2}[^\*]+\*{1,2})'), 'bold2': {'re':re.compile(r'(^| |})(\*{1,2}[^\*]+\*{1,2})'),
'bc':'${W}\\1\\2','dc':'${W}\\1\\2'}, # **bold** 'bc':'\\1${W}\\2','dc':'${W}\\1\\2'}, # **bold**
'code': {'re':re.compile(r'([`]+[^`]+[`]+)'), 'code': {'re':re.compile(r'([`]+[^`]+[`]+)'),
'bc':'${c}\\1','dc':'${m}\\1'}, # `code` 'bc':'${c}\\1','dc':'${m}\\1'}, # `code`
'code_special': {'re':re.compile(r'([`]+[^`]+[`]+)([!>])'), 'code_special': {'re':re.compile(r'([`]+[^`]+[`]+)([!>])'),