improve example in update-code-from-shorthand
This commit is contained in:
parent
002cbc3607
commit
9f9b4bbb84
@ -94,7 +94,9 @@ solution for the goal.
|
||||
```bash
|
||||
[user prompt]
|
||||
UPDATE CODE FROM SHORTHAND
|
||||
script.js
|
||||
#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
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user