diff --git a/gift_wrapper/question.py b/gift_wrapper/question.py
index 766bf0f..ffd6fe3 100644
--- a/gift_wrapper/question.py
+++ b/gift_wrapper/question.py
@@ -11,25 +11,32 @@
from . import remote
from . import colors
-# # a string ended in ".svg" that does *not* begin with "http"
-# pattern_svg_file = '(?)(?!http)(\S+\.svg)(?!\.\S{3})'
-# # pattern_svg_file = '(?:^| |>)(?!http)([a-zA-Z0-9_/]+\.svg)(?!\.\S{3})'
-# # pattern_svg_file = r'(?)?(?!\S)'
-
# regular expression to extract a percentage
-re_percentage = re.compile('(\d*\.\d+|\d+)\s*%')
+re_percentage = re.compile(r'(\d*\.\d+|\d+)\s*%')
+
-# a string template to be used in markdown generation
-markdown_header_template = string.Template('$text')
+def markdown_header(
+ text: str,
+ template: string.Template = string.Template('$text')
+) -> str:
+ """
+ Returns a markdown header for a given text.
+ Parameters
+ ----------
+ text : str
+ Text for the header.
+ template : string template
+ The template that defines the appearance of the header, and in which `text` will be embedded.
-def markdown_header(text: str) -> str:
+ Returns
+ -------
+ str:
+ Markdown-compatible text.
+
+ """
- return f'\n{markdown_header_template.substitute(text=text)}\n\n'
+ return f'\n{template.substitute(text=text)}\n\n'
class HtmlQuestion(metaclass=abc.ABCMeta):
@@ -269,7 +276,6 @@ def answer(self):
if 'perfect' in self.answers:
# ...it is added in a special way
- # processed_answers.append('=' + self.process_text(self.answers['perfect']))
processed_answers.insert(0, '=' + self.process_text(self.answers['perfect']))
else:
@@ -408,7 +414,6 @@ def process_match(f):
# NOTE: an extra space is added in the replacement for `SvgToInline` --- not anymore
self.pre_processing_functions.append(functools.partial(
self.transform_files, pattern='(\S+)\.tex', process_match=process_match, replacement=r'\1.svg'))
- # self.transform_files, pattern='(\S+)\.tex', process_match=process_match, replacement=r' \1.svg'))
class SvgToHttp(QuestionDecorator):
@@ -448,14 +453,9 @@ def process_match(f):
# ...and a note is made of it
self.history['already transferred'].add(f)
- # else:
- #
- # print(f'{f} already transferred...')
-
# a new pre-processing function is attached to the corresponding list
self.pre_processing_functions.append(functools.partial(
self.transform_files, pattern=self.pattern_svg_file,
- # self.transform_files, pattern='(?\s*(?!
)(\S+\.svg)\s*
'
-
# notice the order is important: each pattern will result in a different post-processing function and they are
# applied *sequentially*, each one on the result of the previous one
patterns = [r'
\s*(?!
)(\S+\.svg)\s*
', r'(\S+\.svg)']
@@ -509,8 +507,3 @@ def replacement_function(m) -> str:
# a new pre-processing function is attached to the corresponding list
self.post_processing_functions.append(functools.partial(
self.transform_files, pattern=p, process_match=process_match, replacement=replacement_function))
-
- # # a new pre-processing function is attached to the corresponding list
- # self.post_processing_functions.append(functools.partial(
- # self.transform_files, pattern=self.pattern_svg_file,
- # process_match=process_match, replacement=replacement_function))
diff --git a/setup.py b/setup.py
index b463018..ef14d4b 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@
setuptools.setup(
name="gift-wrapper", # Replace with your own username
- version="1.3.5",
+ version="1.5",
author="Manuel A. Vázquez",
author_email="manuavazquez@gmail.com",
description="Build GIFT (Moodle compatible) files easily",