diff --git a/taskwiki/regexp.py b/taskwiki/regexp.py index 5eb7369..4eb898f 100644 --- a/taskwiki/regexp.py +++ b/taskwiki/regexp.py @@ -60,6 +60,14 @@ GENERIC_VIEWPORT = re.compile( '[=]+' # Header ending ) +GENERIC_HEADER = re.compile( + '^' # Starts at the beginning of the line + '[=]+' # With a positive number of = + '[^=]+' # Character other than = + '[=]+' # Positive number of =, closing the header + '\s*' # Allow trailing whitespace +) + ANSI_ESCAPE_SEQ = re.compile( '\x1b' # literal ESC '\[' # literal [ diff --git a/taskwiki/vwtask.py b/taskwiki/vwtask.py index dc72e42..d8712b1 100644 --- a/taskwiki/vwtask.py +++ b/taskwiki/vwtask.py @@ -351,3 +351,9 @@ class VimwikiTask(object): # If port was detected, break the search break + + # If line matches any header that is not a viewport, + # break the search too + line = self.cache.buffer[i] + if re.match(regexp.GENERIC_HEADER, line): + break