Skip to content

Commit

Permalink
GFM checkbox for /tools/render-markdown
Browse files Browse the repository at this point in the history
To help investigate #88
  • Loading branch information
simonw committed Jan 27, 2024
1 parent 05d1d8a commit 26943e5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions templates/pages/tools/render-markdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@
<h1>Render Markdown</h1>
<p>Using GitHub's API, see <a href="/til/til/markdown_github-markdown-api.md">Rendering Markdown with the GitHub Markdown API</a></p>
<p><textarea id="input" style="width: 80%; height: 10em"></textarea></p>
<p><button>Render</button> <label><input type="checkbox" id="strip_hidden" checked> Strip hidden and cleanup HTML</label></p>
<p>
<button>Render</button>
<label><input type="checkbox" id="strip_hidden" checked> Strip hidden and cleanup HTML</label>
<label><input type="checkbox" id="gfm_mode"> Use GitHub Flavored Markdown (GFM)</label>
</p>
<p><textarea id="output" style="width: 80%; height: 10em"></textarea></p>
<div id="preview"></div>
<script>
Expand Down Expand Up @@ -218,12 +222,13 @@ <h1>Render Markdown</h1>
});

async function render(markdown) {
const mode = document.getElementById('gfm_mode').checked ? 'gfm' : 'markdown';
return (await fetch('https://api.github.com/markdown', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({'mode': 'markdown', 'text': markdown})
body: JSON.stringify({'mode': mode, 'text': markdown})
})).text();
}

Expand Down

0 comments on commit 26943e5

Please sign in to comment.