diff --git a/src/chordpro/base.py b/src/chordpro/base.py index d755a6c..f925f33 100644 --- a/src/chordpro/base.py +++ b/src/chordpro/base.py @@ -1,14 +1,8 @@ -import re - from hyphen import Hyphenator -from chordpro.constants import KNOWN_DIRECTIVES, KNOWN_VERSE_TYPES +from chordpro.constants import DIRECTIVE, CHORD_WORD, CHORUS_MARKER, KNOWN_DIRECTIVES, \ + START_OF, END_OF -DIRECTIVE = re.compile(r'\{(.*?): *(.*?)\}') -START_OF = re.compile(r'\{start_of_(' + '|'.join(KNOWN_VERSE_TYPES) + r')(: *(.*?))?\}') -END_OF = re.compile(r'\{end_of_(' + '|'.join(KNOWN_VERSE_TYPES) + r')\}') -CHORUS_MARKER = re.compile(r'\{chorus(: *(.*?))?\}') -CHORD_WORD = re.compile(r'(.*?)\[(.*?)\]') HYPHEN_CACHE = {} SYLLABLE_EXCEPTIONS = { 'outer': ['out', 'er'] diff --git a/src/chordpro/constants.py b/src/chordpro/constants.py index cc88a39..8e7fc39 100644 --- a/src/chordpro/constants.py +++ b/src/chordpro/constants.py @@ -1,3 +1,5 @@ +import re + KNOWN_DIRECTIVES = [ ('title', 't'), ('subtitle', 'st'), @@ -27,3 +29,8 @@ GERMAN_NOTES = '[CDEFGAH]' NEOLATIN_NOTES = '(Do|Re|Mi|Fa|Sol|La|Si)' CHORD_SUFFIXES = '(b|bb)?(#)?(m|maj7|maj|min7|min|sus)?(1|2|3|4|5|6|7|8|9)?' SLIM_CHARS = 'fiíIÍjlĺľrtť.,;/ ()|"\'!:\\' +DIRECTIVE = re.compile(r'\{(.*?): *(.*?)\}') +START_OF = re.compile(r'\{start_of_(' + '|'.join(KNOWN_VERSE_TYPES) + r')(: *(.*?))?\}') +END_OF = re.compile(r'\{end_of_(' + '|'.join(KNOWN_VERSE_TYPES) + r')\}') +CHORUS_MARKER = re.compile(r'\{chorus(: *(.*?))?\}') +CHORD_WORD = re.compile(r'(.*?)\[(.*?)\]')