danoan.correct_markdown.core.api module

danoan.correct_markdown.core.api.apply_corrections(markdown_stream: TextIO, diff_items: List[DiffItem]) str[source]
Parameters:
  • markdown_stream (TextIO)

  • diff_items (List[DiffItem])

Return type:

str

danoan.correct_markdown.core.api.apply_diff(mv: MarkdownView, item: DiffItem, start: int = 0) Tuple[int, int][source]

Apply correction in markdown view contained in the diff item.

We use the item.original_value and its after context to find the correct position in the markdown view where the diff operation will take place. The after context is important to avoid false positives, which can be quite common when the original_value is short such as the,` one` and so on.

Parameters:
Return type:

Tuple[int, int]

danoan.correct_markdown.core.api.render_diff_view(markdown_stream: TextIO, diff_items: List[DiffItem], insert=None, delete=None, replace=None) str[source]
Parameters:
  • markdown_stream (TextIO)

  • diff_items (List[DiffItem])

Return type:

str

danoan.correct_markdown.core.api.strikethrough_errors(markdown_stream: TextIO, diff_items: List[DiffItem]) str[source]
Parameters:
  • markdown_stream (TextIO)

  • diff_items (List[DiffItem])

Return type:

str

danoan.correct_markdown.core.api.text_diff(ss_a: TextIO, ss_b: TextIO, mode: TextDiffMode, context_size: int = 10, update_a: bool = False) Generator[DiffItem, None, None][source]

Compare two string streams and return the differences.

If mode is TextDiffMode.Letter, the streams are compared letter by letter. If mode is TextDiffMode.Word, some characters such as whitespaces and new lines are ignored.

The context_size gives the number of letter or words surrounding the diff that is returned as context.

If update_a, then the baseline stream is updated with the found diff before the search for the next diff is started.

Parameters:
  • ss_a (TextIO)

  • ss_b (TextIO)

  • mode (TextDiffMode)

  • context_size (int)

  • update_a (bool)

Return type:

Generator[DiffItem, None, None]