Skip to content

Commit

Permalink
Handle headers with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
cdupuis committed Nov 24, 2020
1 parent c89f309 commit 4a35d4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function convertFormat(text: string): string {
.replace(/(\*|_)(?!\1)(\S|\S.*?\S)\1(?!\1)/g, "<itmkd>$2<itmkd>")
.replace(/<bdmkd>/g, "*")
.replace(/<itmkd>/g, "_")
.replace(/^([#]+)\s+(\S+)$/gm, `*$2*`);
.replace(/^([#]+)\s+([\S ]+)$/gm, `*$2*`);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/Markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,15 +706,15 @@ Here is how the above list was created using Markdown:
- \`*Under the Bushes Under the Stars*\`
\`\`\`
`;
const expected = `# Guided By Voices
const expected = `*Guided By Voices*
<https://www.gbv.com|Guided By Voices>, commonly referred to as "_GBV_", is a band from
Dayton, OH, USA fronted by <https://en.wikipedia.org/wiki/Robert_Pollard|Robert Pollard>.
Mr. Pollard is a *prolific* songwriter, through GBV and solo efforts
having released over *_100 albums_*.
## Albums
*Albums*
Here are some <https://www.gbv.com|GBV> albums:
Expand All @@ -736,7 +736,7 @@ Here is how the above list was created using Markdown:
- \`*Under the Bushes Under the Stars*\`
\`\`\`
`;
assert(githubToSlack(md) === expected);
assert.strictEqual(githubToSlack(md), expected);
});

it("should not mangle urls", () => {
Expand Down

0 comments on commit 4a35d4d

Please sign in to comment.