From e9a5358f80342db1e9ba2f3a0190d74d1d805bcc Mon Sep 17 00:00:00 2001 From: Anna Date: Thu, 2 Jan 2025 05:31:48 -0500 Subject: [PATCH] fix(curriculum): markdown lab check syntax multiple times (#57744) --- .../66f55eac933ff64ce654ca74.md | 140 +++++++++++++++++- 1 file changed, 136 insertions(+), 4 deletions(-) diff --git a/curriculum/challenges/english/25-front-end-development/lab-markdown-to-html-converter/66f55eac933ff64ce654ca74.md b/curriculum/challenges/english/25-front-end-development/lab-markdown-to-html-converter/66f55eac933ff64ce654ca74.md index 9f8b4cf862f..e1f53ae33a0 100644 --- a/curriculum/challenges/english/25-front-end-development/lab-markdown-to-html-converter/66f55eac933ff64ce654ca74.md +++ b/curriculum/challenges/english/25-front-end-development/lab-markdown-to-html-converter/66f55eac933ff64ce654ca74.md @@ -134,6 +134,20 @@ const testH1 = testDiv.querySelector("h1") assert.notExists(testH1); ``` +When the value of `#markdown-input` is `# title 1\n# alternate title`, `convertMarkdown()` should return `

title 1

alternate title

`. + +```js +const input = document.querySelector("#markdown-input"); +input.value = "# title 1\n# alternate title"; +const testDiv = document.createElement("div"); +testDiv.innerHTML = convertMarkdown(); +const headings = testDiv.querySelectorAll("h1"); +assert.lengthOf(headings, 2); +assert.lengthOf(testDiv.children, 2); +assert.equal(headings[0].innerText, "title 1"); +assert.equal(headings[1].innerText, "alternate title"); +``` + When the value of `#markdown-input` is `## title 2`, `convertMarkdown()` should return `

title 2

`. ```js @@ -186,6 +200,20 @@ const testH2 = testDiv.querySelector("h2") assert.notExists(testH2); ``` +When the value of `#markdown-input` is `## title 2\n## title 2 alt`, `convertMarkdown()` should return `

title 2

title 2 alt

`. + +```js +const input = document.querySelector("#markdown-input"); +input.value = "## title 2\n## title 2 alt"; +const testDiv = document.createElement("div"); +testDiv.innerHTML = convertMarkdown(); +const headings = testDiv.querySelectorAll("h2"); +assert.lengthOf(headings, 2); +assert.lengthOf(testDiv.children, 2); +assert.equal(headings[0].innerText, "title 2"); +assert.equal(headings[1].innerText, "title 2 alt"); +``` + When the value of `#markdown-input` is `### title 3`, `convertMarkdown()` should return `

title 3

`. ```js @@ -238,6 +266,20 @@ const testH3 = testDiv.querySelector("h3") assert.notExists(testH3); ``` +When the value of `#markdown-input` is `### title 3\n### third title`, `convertMarkdown()` should return `

title 3

third title

`. + +```js +const input = document.querySelector("#markdown-input"); +input.value = "### title 3\n### third title"; +const testDiv = document.createElement("div"); +testDiv.innerHTML = convertMarkdown(); +const headings = testDiv.querySelectorAll("h3"); +assert.lengthOf(headings, 2); +assert.lengthOf(testDiv.children, 2); +assert.equal(headings[0].innerText, "title 3"); +assert.equal(headings[1].innerText, "third title"); +``` + When the value of `#markdown-input` is `**this is bold**`, `convertMarkdown()` should return `this is bold`. ```js @@ -279,17 +321,18 @@ assert.lengthOf(preview.children, 1) assert.equal(strongs[0].innerText, "this is bold"); ``` -When the value of `#markdown-input` is `__this is bold__`, `convertMarkdown()` should return `this is bold`. +When the value of `#markdown-input` is `**this is bold**\n**this is also bold**`, `convertMarkdown()` should return `this is boldthis is also bold`. ```js const input = document.querySelector("#markdown-input"); -input.value = "__this is bold__"; +input.value = "**this is bold**\n**this is also bold**"; const testDiv = document.createElement("div"); testDiv.innerHTML = convertMarkdown(); const strongs = testDiv.querySelectorAll("strong"); -assert.lengthOf(strongs, 1); -assert.lengthOf(testDiv.children, 1); +assert.lengthOf(strongs, 2); +assert.lengthOf(testDiv.children, 2); assert.equal(strongs[0].innerText, "this is bold"); +assert.equal(strongs[1].innerText, "this is also bold"); ``` When the value of `#markdown-input` is `__this is bold__`, `this is bold` should be displayed inside `#html-output`. @@ -320,6 +363,20 @@ assert.lengthOf(preview.children, 1) assert.equal(strongs[0].innerText, "this is bold"); ``` +When the value of `#markdown-input` is `__this is bold__\n__this is also bold__`, `convertMarkdown()` should return `this is boldthis is also bold`. + +```js +const input = document.querySelector("#markdown-input"); +input.value = "__this is bold__\n__this is also bold__"; +const testDiv = document.createElement("div"); +testDiv.innerHTML = convertMarkdown(); +const strongs = testDiv.querySelectorAll("strong"); +assert.lengthOf(strongs, 2); +assert.lengthOf(testDiv.children, 2); +assert.equal(strongs[0].innerText, "this is bold"); +assert.equal(strongs[1].innerText, "this is also bold"); +``` + When the value of `#markdown-input` is `*this is italic*`, `convertMarkdown()` should return `this is italic`. ```js @@ -361,6 +418,20 @@ assert.lengthOf(preview.children, 1); assert.equal(italics[0].innerText, "this is italic"); ``` +When the value of `#markdown-input` is `*this is italic*\n*this is also italic*`, `convertMarkdown()` should return `this is italicthis is also italic`. + +```js +const input = document.querySelector("#markdown-input"); +input.value = "*this is italic*\n*this is also italic*"; +const testDiv = document.createElement("div"); +testDiv.innerHTML = convertMarkdown(); +const italics = testDiv.querySelectorAll("em"); +assert.lengthOf(italics, 2); +assert.lengthOf(testDiv.children, 2); +assert.equal(italics[0].innerText, "this is italic"); +assert.equal(italics[1].innerText, "this is also italic"); +``` + When the value of `#markdown-input` is `_this is italic_`, `convertMarkdown()` should return `this is italic`. ```js @@ -402,6 +473,20 @@ assert.lengthOf(preview.children, 1); assert.equal(italics[0].innerText, "this is italic"); ``` +When the value of `#markdown-input` is `_this is italic_\n_this is also italic_`, `convertMarkdown()` should return `this is italicthis is also italic`. + +```js +const input = document.querySelector("#markdown-input"); +input.value = "_this is italic_\n_this is also italic_"; +const testDiv = document.createElement("div"); +testDiv.innerHTML = convertMarkdown(); +const italics = testDiv.querySelectorAll("em"); +assert.lengthOf(italics, 2); +assert.lengthOf(testDiv.children, 2); +assert.equal(italics[0].innerText, "this is italic"); +assert.equal(italics[1].innerText, "this is also italic"); +``` + When the value of `#markdown-input` is either `# **title 1**` or `# __title 1__`, `convertMarkdown()` should return `

title 1

`. ```js @@ -529,6 +614,22 @@ assert.equal(imgs[0].alt, "alt-text"); assert.isTrue(imgs[0].src.endsWith("image-source")); ``` +When the value of `#markdown-input` is `![alt-text](image-source)\n![alt-text-2](image-source-2)`, `convertMarkdown()` should return `alt-textalt-text-2`. + +```js +const input = document.querySelector("#markdown-input"); +input.value = "!![alt-text](image-source)\n![alt-text-2](image-source-2)"; +const testDiv = document.createElement("div"); +testDiv.innerHTML = convertMarkdown(); +const imgs = testDiv.querySelectorAll("img"); +assert.lengthOf(testDiv.children, 2); +assert.lengthOf(imgs, 2); +assert.equal(imgs[0].alt, "alt-text"); +assert.isTrue(imgs[0].src.endsWith("image-source")); +assert.equal(imgs[1].alt, "alt-text-2"); +assert.isTrue(imgs[1].src.endsWith("image-source-2")); +``` + When the value of `#markdown-input` is `[link text](URL)`, `convertMarkdown()` should return `link text`. ```js @@ -573,6 +674,22 @@ assert.isTrue(anchors[0].href.endsWith("URL")); assert.equal(anchors[0].innerText, "link text"); ``` +When the value of `#markdown-input` is `[link text](URL)\n[link text 2](URL2)`, `convertMarkdown()` should return `link textlink text 2`. + +```js +const input = document.querySelector("#markdown-input"); +input.value = "[link text](URL)\n[link text 2](URL2)"; +const testDiv = document.createElement("div"); +testDiv.innerHTML = convertMarkdown(); +const anchors = testDiv.querySelectorAll("a"); +assert.lengthOf(testDiv.children, 2); +assert.lengthOf(anchors, 2); +assert.isTrue(anchors[0].href.endsWith("URL")); +assert.equal(anchors[0].innerText, "link text"); +assert.isTrue(anchors[1].href.endsWith("URL2")); +assert.equal(anchors[1].innerText, "link text 2"); +``` + When the value of `#markdown-input` is `> this is a quote`, `convertMarkdown()` should return `
this is a quote
`. ```js @@ -614,6 +731,21 @@ assert.lengthOf(quotes, 1); assert.equal(quotes[0].innerText, "this is a quote"); ``` +When the value of `#markdown-input` is `> this is a quote\n> this is another quote`, `convertMarkdown()` should return `
this is a quote
this is another quote
`. + +```js +const input = document.querySelector("#markdown-input"); +input.value = "> this is a quote\n> this is another quote"; +const testDiv = document.createElement("div"); +testDiv.innerHTML = convertMarkdown(); +const quotes = testDiv.querySelectorAll("blockquote"); +assert.lengthOf(testDiv.children, 2); +assert.lengthOf(quotes, 2); +assert.equal(quotes[0].innerText, "this is a quote"); +assert.equal(quotes[1].innerText, "this is another quote"); +``` + + When the value of `#markdown-input` is `some text > not a quote anymore`, `convertMarkdown()` should not convert `> not a quote anymore` into a `blockquote` element. ```js