Skip to content

Commit 1173631

Browse files
feat(prettierOnMarkdown): Forced prettier options to always have parser set to markdown when used.
1 parent 911fd9a commit 1173631

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

browser/components/CodeEditor.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,15 @@ export default class CodeEditor extends React.Component {
236236
[translateHotkey(hotkey.prettifyMarkdown)]: cm => {
237237
// Default / User configured prettier options
238238
const currentConfig = JSON.parse(self.props.prettierConfig)
239-
// Get current cursor position.
239+
240+
// Parser type will always need to be markdown so we override the option before use
241+
currentConfig.parser = 'markdown'
242+
243+
// Get current cursor position
240244
const cursorPos = cm.getCursor()
241245
currentConfig.cursorOffset = cm.doc.indexFromPos(cursorPos)
242246

243-
// Prettify contents of editor.
247+
// Prettify contents of editor
244248
const formattedTextDetails = prettier.formatWithCursor(cm.doc.getValue(), currentConfig)
245249

246250
const formattedText = formattedTextDetails.formatted

browser/main/lib/ConfigManager.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ export const DEFAULT_CONFIG = {
7171
"trailingComma": "es5",
7272
"tabWidth": 4,
7373
"semi": false,
74-
"singleQuote": true,
75-
"parser":"markdown"
74+
"singleQuote": true
7675
}`
7776

7877
},

0 commit comments

Comments
 (0)