-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding in support for jsDelivr
- Loading branch information
Showing
1 changed file
with
49 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,28 @@ | |
[](https://github.com/jaredwray/writr/actions/workflows/tests.yml) | ||
[](https://github.com/jaredwray/writr/blob/master/LICENSE) | ||
[](https://codecov.io/gh/jaredwray/writr) | ||
[](https://www.jsdelivr.com/package/npm/writr) | ||
[](https://npmjs.com/package/writr) | ||
[](https://npmjs.com/package/writr) | ||
|
||
# Features | ||
* Removes the remark / unified complexity and easy to use. | ||
* Built in caching 💥 making it render very fast when there isnt a change | ||
* Frontmatter support built in by default. :tada: | ||
* Easily Render to `React` or `HTML`. | ||
* Generates a Table of Contents for your markdown files (remark-toc). | ||
* Slug generation for your markdown files (rehype-slug). | ||
* Code Highlighting (rehype-highlight). | ||
* Math Support (rehype-katex). | ||
* Markdown to HTML (rehype-stringify). | ||
* Github Flavor Markdown (remark-gfm). | ||
* Emoji Support (remark-emoji). | ||
* MDX Support (remark-mdx). | ||
* Built in Hooks for adding code to render pipeline. | ||
|
||
# Table of Contents | ||
- [Features](#features) | ||
- [ESM and Node Version Support](#esm-and-node-version-support) | ||
- [Getting Started](#getting-started) | ||
- [Running via Browser as an ESM Module](#running-via-browser-as-an-esm-module) | ||
- [API](#api) | ||
- [`new Writr(arg?: string | WritrOptions, options?: WritrOptions)`](#new-writrarg-string--writroptions-options-writroptions) | ||
- [`.content`](#content) | ||
|
@@ -31,29 +46,10 @@ | |
- [`.saveToFile(filePath: string): Promise<void>`](#savetofilefilepath-string-promisevoid) | ||
- [`.saveToFileSync(filePath: string): void`](#savetofilesyncfilepath-string-void) | ||
- [Hooks](#hooks) | ||
- [ESM and Node Version Support](#esm-and-node-version-support) | ||
- [Code of Conduct and Contributing](#code-of-conduct-and-contributing) | ||
- [License](#license) | ||
|
||
|
||
# Features | ||
* Removes the remark / unified complexity and easy to use. | ||
* Built in caching 💥 making it render very fast when there isnt a change | ||
* Frontmatter support built in by default. :tada: | ||
* Easily Render to `React` or `HTML`. | ||
* Generates a Table of Contents for your markdown files (remark-toc). | ||
* Slug generation for your markdown files (rehype-slug). | ||
* Code Highlighting (rehype-highlight). | ||
* Math Support (rehype-katex). | ||
* Markdown to HTML (rehype-stringify). | ||
* Github Flavor Markdown (remark-gfm). | ||
* Emoji Support (remark-emoji). | ||
* MDX Support (remark-mdx). | ||
* Built in Hooks for adding code to render pipeline. | ||
|
||
# ESM and Node Version Support | ||
|
||
This package is ESM only and tested on the current lts version and its previous. Please don't open issues for questions regarding CommonJS / ESM or previous Nodejs versions. To learn more about using ESM please read this from `sindresorhus`: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
|
||
# Getting Started | ||
|
||
```bash | ||
|
@@ -101,6 +97,33 @@ const writr = new Writr(`# Hello World ::-):\n\n This is a test.`, writrOptions) | |
const html = await writr.render(options); // <h1>Hello World ::-):</h1><p>This is a test.</p> | ||
``` | ||
|
||
# Running via Browser as an ESM Module | ||
|
||
You can also run Writr via the browser. Here is an example of how to do that. | ||
|
||
```html | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Writr Example</title> | ||
<script type="module"> | ||
import {Writr} from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm' | ||
const writr = new Writr(`# Hello World ::-):\n\n This is a test.`); | ||
writr.render().then(html => { | ||
document.body.innerHTML = html; | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> | ||
``` | ||
|
||
This will render the markdown to HTML and display it in the body of the page. | ||
|
||
# API | ||
|
||
## `new Writr(arg?: string | WritrOptions, options?: WritrOptions)` | ||
|
@@ -412,6 +435,10 @@ export type loadFromFileData = { | |
This is called when you call `loadFromFile`, `loadFromFileSync`. | ||
# ESM and Node Version Support | ||
This package is ESM only and tested on the current lts version and its previous. Please don't open issues for questions regarding CommonJS / ESM or previous Nodejs versions. To learn more about using ESM please read this from `sindresorhus`: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
# Code of Conduct and Contributing | ||
[Code of Conduct](CODE_OF_CONDUCT.md) and [Contributing](CONTRIBUTING.md) guidelines. | ||
|