From 6835d79e9ea7ba77b9d9d32a2bb9e1e3cdc76539 Mon Sep 17 00:00:00 2001 From: Camilo Coelho Date: Sun, 31 Oct 2021 18:31:17 +0100 Subject: [PATCH 01/10] Updating global config file --- config.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config.json b/config.json index d657ac36a8..f7354b254c 100644 --- a/config.json +++ b/config.json @@ -369,6 +369,20 @@ "strings" ] }, + { + "slug": "markdown", + "name": "Markdown", + "uuid": "3994ee58-0d75-4c46-afe1-666466470255", + "practices": ["regular-expressions", "functions"], + "prerequisites": [], + "difficulty": 4, + "topics": [ + "conditionals", + "pattern_recognition", + "regular_expressions", + "strings" + ] + }, { "slug": "book-store", "name": "Book Store", From da4f08848da491f0de414f30332bc9871c8a54a7 Mon Sep 17 00:00:00 2001 From: Camilo Coelho Date: Sun, 31 Oct 2021 18:31:54 +0100 Subject: [PATCH 02/10] Creating meta files --- exercises/practice/markdown/.meta/config.json | 10 +++ exercises/practice/markdown/.meta/proof.ci.js | 63 +++++++++++++++++++ exercises/practice/markdown/.meta/tests.toml | 0 3 files changed, 73 insertions(+) create mode 100644 exercises/practice/markdown/.meta/config.json create mode 100644 exercises/practice/markdown/.meta/proof.ci.js create mode 100644 exercises/practice/markdown/.meta/tests.toml diff --git a/exercises/practice/markdown/.meta/config.json b/exercises/practice/markdown/.meta/config.json new file mode 100644 index 0000000000..ff3a79dba4 --- /dev/null +++ b/exercises/practice/markdown/.meta/config.json @@ -0,0 +1,10 @@ +{ + "blurb": "Refactor a Markdown parser.", + "authors": ["kmelow"], + "contributors": [], + "files": { + "solution": ["markdown.js"], + "test": ["markdown.spec.js"], + "example": [".meta/proof.ci.js"] + } +} diff --git a/exercises/practice/markdown/.meta/proof.ci.js b/exercises/practice/markdown/.meta/proof.ci.js new file mode 100644 index 0000000000..7f89f7e7e4 --- /dev/null +++ b/exercises/practice/markdown/.meta/proof.ci.js @@ -0,0 +1,63 @@ +export const parse = (markdown) => { + if (markdown.includes(' __')) { + markdown = markdown.replace(' __', ' '); + } + if (markdown.includes(' _')) { + markdown = markdown.replace(' _', ' '); + } + + if (markdown.includes('__ ')) { + markdown = markdown.replace('__ ', ' '); + } + if (markdown.includes('_ ')) { + markdown = markdown.replace('_ ', ' '); + } + + if (markdown.startsWith('__')) { + markdown = markdown.replace('__', ''); + } + if (markdown.endsWith('__')) { + markdown = markdown.replace('__', ''); + } + + if (markdown.startsWith('_')) { + markdown = markdown.replace('_', ''); + } + if (markdown.endsWith('_')) { + markdown = markdown.replace('_', ''); + } + + if (markdown.startsWith('# ')) { + markdown = markdown.replace('# ', '

'); + if (markdown.match(/\n\*/gm)) { + markdown = markdown.replace('\n* ', '

'); + markdown = markdown + '

'; + } else { + markdown = markdown + ''; + } + } else if (markdown.startsWith('## ')) { + markdown = markdown.replace('## ', '

') + '

'; + } else if (markdown.startsWith('### ')) { + markdown = markdown.replace('### ', '

') + '

'; + } else if (markdown.startsWith('#### ')) { + markdown = markdown.replace('#### ', '

') + '

'; + } else if (markdown.startsWith('##### ')) { + markdown = markdown.replace('##### ', '
') + '
'; + } else if (markdown.startsWith('###### ')) { + markdown = markdown.replace('###### ', '
') + '
'; + } else if (markdown.startsWith('* ')) { + markdown = markdown.replace('* ', ''; + } else { + markdown = `

${markdown}

`; + } + + markdown = markdown.replace('\n* ', ''; + } } else { markdown = markdown + ''; } From a75649ff3c86391bbadb4cf316b3395e623574b4 Mon Sep 17 00:00:00 2001 From: Camilo Coelho Date: Sun, 31 Oct 2021 20:47:44 +0100 Subject: [PATCH 10/10] Running scripts and updating config --- exercises/practice/markdown/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/practice/markdown/package.json b/exercises/practice/markdown/package.json index 69e873f8aa..ab7374161d 100644 --- a/exercises/practice/markdown/package.json +++ b/exercises/practice/markdown/package.json @@ -11,12 +11,12 @@ }, "devDependencies": { "@babel/cli": "^7.15.7", - "@babel/core": "^7.15.8", + "@babel/core": "^7.16.0", "@babel/plugin-syntax-bigint": "^7.8.3", "@babel/preset-env": "^7.15.8", "@exercism/eslint-config-javascript": "^0.5.0", "@types/jest": "^26.0.24", - "@types/node": "^16.11.4", + "@types/node": "^16.11.6", "babel-jest": "^27.3.1", "core-js": "^3.19.0", "eslint": "^7.32.0",