Skip to content

Instantly share code, notes, and snippets.

@dougluce
Created November 28, 2022 18:57
Show Gist options
  • Save dougluce/c890785429493b1c9288ca750b8f62be to your computer and use it in GitHub Desktop.
Save dougluce/c890785429493b1c9288ca750b8f62be to your computer and use it in GitHub Desktop.
Markdown web page -- text in a hidden div, convert witha little script...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://unpkg.com/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://unpkg.com/showdown/dist/showdown.min.js" crossorigin></script>
</head>
<body>
<div id="source" style="display: none; visibility: hidden;">
# Markdown syntax guide
## Headers
# This is a Heading h1
## This is a Heading h2
###### This is a Heading h6
## Emphasis
*This text will be italic*
_This will also be italic_
**This text will be bold**
__This will also be bold__
_You **can** combine them_
## Lists
### Unordered
* Item 1
* Item 2
* Item 2a
* Item 2b
### Ordered
1. Item 1
1. Item 2
1. Item 3
1. Item 3a
1. Item 3b
## Images
![This is a alt text.](/image/sample.png "This is a sample image.")
## Links
You may be using [Markdown Live Preview](https://markdownlivepreview.com/).
## Blockquotes
> Markdown is a lightweight markup language with plain-text-formatting syntax, created in 2004 by John Gruber with Aaron Swartz.
>
>> Markdown is often used to format readme files, for writing messages in online discussion forums, and to create rich text using a plain text editor.
## Tables
| Left columns | Right columns |
| ------------- |:-------------:|
| left foo | right foo |
| left bar | right bar |
| left baz | right baz |
## Blocks of code
```
let message = 'Hello world';
alert(message);
```
## Inline code
This web site is using `javascript`
</div>
<main class="container">
<div class="row g-5">
<div class="col-md-8">
<article class="blog-post" id="target">
</article>
</div>
</div>
</main>
<script>
const source = document.getElementById('source')
const target = document.getElementById('target')
const converter = new showdown.Converter()
target.innerHTML = converter.makeHtml(source.innerHTML)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment