### Question:
MarkwonBasedMarkdownRenderer implements Markdown { @VisibleForTesting String fixInvalidHeadings(String markdown) { try { Matcher matcher = HEADING_WITHOUT_SPACE_MARKDOWN_PATTERN.matcher(markdown); while (matcher.find()) { String heading = matcher.group(0); String hashes = matcher.group(1); String content = matcher.group(2).trim(); markdown = markdown.replace(heading, String.format("%s %s", hashes, content)); } } catch (Throwable e) { Timber.e(e, "Couldn't fix invalid headers in: %s", markdown); } return markdown; } @Inject  MarkwonBasedMarkdownRenderer(
      SpannableConfiguration configuration,
      AutoRedditLinkExtension autoRedditLinkExtension,
      EmptyListItemHandlerExtension emptyListItemHandlerExtension,
      MarkdownHintOptions markdownOptions,
      @Named("markwon_spans_renderer") Cache<String, CharSequence> cache); @Override CharSequence parse(PendingSyncReply reply); @Override CharSequence parseAuthorFlair(String flair); @Override CharSequence parse(Message message); @Override CharSequence parse(Comment comment); @Override CharSequence parseSelfText(Submission submission); @Override @Deprecated String stripMarkdown(Comment comment); @Override String stripMarkdown(Message message); @Override void clearCache();  }### Answer:
@Test public void fixInvalidHeadings() { String invalid = "#Heading 1\n\n##Heading 2\n\n### Heading 3\n\n#### Heading 4\n\n#####Heading 5\n\n######Heading 6\n\nSome normal text with a # in between."; String expected = "# Heading 1\n\n## Heading 2\n\n### Heading 3\n\n#### Heading 4\n\n##### Heading 5\n\n###### Heading 6\n\nSome normal text with a # in between."; String parsed = renderer.fixInvalidHeadings(invalid); assertEquals(expected, parsed); }