minor: Clean up lstrip() for help article titles.

Saying `foo.lstrip('# ')` does more than just remove
a '# ' prefix.  It removes any combination of '#' and
spaces.

We now make the intention slightly more clear.

We would strip these as you'd expect:

    # foo
    ## foo
    ### foo

but for this we now only strip the first "#":

    # # # # # foo
This commit is contained in:
Steve Howell
2020-03-20 17:28:24 +00:00
committed by Tim Abbott
parent edf1b1e5e8
commit a041d9e4aa

View File

@@ -107,7 +107,7 @@ class MarkdownDirectoryView(ApiURLView):
with open(article_path) as article_file: with open(article_path) as article_file:
first_line = article_file.readlines()[0] first_line = article_file.readlines()[0]
# Strip the header and then use the first line to get the article title # Strip the header and then use the first line to get the article title
article_title = first_line.strip().lstrip("# ") article_title = first_line.lstrip("#").strip()
if context["not_index_page"]: if context["not_index_page"]:
context["OPEN_GRAPH_TITLE"] = "%s (%s)" % (article_title, title_base) context["OPEN_GRAPH_TITLE"] = "%s (%s)" % (article_title, title_base)
else: else: