From 0c6333e6041a0354a46e65af092a8d484f9da580 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 1 Dec 2016 12:55:00 -0800 Subject: [PATCH] Add font settings for markdown preview (#16302) Fixes #4641 Adds basic settings for controlling the markdown preview font. We already support this with custom css, but these settings are similar to what the editor and integrated terminal expose and allow for a few basic customizations. Custom style sheets will override these. --- extensions/markdown/package.json | 15 +++++++++++++++ extensions/markdown/package.nls.json | 5 ++++- extensions/markdown/src/extension.ts | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/extensions/markdown/package.json b/extensions/markdown/package.json index 295f09a810c..43a245bd04b 100644 --- a/extensions/markdown/package.json +++ b/extensions/markdown/package.json @@ -130,6 +130,21 @@ ], "default": "hide", "description": "%markdown.previewFrontMatter.dec%" + }, + "markdown.preview.fontFamily": { + "type": "string", + "default": "'Segoe WPC', 'Segoe UI', 'SFUIText-Light', 'HelveticaNeue-Light'", + "description": "%markdown.preview.fontFamily.desc%" + }, + "markdown.preview.fontSize": { + "type": "number", + "default": 14, + "description": "%markdown.preview.fontSize.desc%" + }, + "markdown.preview.lineHeight": { + "type": "number", + "default": 1.6, + "description": "%markdown.preview.lineHeight.desc%" } } } diff --git a/extensions/markdown/package.nls.json b/extensions/markdown/package.nls.json index dbdafe5963f..d14a486d977 100644 --- a/extensions/markdown/package.nls.json +++ b/extensions/markdown/package.nls.json @@ -3,5 +3,8 @@ "markdown.previewSide.title" : "Open Preview to the Side", "markdown.showSource.title" : "Show Source", "markdown.styles.dec": "A list of URLs or local paths to CSS style sheets to use from the markdown preview. Relative paths are interpreted relative to the folder open in the explorer. If there is no open folder, they are interpreted relative to the location of the markdown file. All '\\' need to be written as '\\\\'.", - "markdown.previewFrontMatter.dec": "Sets how YAML front matter should be rendered in the markdown preview. 'hide' removes the front matter. Otherwise, the front matter is treated as markdown content" + "markdown.previewFrontMatter.dec": "Sets how YAML front matter should be rendered in the markdown preview. 'hide' removes the front matter. Otherwise, the front matter is treated as markdown content.", + "markdown.preview.fontFamily.desc": "Controls the font family used in the markdown preview.", + "markdown.preview.fontSize.desc": "Controls the font size in pixels used in the markdown preview.", + "markdown.preview.lineHeight.desc": "Controls the line height used in the markdown preview. This number is relative to the font size." } \ No newline at end of file diff --git a/extensions/markdown/src/extension.ts b/extensions/markdown/src/extension.ts index 732f549a411..ca55ce16014 100644 --- a/extensions/markdown/src/extension.ts +++ b/extensions/markdown/src/extension.ts @@ -223,6 +223,22 @@ class MDDocumentContentProvider implements vscode.TextDocumentContentProvider { return []; } + private getSettingsOverrideStyles(): string { + const previewSettings = vscode.workspace.getConfiguration('markdown')['preview']; + if (!previewSettings) { + return ''; + } + const {fontFamily, fontSize, lineHeight} = previewSettings; + return [ + ''].join('\n'); + } + public provideTextDocumentContent(uri: vscode.Uri): Thenable { return vscode.workspace.openTextDocument(vscode.Uri.parse(uri.query)).then(document => { const scrollBeyondLastLine = vscode.workspace.getConfiguration('editor')['scrollBeyondLastLine']; @@ -233,6 +249,7 @@ class MDDocumentContentProvider implements vscode.TextDocumentContentProvider { '', ``, ``, + this.getSettingsOverrideStyles(), this.computeCustomStyleSheetIncludes(uri), ``, '', -- GitLab