Example #1
0
 def __search_for_possible_matches(
     self,
     string_to_check: str,
     string_to_check_lower: str,
     search_start: int,
     found_index: int,
     start_x_offset: int,
     start_y_offset: int,
     same_line_offset: int,
     next_name: str,
     context: PluginScanContext,
     token: MarkdownToken,
 ) -> None:
     col_adjust, line_adjust = ParserHelper.adjust_for_newlines(
         string_to_check_lower, search_start, found_index)
     if line_adjust == 0 and start_y_offset == 0:
         col_adjust -= same_line_offset
     line_adjust += start_y_offset
     if col_adjust == 0 and start_x_offset:
         col_adjust += (-start_x_offset
                        if start_x_offset > 0 else -(-start_x_offset - 1))
         col_adjust = -col_adjust
     elif col_adjust > 0 and start_x_offset:
         col_adjust += -start_x_offset - 1
         col_adjust = -col_adjust
     self.__check_for_proper_match(
         string_to_check,
         found_index,
         next_name,
         context,
         token,
         line_adjust,
         col_adjust,
     )
Example #2
0
 def __evaluate_possible_url(
     self,
     source_text: str,
     url_prefix: str,
     found_index: int,
     context: PluginScanContext,
     token: MarkdownToken,
 ) -> None:
     if found_index == 0 or source_text[found_index - 1] in (
             " ",
             ParserHelper.newline_character,
     ):
         url_start_sequence = source_text[found_index + len(url_prefix):]
         if (len(url_start_sequence) >= 3
                 and url_start_sequence.startswith("//")
                 and url_start_sequence[2]
                 not in (" ", ParserHelper.newline_character)):
             (
                 column_number_delta,
                 line_number_delta,
             ) = ParserHelper.adjust_for_newlines(source_text, 0,
                                                  found_index)
             self.report_next_token_error(
                 context,
                 token,
                 line_number_delta=line_number_delta,
                 column_number_delta=column_number_delta,
             )
Example #3
0
    def __adjust_for_newlines_and_search(
        self,
        context: PluginScanContext,
        token: MarkdownToken,
        link_body_text: str,
        full_link_text: str,
        string_to_check: str,
        same_line_offset: int,
    ) -> None:

        start_x_offset = 0
        start_y_offset = 0
        if ParserHelper.newline_character in link_body_text:
            start_x_offset, start_y_offset = ParserHelper.adjust_for_newlines(
                full_link_text, 0, len(full_link_text))
        self.__search_for_matches(
            string_to_check,
            context,
            token,
            same_line_offset,
            start_x_offset,
            start_y_offset,
        )