Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixes#50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 3 commits intomasterfromfixes
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
ignore leading/trailing white space in validate markdown
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
@ShMcK
ShMcK committedJun 25, 2020
commitf0efe97e0cc24f2391e306c3efa118d08add7bd3
9 changes: 5 additions & 4 deletionssrc/utils/validateMarkdown.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,16 +53,17 @@ const codeBlockRegex = /```[a-z]*\n[\s\S]*?\n```/gm;

export function validateMarkdown(md: string): boolean {
// remove codeblocks which might contain any valid combinations
const text = md.replace(codeBlockRegex, "");
// trim white space
const text = md.replace(codeBlockRegex, "").trim();

let valid = true;

for (const v of validations) {
if (!v.validate(text)) {
valid = false;
//if (process.env.NODE_ENV !== "test") {
console.warn(v.message);
//}
if (process.env.NODE_ENV !== "test") {
console.warn(v.message);
}
}
}

Expand Down
22 changes: 22 additions & 0 deletionstests/markdown.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,4 +132,26 @@ Should not be an issue
First Step`;
expect(validateMarkdown(md)).toBe(true);
});
it("should ignore empty space at the top", () => {
const md = `

# Title

Description.`;
expect(validateMarkdown(md)).toBe(true);
});
it("should ignore empty space at the bottom", () => {
const md = `

# Title

Description.





`;
expect(validateMarkdown(md)).toBe(true);
});
});

[8]ページ先頭

©2009-2025 Movatter.jp