improve example in update-code-from-shorthand

This commit is contained in:
jhauga 2025-11-02 15:32:31 -05:00
parent 002cbc3607
commit 9f9b4bbb84

View File

@ -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
}
};