Skip to content

Commit

Permalink
enable theme for export utility
Browse files Browse the repository at this point in the history
  • Loading branch information
anhtumai committed May 22, 2023
1 parent 02ab5ed commit b585026
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions grip/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ def clear_cache(grip_class=None):
def render_page(path=None, user_content=False, context=None,
username=None, password=None,
render_offline=False, render_wide=False, render_inline=False,
api_url=None, title=None, text=None, quiet=None,
api_url=None, title=None, text=None, quiet=None, theme='light',
grip_class=None):
"""
Renders the specified markup text to an HTML page and returns it.
"""
return create_app(path, user_content, context, username, password,
render_offline, render_wide, render_inline, api_url,
title, text, False, quiet, grip_class).render()
title, text, False, quiet, theme, grip_class).render()


def render_content(text, user_content=False, context=None, username=None,
Expand All @@ -97,7 +97,7 @@ def render_content(text, user_content=False, context=None, username=None,
def export(path=None, user_content=False, context=None,
username=None, password=None, render_offline=False,
render_wide=False, render_inline=True, out_filename=None,
api_url=None, title=None, quiet=False, grip_class=None):
api_url=None, title=None, quiet=False, theme='light', grip_class=None):
"""
Exports the rendered HTML to a file.
"""
Expand All @@ -115,7 +115,7 @@ def export(path=None, user_content=False, context=None,

page = render_page(path, user_content, context, username, password,
render_offline, render_wide, render_inline, api_url,
title, None, quiet, grip_class)
title, None, quiet, theme, grip_class)

if export_to_stdout:
try:
Expand Down
22 changes: 11 additions & 11 deletions grip/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,28 @@ def main(argv=None, force_utf8=True, patch_svg=True):
if args['--user'] and not password:
password = getpass()

# Parse theme argument
if args['--theme']:
if args['--theme'] in VALID_THEME_OPTIONS:
theme: str = args['--theme']
else:
print('Error: valid options for theme argument are "light", "dark"')
return 1
else:
theme = 'light'

# Export to a file instead of running a server
if args['--export']:
try:
export(args['<path>'], args['--user-content'], args['--context'],
args['--user'], password, False, args['--wide'],
not args['--no-inline'], args['<address>'],
args['--api-url'], args['--title'], args['--quiet'])
args['--api-url'], args['--title'], args['--quiet'], theme)
return 0
except ReadmeNotFoundError as ex:
print('Error:', ex)
return 1

# Parse theme argument
if args['--theme']:
if args['--theme'] in VALID_THEME_OPTIONS:
theme: str = args['--theme']
else:
print('Error: valid options for theme argument are "light", "dark"')
return 1
else:
theme = 'light'

# Parse arguments
path, address = resolve(args['<path>'], args['<address>'])
host, port = split_address(address)
Expand Down

0 comments on commit b585026

Please sign in to comment.