Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support html formatting #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as monaco from './src/monaco/editor/editor.main.js';

import prettier from './src/prettier.js';
import prettierBabel from './src/prettier-babel.js';
import prettierHtml from './src/prettier-html.js';

const sheet = document.createElement('style');
document.head.appendChild(sheet);
Expand Down Expand Up @@ -72,6 +73,7 @@ export default (options) => {
...editorDefaults,
...restOfOptions,
});
const language = editor.getModel().getModeId();

// Import themes directly from the amazing collection by @brijeshb42
// https://raw.githubusercontent.com/brijeshb42/monaco-themes/master/themes
Expand Down Expand Up @@ -99,8 +101,8 @@ export default (options) => {
const pos = editor.getPosition();

const prettyVal = prettier.formatWithCursor(val, {
parser: 'babel',
plugins: prettierBabel,
parser: language === 'html' ? 'html' : 'babel',
plugins: [language === 'html' ? prettierHtml : prettierBabel],
cursorOffset: computeOffset(val, pos),
});

Expand Down
567 changes: 312 additions & 255 deletions index.min.js

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions src/prettier-html.js

Large diffs are not rendered by default.