From 9f9b4bbb84082e62bf0ff09b0a825b00d35f664e Mon Sep 17 00:00:00 2001 From: jhauga Date: Sun, 2 Nov 2025 15:32:31 -0500 Subject: [PATCH] improve example in update-code-from-shorthand --- .../update-code-from-shorthand.instructions.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/instructions/update-code-from-shorthand.instructions.md b/instructions/update-code-from-shorthand.instructions.md index 8d68cc9..aac9263 100644 --- a/instructions/update-code-from-shorthand.instructions.md +++ b/instructions/update-code-from-shorthand.instructions.md @@ -93,8 +93,10 @@ solution for the goal. ```bash [user prompt] -UPDATE CODE FROM SHORTHAND -script.js +UPDATE CODE FROM SHORTHAND +#file:script.js +Use #file:index.html:94-99 to see where converted +markdown to html will be parsed `id="a"`. ``` ### Code File @@ -108,8 +110,18 @@ var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { let data = this.responseText; + let a = document.getElementById("a"); + let output = ""; // start-shorthand - ()=> apply_html_to_parsed_markdown(data); + ()=> let apply_html_to_parsed_markdown = (md) => { + ()=> md.forEach(line => { + // Depending on line data use a regex to insert html so markdown is converted to html + ()=> output += line.replace(/^(regex to add html elements from markdonw line)(.*)$/g, $1$1); + }); + // Output the converted file from markdown to html. + return output; + }; + ()=>a.innerHTML = apply_html_to_parsed_markdown(data); // end-shorthand } };