diff --git a/src/chordpro/renderers/html.py b/src/chordpro/renderers/html.py
index 35c2d26..e8af233 100644
--- a/src/chordpro/renderers/html.py
+++ b/src/chordpro/renderers/html.py
@@ -4,18 +4,18 @@ CHORD = '
{} | '
SYLLB = '{} | '
LINE = ''
-VERSE = '''
+STANZA = '''
{verse_name}
{verse_body}
'''
-TITLE = ''
+TITLE = ''
HTML = '''
{title}
@@ -41,7 +41,7 @@ HTML_OPTIONS = {
'default_size': {
'description': 'The default size to use.',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'default'
},
'title_font': {
@@ -51,9 +51,9 @@ HTML_OPTIONS = {
'group': 'title'
},
'title_size': {
- 'description': 'The size of the title in rem',
+ 'description': 'The size of the title in pt',
'type': int,
- 'default': None,
+ 'default': 14,
'group': 'title'
},
'title_is_bold': {
@@ -65,13 +65,13 @@ HTML_OPTIONS = {
'title_is_centered': {
'description': 'Center the title on the page',
'type': bool,
- 'default': None,
+ 'default': False,
'group': 'title'
},
'title_is_upper': {
'description': 'Force the title to be uppercase',
'type': bool,
- 'default': None,
+ 'default': False,
'group': 'title'
},
'composer_font': {
@@ -81,27 +81,27 @@ HTML_OPTIONS = {
'group': 'composer'
},
'composer_size': {
- 'description': 'The size of the composer in rem',
+ 'description': 'The size of the composer in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'composer'
},
'composer_is_bold': {
'description': 'Set to True to make the composer bold',
'type': bool,
- 'default': None,
+ 'default': False,
'group': 'composer'
},
'composer_is_centered': {
'description': 'Center the composer on the page',
'type': bool,
- 'default': None,
+ 'default': False,
'group': 'composer'
},
'composer_is_upper': {
'description': 'Force the composer to be uppercase',
'type': bool,
- 'default': None,
+ 'default': False,
'group': 'composer'
},
'copyright_font': {
@@ -111,9 +111,9 @@ HTML_OPTIONS = {
'group': 'copyright'
},
'copyright_size': {
- 'description': 'The size of the copyright in rem',
+ 'description': 'The size of the copyright in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'copyright'
},
'copyright_is_bold': {
@@ -125,7 +125,7 @@ HTML_OPTIONS = {
'copyright_is_upper': {
'description': 'Force the copyright to be uppercase',
'type': bool,
- 'default': None,
+ 'default': False,
'group': 'copyright'
},
'stanza_font': {
@@ -135,9 +135,9 @@ HTML_OPTIONS = {
'group': 'stanza'
},
'stanza_size': {
- 'description': 'The size of the stanza in rem',
+ 'description': 'The size of the stanza in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'stanza'
},
'stanza_is_bold': {
@@ -147,7 +147,7 @@ HTML_OPTIONS = {
'group': 'stanza'
},
'stanza_indent': {
- 'description': 'How much to indent the stanza by, in rem',
+ 'description': 'How much to indent the stanza',
'type': int,
'default': 4,
'group': 'stanza'
@@ -159,9 +159,9 @@ HTML_OPTIONS = {
'group': 'stanza_heading'
},
'stanza_heading_size': {
- 'description': 'The size of the stanza heading in rem',
+ 'description': 'The size of the stanza heading in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'stanza_heading'
},
'stanza_heading_is_bold': {
@@ -183,21 +183,21 @@ HTML_OPTIONS = {
'group': 'verse'
},
'verse_size': {
- 'description': 'The size of the verse in rem',
+ 'description': 'The size of the verse in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'verse'
},
'verse_is_bold': {
'description': 'Set to True to make the verse bold',
'type': bool,
- 'default': None,
+ 'default': False,
'group': 'verse'
},
'verse_indent': {
- 'description': 'How much to indent the verse by, in rem',
+ 'description': 'How much to indent the verse',
'type': int,
- 'default': None,
+ 'default': 4,
'group': 'verse'
},
'verse_heading_font': {
@@ -207,15 +207,15 @@ HTML_OPTIONS = {
'group': 'verse_heading'
},
'verse_heading_size': {
- 'description': 'The size of the verse heading in rem',
+ 'description': 'The size of the verse heading in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'verse_heading'
},
'verse_heading_is_bold': {
'description': 'Set to True to make the verse heading bold',
'type': bool,
- 'default': None,
+ 'default': True,
'group': 'verse_heading'
},
'verse_heading_is_upper': {
@@ -231,21 +231,21 @@ HTML_OPTIONS = {
'group': 'chorus'
},
'chorus_size': {
- 'description': 'The size of the chorus in rem',
+ 'description': 'The size of the chorus in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'chorus'
},
'chorus_is_bold': {
'description': 'Set to True to make the chorus bold',
'type': bool,
- 'default': None,
+ 'default': False,
'group': 'chorus'
},
'chorus_indent': {
- 'description': 'How much to indent the chorus by, in rem',
+ 'description': 'How much to indent the chorus',
'type': int,
- 'default': None,
+ 'default': 4,
'group': 'chorus'
},
'chorus_heading_font': {
@@ -255,15 +255,15 @@ HTML_OPTIONS = {
'group': 'chorus_heading'
},
'chorus_heading_size': {
- 'description': 'The size of the chorus heading in rem',
+ 'description': 'The size of the chorus heading in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'chorus_heading'
},
'chorus_heading_is_bold': {
'description': 'Set to True to make the chorus heading bold',
'type': bool,
- 'default': None,
+ 'default': True,
'group': 'chorus_heading'
},
'chorus_heading_is_upper': {
@@ -279,21 +279,21 @@ HTML_OPTIONS = {
'group': 'bridge'
},
'bridge_size': {
- 'description': 'The size of the bridge in rem',
+ 'description': 'The size of the bridge in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'bridge'
},
'bridge_is_bold': {
'description': 'Set to True to make the bridge bold',
'type': bool,
- 'default': None,
+ 'default': False,
'group': 'bridge'
},
'bridge_indent': {
- 'description': 'How much to indent the bridge by, in rem',
+ 'description': 'How much to indent the bridge',
'type': int,
- 'default': None,
+ 'default': 4,
'group': 'bridge'
},
'bridge_heading_font': {
@@ -303,15 +303,15 @@ HTML_OPTIONS = {
'group': 'bridge_heading'
},
'bridge_heading_size': {
- 'description': 'The size of the bridge heading in rem',
+ 'description': 'The size of the bridge heading in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'bridge_heading'
},
'bridge_heading_is_bold': {
'description': 'Set to True to make the bridge heading bold',
'type': bool,
- 'default': None,
+ 'default': True,
'group': 'bridge_heading'
},
'bridge_heading_is_upper': {
@@ -327,9 +327,9 @@ HTML_OPTIONS = {
'group': 'chord'
},
'chord_size': {
- 'description': 'The size of the chord in rem',
+ 'description': 'The size of the chord in pt',
'type': int,
- 'default': None,
+ 'default': 12,
'group': 'chord'
},
'chord_is_bold': {
@@ -367,14 +367,10 @@ def get_option_groups():
def make_style(name, font=None, size=None, is_bold=None, is_centered=None, is_upper=None, indent=None):
"""Build a CSS style"""
styles = []
- if name == 'default':
- styles.append('html, body, * {')
- else:
- styles.append('.{name} {{'.format(name=name))
if font:
styles.append(' font-family: \'{font}\';'.format(font=font))
if size:
- styles.append(' font-size: {size}rem;'.format(size=size))
+ styles.append(' font-size: {size}pt;'.format(size=size))
if is_bold:
styles.append(' font-weight: bold !important;')
if is_centered:
@@ -383,7 +379,12 @@ def make_style(name, font=None, size=None, is_bold=None, is_centered=None, is_up
styles.append(' text-transform: uppercase;')
if indent:
styles.append(' margin-left: {indent}rem;'.format(indent=indent))
- styles.append('}')
+ if styles:
+ if name == 'default':
+ styles.insert(0, 'html, body, * {')
+ else:
+ styles.insert(0, '.{name} {{'.format(name=name))
+ styles.append('}')
return os.linesep.join(styles)
@@ -395,7 +396,7 @@ def generate_option_styles(options):
name = '{group}_{key}'.format(group=group, key=key)
if name not in HTML_OPTIONS:
continue
- option = options.get(name, default=HTML_OPTIONS[name]['default'])
+ option = options.get(name, HTML_OPTIONS[name]['default'])
if option:
kwargs[key] = option
styles.append(make_style(group.replace('_', '-'), **kwargs))
@@ -419,9 +420,9 @@ def render(song, options=None):
rendered_syllables.append(SYLLB.format(
syllable.syllable + (' ' if is_last_syllable and not is_last_word else '')))
rendered_lines.append(LINE.format(''.join(rendered_chords), ''.join(rendered_syllables)))
- rendered_verses.append(VERSE.format(verse_type=verse.type_ or '', verse_name=verse.title,
- verse_body='\n'.join(rendered_lines)))
+ rendered_verses.append(STANZA.format(verse_type=verse.type_ or '', verse_name=verse.title,
+ verse_body='\n'.join(rendered_lines)))
title = song.metadata.get('title') or 'Song'
- metadata = TITLE.format(title=title, artist=song.metadata.get('artist') or song.metadata.get('composer') or '')
+ metadata = TITLE.format(title=title, composer=song.metadata.get('artist') or song.metadata.get('composer') or '')
body = metadata + '\n' + '\n'.join(rendered_verses)
return HTML.format(title=title, body=body, styles=os.linesep.join(styles))