├── .browserslistrc ├── .editorconfig ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── .prettierignore ├── .prettierrc ├── LICENSE ├── README.md ├── babel.config.js ├── package.json ├── public ├── favicon.ico ├── img │ └── icons │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── apple-touch-icon-120x120.png │ │ ├── apple-touch-icon-152x152.png │ │ ├── apple-touch-icon-180x180.png │ │ ├── apple-touch-icon-60x60.png │ │ ├── apple-touch-icon-76x76.png │ │ ├── apple-touch-icon.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── msapplication-icon-144x144.png │ │ └── opengraph.png ├── index.html ├── manifest.json ├── robots.txt └── sw-events.js ├── scripts └── browserified-prettyhtml.js ├── src ├── App.vue ├── EventBus.js ├── assets │ ├── logo.png │ ├── screenshot.jpg │ └── styles.css ├── components │ ├── AppExampleButtons.vue │ └── AppToggle.vue ├── main.js ├── registerServiceWorker.js ├── utils │ └── Examples.js └── workers │ ├── index.js │ └── prettyhtml.worker.js ├── tailwind.js ├── vue.config.js └── yarn.lock /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true, 5 | }, 6 | globals: { 7 | preval: true, 8 | }, 9 | extends: ["plugin:vue/essential", "@vue/prettier"], 10 | rules: { 11 | "no-console": process.env.NODE_ENV === "production" ? "error" : "off", 12 | "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off", 13 | }, 14 | parserOptions: { 15 | parser: "babel-eslint", 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | public/prettyhtml.browserified.min.js 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | 15 | # Editor directories and files 16 | .idea 17 | .vscode 18 | *.suo 19 | *.ntvs* 20 | *.njsproj 21 | *.sln 22 | *.sw* 23 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | const purgecss = require("@fullhuman/postcss-purgecss"); 2 | const autoprefixer = require("autoprefixer"); 3 | const whitelister = require("purgecss-whitelister"); 4 | const prismcss = whitelister("./src/assets/styles.css"); 5 | module.exports = { 6 | plugins: [ 7 | require("tailwindcss")("./tailwind.js"), 8 | process.env.NODE_ENV === "production" && 9 | purgecss({ 10 | content: ["./src/**/*.vue"], 11 | whitelist: ["html", "body"].concat(prismcss), 12 | extractors: [ 13 | { 14 | extractor: class TailwindExtractor { 15 | static extract(content) { 16 | return content.match(/[A-z0-9-:/]+/g) || []; 17 | } 18 | }, 19 | extensions: ["vue"], 20 | }, 21 | ], 22 | }), 23 | autoprefixer, 24 | ], 25 | }; 26 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json 2 | node_modules 3 | dist 4 | coverage 5 | public 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "trailingComma": "all", 6 | "htmlWhitespaceSensitivity": "ignore", 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Mesut Koca (https://mesutkoca.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PrettyHtml 2 | 3 | Offline Formatter for your Angular, Vue, Svelte or pure HTML5 codes. 4 | 5 | Live: [prettyhtml.netlify.com](https://prettyhtml.netlify.com) 6 | 7 | ![Screenshot of prettyhtml](src/assets/screenshot.jpg) 8 | 9 | ## About 10 | 11 | Uses browserified version of the [prettyhtml](https://ghub.io/@starptech/prettyhtml) 12 | (👍) 13 | 14 | ## Project setup 15 | 16 | ``` 17 | yarn install 18 | ``` 19 | 20 | ### Compiles and hot-reloads for development 21 | 22 | ``` 23 | yarn run serve 24 | ``` 25 | 26 | ### Compiles and minifies for production 27 | 28 | ``` 29 | yarn run build 30 | ``` 31 | 32 | ### Lints and fixes files 33 | 34 | ``` 35 | yarn run lint 36 | ``` 37 | 38 | ### Run the unit tests 39 | 40 | ``` 41 | yarn run test:unit 42 | ``` 43 | 44 | ## Dependencies 45 | 46 | - [vue-prism-editor](https://ghub.io/vue-prism-editor): A dead simple code editor with syntax highlighting and line numbers. 47 | - [tailwindcss](https://ghub.io/tailwindcss): A utility-first CSS framework for rapidly building custom user interfaces. 48 | - [vue](https://ghub.io/vue): Reactive, component-oriented view layer for modern web interfaces. 49 | 50 | ## Licence 51 | 52 | [MIT](https://opensource.org/licenses/MIT) © [Mesut Koca](https://mesutkoca.com) 53 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/app"], 3 | plugins: ["preval"], 4 | }; 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pretty-html", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "yarn bundle && vue-cli-service build", 8 | "lint": "vue-cli-service lint", 9 | "bundle": "node ./scripts/browserified-prettyhtml.js" 10 | }, 11 | "dependencies": { 12 | "clipboard": "^2.0.4", 13 | "prismjs": "^1.16.0", 14 | "register-service-worker": "^1.6.2", 15 | "tailwindcss": "^0.7.4", 16 | "vue": "^2.6.10", 17 | "vue-prism-editor": "^0.2.0" 18 | }, 19 | "devDependencies": { 20 | "@fullhuman/postcss-purgecss": "^1.2.0", 21 | "@starptech/prettyhtml": "^0.9.0", 22 | "@vue/cli-plugin-babel": "^3.7.0", 23 | "@vue/cli-plugin-eslint": "^3.7.0", 24 | "@vue/cli-plugin-pwa": "^3.7.0", 25 | "@vue/cli-service": "3.7.0", 26 | "@vue/eslint-config-prettier": "^4.0.1", 27 | "babel-plugin-preval": "^3.0.1", 28 | "browserify": "^16.2.3", 29 | "purgecss-whitelister": "^2.4.0", 30 | "uglify-es": "^3.3.9", 31 | "vue-template-compiler": "^2.6.10", 32 | "workerize-loader": "^1.0.4" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/favicon.ico -------------------------------------------------------------------------------- /public/img/icons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/android-chrome-192x192.png -------------------------------------------------------------------------------- /public/img/icons/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/android-chrome-512x512.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/apple-touch-icon.png -------------------------------------------------------------------------------- /public/img/icons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/favicon-16x16.png -------------------------------------------------------------------------------- /public/img/icons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/favicon-32x32.png -------------------------------------------------------------------------------- /public/img/icons/msapplication-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/msapplication-icon-144x144.png -------------------------------------------------------------------------------- /public/img/icons/opengraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/public/img/icons/opengraph.png -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | PrettyHtml - The formatter for the modern web 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 38 | 39 | 40 | 41 | 42 | 45 |
46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pretty-html", 3 | "short_name": "pretty-html", 4 | "icons": [ 5 | { 6 | "src": "/img/icons/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/img/icons/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "start_url": "/index.html", 17 | "display": "standalone", 18 | "background_color": "#ffffff", 19 | "theme_color": "#606f7b" 20 | } 21 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | -------------------------------------------------------------------------------- /public/sw-events.js: -------------------------------------------------------------------------------- 1 | //console.log("SW EVENTS LOADED!"); 2 | self.addEventListener("message", e => { 3 | const replyPort = e.ports[0]; 4 | const data = e.data; 5 | if (!data || !replyPort) return; 6 | if (replyPort && data.action === "skipWaiting") { 7 | e.waitUntil( 8 | self 9 | .skipWaiting() 10 | .then( 11 | () => replyPort.postMessage({ error: null }), 12 | error => replyPort.postMessage({ error }) 13 | ) 14 | ); 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /scripts/browserified-prettyhtml.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs") 2 | const path = require("path") 3 | const browserify = require("browserify") 4 | const uglify = require("uglify-es") 5 | 6 | const pkgName = "@starptech/prettyhtml" 7 | const pkgFileName = "prettyhtml.browserified.min.js" 8 | const pkgPath = path.resolve(__dirname, "../public/" + pkgFileName) 9 | const umdName = "prettyhtml" 10 | 11 | const b = browserify([require.resolve(pkgName)], { 12 | standalone: umdName, 13 | }) 14 | // ignore prettier 15 | b.ignore("prettier") 16 | 17 | b.bundle((err, buf) => { 18 | if (err) console.log(err) 19 | try { 20 | let bundledCode = buf.toString() 21 | const minifiedCode = uglify.minify(bundledCode).code 22 | fs.writeFileSync(pkgPath, minifiedCode, "utf-8") 23 | } catch (error) { 24 | console.log(error) 25 | } 26 | }) 27 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 269 | 270 | 369 | 370 | 396 | -------------------------------------------------------------------------------- /src/EventBus.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | export default new Vue({}); 3 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/src/assets/logo.png -------------------------------------------------------------------------------- /src/assets/screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Prettyhtml/pretty-html-web/41b0867b03b729f57ce67feae083f2fe2cc5e399/src/assets/screenshot.jpg -------------------------------------------------------------------------------- /src/assets/styles.css: -------------------------------------------------------------------------------- 1 | @tailwind preflight; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | .my-editor { 6 | background-color: #fafafa; 7 | } 8 | .prism-editor__code { 9 | margin-left: 8px; 10 | font-family: "Fira code", "Fira Mono", Consolas, Menlo, Courier, monospace; 11 | font-variant-ligatures: common-ligatures; 12 | font-size: 14px; 13 | line-height: 1.5; 14 | } 15 | 16 | /* Syntax highlighting */ 17 | .token.comment, 18 | .token.prolog, 19 | .token.doctype, 20 | .token.cdata { 21 | color: #90a4ae; 22 | } 23 | .token.punctuation { 24 | color: #9e9e9e; 25 | } 26 | .namespace { 27 | opacity: 0.7; 28 | } 29 | .token.property, 30 | .token.tag, 31 | .token.boolean, 32 | .token.number, 33 | .token.constant, 34 | .token.symbol, 35 | .token.deleted { 36 | color: #e91e63; 37 | } 38 | .token.selector, 39 | .token.attr-name, 40 | .token.string, 41 | .token.char, 42 | .token.builtin, 43 | .token.inserted { 44 | color: #4caf50; 45 | } 46 | .token.operator, 47 | .token.entity, 48 | .token.url, 49 | .language-css .token.string, 50 | .style .token.string { 51 | color: #795548; 52 | } 53 | .token.atrule, 54 | .token.attr-value, 55 | .token.keyword { 56 | color: #3f51b5; 57 | } 58 | .token.function { 59 | color: #f44336; 60 | } 61 | .token.regex, 62 | .token.important, 63 | .token.variable { 64 | color: #ff9800; 65 | } 66 | .token.important, 67 | .token.bold { 68 | font-weight: bold; 69 | } 70 | .token.italic { 71 | font-style: italic; 72 | } 73 | .token.entity { 74 | cursor: help; 75 | } 76 | -------------------------------------------------------------------------------- /src/components/AppExampleButtons.vue: -------------------------------------------------------------------------------- 1 | 29 | 39 | -------------------------------------------------------------------------------- /src/components/AppToggle.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 56 | 57 | 58 | 63 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | import "./registerServiceWorker"; 4 | 5 | import "prismjs"; 6 | // import "prismjs/themes/prism-tomorrow.css"; 7 | Vue.config.productionTip = false; 8 | 9 | new Vue({ 10 | render: h => h(App), 11 | }).$mount("#app"); 12 | -------------------------------------------------------------------------------- /src/registerServiceWorker.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | 3 | import { register } from "register-service-worker"; 4 | 5 | const skipWaiting = registration => { 6 | const worker = registration.waiting; 7 | if (!worker) { 8 | return Promise.resolve(); 9 | } 10 | 11 | console.log("[SW] Doing worker.skipWaiting()."); 12 | return new Promise((resolve, reject) => { 13 | const channel = new MessageChannel(); 14 | 15 | channel.port1.onmessage = event => { 16 | console.log("[SW] Done worker.skipWaiting()."); 17 | if (event.data.error) { 18 | reject(event.data.error); 19 | } else { 20 | resolve(event.data); 21 | } 22 | }; 23 | 24 | worker.postMessage({ action: "skipWaiting" }, [channel.port2]); 25 | }); 26 | }; 27 | 28 | let snackbar = null; 29 | let swe = null; 30 | let reloads = () => { 31 | skipWaiting(swe) 32 | .then(() => { 33 | window.location.reload(); 34 | }) 35 | .catch(err => { 36 | console.error(err); 37 | }); 38 | }; 39 | function showSnackbar() { 40 | if (snackbar == null) { 41 | snackbar = document.createElement("div"); 42 | document.body.appendChild(snackbar); 43 | } 44 | 45 | snackbar.innerHTML = ` 46 |
50 | New content is available. 51 | 54 |
`; 55 | snackbar.addEventListener("click", e => { 56 | if (e.target.nodeName === "BUTTON") { 57 | reloads(); 58 | } 59 | }); 60 | } 61 | 62 | if (process.env.NODE_ENV === "production") { 63 | register(`${process.env.BASE_URL}service-worker.js`, { 64 | ready() { 65 | console.log( 66 | "[SW] App is being served from cache by a service worker.\n" + 67 | "For more details, visit https://goo.gl/AFskqB", 68 | ); 69 | }, 70 | cached() { 71 | console.log("[SW] Content has been cached for offline use."); 72 | }, 73 | updated(registration) { 74 | console.log("[SW] New content is available; please refresh!."); 75 | swe = registration; 76 | showSnackbar(); 77 | }, 78 | offline() { 79 | console.log( 80 | "[SW] No internet connection found. App is running in offline mode.", 81 | ); 82 | }, 83 | error(error) { 84 | console.error("[SW] Error during service worker registration:", error); 85 | }, 86 | }); 87 | } 88 | -------------------------------------------------------------------------------- /src/utils/Examples.js: -------------------------------------------------------------------------------- 1 | export default { 2 | html: ` 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 |

Please sign in

11 | 12 | 13 |
14 | 17 |
18 | 19 |

© 2017-2018

20 |
21 | 22 | `, 23 | vue: ` 24 |
25 |
26 | 27 |
28 |