Skip to content

Commit

Permalink
Merge branch 'release/v5.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
manuth committed Oct 5, 2021
2 parents 18990d2 + d48bb8b commit 5b030ae
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 18 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## MarkdownConverter [Unreleased]

[Show differences](https://github.com/manuth/MarkdownConverter/compare/v5.0.0...dev)
[Show differences](https://github.com/manuth/MarkdownConverter/compare/v5.0.1...dev)

## MarkdownConverter v5.0.1
### Updated
- The internal slugifier to make anchors look like the ones produced by GitHub
Once more, thanks to [@Postur](https://github.com/Postur) for pointing this out!

[Show differences](https://github.com/manuth/MarkdownConverter/compare/v5.0.0...v5.0.1)

## MarkdownConverter v5.0.0
### Breaking
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown-converter",
"version": "5.0.0",
"version": "5.0.1",
"private": true,
"description": "A markdown-converter for vscode",
"author": "Manuel Thalmann <m@nuth.ch> (https://nuth.ch)",
Expand Down
12 changes: 2 additions & 10 deletions src/System/Documents/Slugifier.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { slugify } from "transliteration";

/**
* Provides the functionality to generate slugs.
*/
Expand Down Expand Up @@ -45,7 +43,7 @@ export class Slugifier
{
let baseName = this.Slugify(text);

let counter = 1;
let counter = 0;
let slug = baseName;

while (this.Slugs.includes(slug))
Expand Down Expand Up @@ -76,12 +74,6 @@ export class Slugifier
*/
protected Slugify(text: string): string
{
return slugify(
text,
{
lowercase: true,
separator: "-",
ignore: []
});
return text.replace(/[^\p{L}\p{M}\p{Nd}\p{Nl}\p{Pc}\- ]/gu, "").toLowerCase().replace(/ /g, "-");
}
}
3 changes: 2 additions & 1 deletion src/test/CommonHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export function CommonHooks(): ITestContext<ISettings>
});

teardown(
async () =>
async function()
{
this.timeout(5 * 1000);
Resources.Culture = originalCulture;
await interceptor.Context.CloseEditors();
});
Expand Down
35 changes: 33 additions & 2 deletions src/tests/common/System/Documents/Slugifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function SlugifierTests(): void
slugifier = new Slugifier();
});

suite(
suite.only(
nameof<Slugifier>((slugifier) => slugifier.CreateSlug),
() =>
{
Expand All @@ -50,9 +50,40 @@ export function SlugifierTests(): void

for (let i = 0; i < max; i++)
{
strictEqual(slugifier.CreateSlug(slug), kebabCase(`${slug}${i + 2}`));
strictEqual(slugifier.CreateSlug(slug), kebabCase(`${slug}${i + 1}`));
}
});

test(
"Checking whether multiple spaces in a row are not removed…",
() =>
{
let count = random.integer(1, 10);

strictEqual(
slugifier.CreateSlug(`hello${" ".repeat(count)}world`),
`hello${"-".repeat(count)}world`);
});

test(
"Checking whether punctations are removed…",
() =>
{
strictEqual(
slugifier.CreateSlug(
"hello " +
"[]!'#$%&()*+,./:;<=>?@\\^{|}~`。,、;:?!…—·¨‘’“”~‖∶"'`|〃〔〕〈〉《》「」『』.〖〗【】()[]{}" +
"world"),
"hello-world");
});

test(
"Checking whether unicode-characters aren't stripped away…",
() =>
{
strictEqual(slugifier.CreateSlug("你好, world!'"), "你好-world");
strictEqual(slugifier.CreateSlug("Krøv"), "krøv");
});
});

suite(
Expand Down
2 changes: 1 addition & 1 deletion src/tests/common/System/Tasks/ConversionRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ export function ConversionRunnerTests(context: ITestContext<ISettings>): void
{
let result = load(parser.render(content));
strictEqual(result(`#${kebabCase(headerText)}`).length, 1);
strictEqual(result(`#${kebabCase(`${headerText}2`)}`).length, 1);
strictEqual(result(`#${kebabCase(`${headerText}1`)}`).length, 1);
}
});

Expand Down

0 comments on commit 5b030ae

Please sign in to comment.