Skip to content

Commit a0316e5

Browse files
committed
loading properly in the browser
1 parent 5f2e2e2 commit a0316e5

File tree

6 files changed

+175
-107
lines changed

6 files changed

+175
-107
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,21 @@ _Added in v1.1.0_
5454

5555
To use this package in the browser, you need to load Prettier's standalone bundle before loading the build provided in this package.
5656

57-
```html
58-
<script src="https://unpkg.com/prettier@latest"></script>
59-
<script
60-
type="module"
61-
src="https://unpkg.com/prettier-plugin-solidity@latest"
62-
></script>
63-
```
64-
6557
Prettier's unpkg field points to `https://unpkg.com/prettier/standalone.js`, in a similar way this plugin points to `https://unpkg.com/prettier-plugin-solidity/dist/standalone.js`.
6658

6759
Once the scripts are loaded you will have access the globals `prettier` and `prettierPlugins`.
6860

6961
We follow Prettier's strategy for populating their plugins in the object `prettierPlugins`, you can load other plugins like `https://unpkg.com/[email protected]/parser-markdown.js` and Prettier will have access to multiple parsers.
7062

7163
```html
72-
<script>
64+
<script type="module">
65+
const prettier = await import(
66+
'https://unpkg.com/prettier-plugin-solidity@latest'
67+
);
68+
const prettierSolidity = await import(
69+
'https://unpkg.com/prettier-plugin-solidity@latest'
70+
);
71+
7372
async function format(code) {
7473
return await prettier.format(code, {
7574
parser: 'slang-solidity',

0 commit comments

Comments
 (0)