Skip to content

Commit e145859

Browse files
jhaugagemini-code-assist[bot]UziTech
authored
docs: browser example for marked on page data (#3864)
* docs: browser example for marked on page data * Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * docs: browser example to USING_ADVANCED.md * Update docs/USING_ADVANCED.md Applied suggestion. Thank you. Co-authored-by: Tony Brix <[email protected]> * docs: update menu, close user ex details --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Tony Brix <[email protected]>
1 parent af55876 commit e145859

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

docs/USING_ADVANCED.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,44 @@ Marked can be extended using [custom extensions](/using_pro#extensions). This is
111111
|[Typograf](https://github.com/laidrivm/marked-typograf)|[`marked-typograf`](https://www.npmjs.com/package/marked-typograf)|Use [typograf](https://www.npmjs.com/package/typograf) as a more powerful and extendable alternative to Smartypants for creating “smart” typographic punctuation, such as quotes and dashes.|
112112
|[XHTML](https://github.com/markedjs/marked-xhtml)|[`marked-xhtml`](https://www.npmjs.com/package/marked-xhtml)|Emit self-closing HTML tags for void elements (&lt;br/&gt;, &lt;img/&gt;, etc.) with a "/" as required by XHTML.|
113113

114+
<h2 id="user-examples">User Examples</h2>
115+
116+
<details>
117+
118+
<summary>Marked can render on-page content as markdown in the browser.</summary>
119+
120+
```html
121+
<!DOCTYPE html>
122+
<html>
123+
<head>
124+
<!-- Suggested stylesheet -->
125+
<link rel="stylesheet"
126+
href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.8.1/github-markdown.min.css"
127+
crossorigin="anonymous" referrerpolicy="no-referrer" />
128+
129+
<title>Marked for the full page</title>
130+
</head>
131+
132+
<body>
133+
<textarea id="markdown-source" style="display: none;">
134+
# Title
135+
136+
Lots of text using **markdown syntax.**
137+
</textarea>
138+
<div id="content" class="markdown-body"></div>
139+
140+
<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
141+
<script>
142+
const source = document.getElementById('markdown-source').value;
143+
144+
// Parse the markdown and render it into the content div.
145+
document.getElementById('content').innerHTML = marked.parse(source);
146+
</script>
147+
</body>
148+
</html>
149+
```
150+
</details>
151+
114152
<h2 id="inline">Inline Markdown</h2>
115153

116154
You can parse inline markdown by running markdown through `marked.parseInline`.

docs/_document.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@
259259
>Known Extensions</a
260260
>
261261
</li>
262+
<li>
263+
<a
264+
class="block hover:text-primary dark:hover:text-primary"
265+
href="/using_advanced#user-examples"
266+
>User Examples</a
267+
>
268+
</li>
262269
<li>
263270
<a
264271
class="block hover:text-primary dark:hover:text-primary"

0 commit comments

Comments
 (0)