aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/usage.rst4
-rwxr-xr-xtextoutpc/builtin/_Link.py7
-rwxr-xr-xtextoutpc/builtin/_Title.py4
3 files changed, 11 insertions, 4 deletions
diff --git a/docs/usage.rst b/docs/usage.rst
index 1e23cba..6411351 100644
--- a/docs/usage.rst
+++ b/docs/usage.rst
@@ -38,7 +38,9 @@ The following tweaks are read by the translator and built-in tags:
(e.g. lynx) compatibility, e.g. ``<b>``, ``<i>``, ``<center>``, and
others. Defaults to ``True``.
- ``title_level`` (HTML): level at which to start for titles and subtitles,
- e.g. ``h5`` for ``h5`` for titles and ``h6`` for subtitles.
+ e.g. 5 means ``h5`` for ``h5`` for titles and ``h6`` for subtitles.
+- ``link_target`` (HTML): either ``self`` (default, load in the same
+ frame as it was clicked) or ``blank`` (load in an other window).
An example call would be:
diff --git a/textoutpc/builtin/_Link.py b/textoutpc/builtin/_Link.py
index efe4a5a..b4b7ed9 100755
--- a/textoutpc/builtin/_Link.py
+++ b/textoutpc/builtin/_Link.py
@@ -52,7 +52,12 @@ class LinkTag(_InlineTag):
self._validate()
def begin_html(self):
- return '<a href="{}">'.format(_htmlescape(self._url))
+ target = self.tweak("link_target", "").casefold()
+ tattrs = ''
+ if target == 'blank':
+ tattrs = ' target="_blank" rel="noopener"'
+
+ return '<a href="{}"{}>'.format(_htmlescape(self._url), tattrs)
def end_html(self):
return '</a>'
diff --git a/textoutpc/builtin/_Title.py b/textoutpc/builtin/_Title.py
index 05d12ff..0f744e9 100755
--- a/textoutpc/builtin/_Title.py
+++ b/textoutpc/builtin/_Title.py
@@ -21,8 +21,8 @@ class TitleTag(_BlockTag):
raw = True
def prepare(self, name, value):
- level = self.tweak("title_level", "1")
- if level[0] == "h":
+ level = self.tweak("title_level", "1").casefold()
+ if isinstance(level, str) and level[0] == "h":
level = level[1:]
level = int(level)
assert 1 <= level <= 5