diff --git a/build/npm/postinstall.js b/build/npm/postinstall.js index 1a73f1e0ab9..37af6ff2a41 100644 --- a/build/npm/postinstall.js +++ b/build/npm/postinstall.js @@ -11,6 +11,7 @@ const extensions = [ 'vscode-colorize-tests', 'json', 'configuration-editing', + 'markdown', 'typescript', 'php', 'javascript', diff --git a/extensions/markdown/markdown.configuration.json b/extensions/markdown/markdown.configuration.json new file mode 100644 index 00000000000..3bf082d18e5 --- /dev/null +++ b/extensions/markdown/markdown.configuration.json @@ -0,0 +1,26 @@ +{ + "comments": { + // symbol used for single line comment. Remove this entry if your language does not support line comments + "lineComment": "//", + // symbols used for start and end a block comment. Remove this entry if your language does not support block comments + "blockComment": [ + "/*", + "*/" + ] + }, + // symbols used as brackets + "brackets": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ] + ] +} \ No newline at end of file diff --git a/extensions/markdown/media/markdown.css b/extensions/markdown/media/markdown.css new file mode 100644 index 00000000000..218b8c407a0 --- /dev/null +++ b/extensions/markdown/media/markdown.css @@ -0,0 +1,163 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +body { + font-family: "Segoe WPC", "Segoe UI", "SFUIText-Light", "HelveticaNeue-Light", sans-serif, "Droid Sans Fallback"; + font-size: 14px; + padding-left: 12px; + line-height: 22px; +} + +img { + max-width: 100%; + max-height: 100%; +} + +a { + color: #4080D0; + text-decoration: none; +} + +a:focus, +input:focus, +select:focus, +textarea:focus { + outline: 1px solid -webkit-focus-ring-color; + outline-offset: -1px; +} + +hr { + border: 0; + height: 2px; + border-bottom: 2px solid; +} + +h1 { + padding-bottom: 0.3em; + line-height: 1.2; + border-bottom-width: 1px; + border-bottom-style: solid; +} + +h1, h2, h3 { + font-weight: normal; +} + +a:hover { + color: #4080D0; + text-decoration: underline; +} + +table { + border-collapse: collapse; +} + +table > thead > tr > th { + text-align: left; + border-bottom: 1px solid; +} + +table > thead > tr > th, +table > thead > tr > td, +table > tbody > tr > th, +table > tbody > tr > td { + padding: 5px 10px; +} + +table > tbody > tr + tr > td { + border-top: 1px solid; +} + +blockquote { + margin: 0 7px 0 5px; + padding: 0 16px 0 10px; + border-left: 5px solid; +} + +code { + font-family: Menlo, Monaco, Consolas, "Droid Sans Mono", "Courier New", monospace, "Droid Sans Fallback"; + font-size: 14px; + line-height: 19px; +} + +.mac code { + font-size: 12px; + line-height: 18px; +} + +code > div { + padding: 16px; + border-radius: 3px; + overflow: auto; +} + +/** Theming */ + +.vs { + color: rgb(30, 30, 30); +} + +.vs-dark { + color: #DDD; +} + +.hc-black { + color: white; +} + +.vs code { + color: #A31515; +} + +.vs-dark code { + color: #D7BA7D; +} + +.vs code > div { + background-color: rgba(220, 220, 220, 0.4); +} + +.vs-dark code > div { + background-color: rgba(10, 10, 10, 0.4); +} + +.hc-black code > div { + background-color: rgb(0, 0, 0); +} + +.hc-black h1 { + border-color: rgb(0, 0, 0); +} + +.vs table > thead > tr > th { + border-color: rgba(0, 0, 0, 0.69); +} + +.vs-dark table > thead > tr > th { + border-color: rgba(255, 255, 255, 0.69); +} + +.vs h1, +.vs hr, +.vs table > tbody > tr + tr > td { + border-color: rgba(0, 0, 0, 0.18); +} + +.vs-dark h1, +.vs-dark hr, +.vs-dark table > tbody > tr + tr > td { + border-color: rgba(255, 255, 255, 0.18); +} + +.vs blockquote, +.vs-dark blockquote { + background: rgba(127, 127, 127, 0.1); + border-color: rgba(0, 122, 204, 0.5); +} + +.hc-black blockquote { + background: transparent; + border-color: #fff; +} \ No newline at end of file diff --git a/extensions/markdown/media/tomorrow.css b/extensions/markdown/media/tomorrow.css new file mode 100644 index 00000000000..8f099dfa973 --- /dev/null +++ b/extensions/markdown/media/tomorrow.css @@ -0,0 +1,71 @@ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ + +/* Tomorrow Comment */ +.hljs-comment, +.hljs-quote { + color: #8e908c; +} + +/* Tomorrow Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-deletion { + color: #c82829; +} + +/* Tomorrow Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-meta, +.hljs-link { + color: #f5871f; +} + +/* Tomorrow Yellow */ +.hljs-attribute { + color: #eab700; +} + +/* Tomorrow Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #718c00; +} + +/* Tomorrow Blue */ +.hljs-title, +.hljs-section { + color: #4271ae; +} + +/* Tomorrow Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #8959a8; +} + +.hljs { + display: block; + overflow-x: auto; + color: #4d4d4c; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} \ No newline at end of file diff --git a/extensions/markdown/package.json b/extensions/markdown/package.json index 246acdcc002..9c3d54b6a9b 100644 --- a/extensions/markdown/package.json +++ b/extensions/markdown/package.json @@ -1,12 +1,77 @@ { - "name": "markdown", - "version": "0.1.0", - "publisher": "vscode", - "engines": { "vscode": "*" }, - "contributes": { - "snippets": [{ + "name": "vscode-markdown", + "displayName": "VS Code Markdown", + "description": "Markdown for VS Code", + "version": "0.2.0", + "publisher": "Microsoft", + "engines": { + "vscode": "^1.0.0" + }, + "main": "./out/extension", + "categories": [ + "Languages" + ], + "activationEvents": [ + "onCommand:extension.previewMarkdown", + "onCommand:extension.previewMarkdownSide" + ], + "contributes": { + "languages": [ + { + "id": "markdown", + "aliases": [ + "Markdown", + "markdown" + ], + "extensions": [ + ".md", + ".mdown", + ".markdown", + ".markdn" + ], + "configuration": "./markdown.configuration.json" + } + ], + "grammars": [ + { + "language": "markdown", + "scopeName": "text.html.markdown", + "path": "./syntaxes/markdown.tmLanguage" + } + ], + "commands": [ + { + "command": "extension.previewMarkdown", + "title": "%markdown.previewMarkdown.title%" + }, + { + "command": "extension.previewMarkdownSide", + "title": "%markdown.previewMarkdownSide.title%" + } + ], + "keybindings": [ + { + "command": "extension.previewMarkdown", + "key": "shift+ctrl+v", + "mac": "shift+cmd+v" + }, + { + "command": "extension.previewMarkdownSide", + "key": "ctrl+k v", + "mac": "cmd+k v" + } + ], + "snippets": [{ "language": "markdown", "path": "./snippets/markdown.json" }] - } + }, + "scripts": { + "vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:markdown ./tsconfig.json" + }, + "dependencies": { + "highlight.js": "^9.3.0", + "markdown-it": "^6.0.1", + "markdown-it-named-headers": "0.0.4" + } } \ No newline at end of file diff --git a/extensions/markdown/package.nls.json b/extensions/markdown/package.nls.json new file mode 100644 index 00000000000..ecfbb9272a4 --- /dev/null +++ b/extensions/markdown/package.nls.json @@ -0,0 +1,4 @@ +{ + "markdown.previewMarkdown.title" : "Markdown: Toggle Preview", + "markdown.previewMarkdownSide.title" : "Markdown: Open Preview to the Side" +} \ No newline at end of file diff --git a/extensions/markdown/src/extension.ts b/extensions/markdown/src/extension.ts new file mode 100644 index 00000000000..fd0281510ac --- /dev/null +++ b/extensions/markdown/src/extension.ts @@ -0,0 +1,174 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + + 'use strict'; + +import * as vscode from 'vscode'; +import * as fs from 'fs'; +import * as path from 'path'; +import { ExtensionContext, TextDocumentContentProvider, EventEmitter, Event, Uri, TextDocument, ViewColumn } from "vscode"; + +const hljs = require('highlight.js'); +const mdnh = require('markdown-it-named-headers'); +const md = require('markdown-it')({ + html: true, + highlight: function (str, lang) { + if (lang && hljs.getLanguage(lang)) { + try { + return `
${hljs.highlight(lang, str, true).value}
`; + } catch (error) { } + } + return `
${md.utils.escapeHtml(str)}
`; + } +}).use(mdnh, {}); + +export function activate(context: ExtensionContext) { + let provider = new MDDocumentContentProvider(context); + let registration = vscode.workspace.registerTextDocumentContentProvider('markdown', provider); + + let d1 = vscode.commands.registerCommand('extension.previewMarkdown', () => openPreview()); + let d2 = vscode.commands.registerCommand('extension.previewMarkdownSide', () => openPreview(true)); + + context.subscriptions.push(d1, d2, registration); + + vscode.workspace.onDidSaveTextDocument((e: TextDocument) => { + if (isMarkdownFile(e.fileName)) { + let markdownPreviewUri = Uri.parse(`markdown://${e.uri.path}`); + provider.update(markdownPreviewUri); + } + }); + + vscode.workspace.onDidChangeConfiguration(() => { + vscode.workspace.textDocuments.forEach((document) => { + if ('markdown' === document.uri.scheme) { + provider.update(document.uri); + } + }); + }); +} + +function endsWith(haystack: string, needle: string): boolean { + let diff = haystack.length - needle.length; + if (diff > 0) { + return haystack.lastIndexOf(needle) === diff; + } else if (diff === 0) { + return haystack === needle; + } else { + return false; + } +} + +function isMarkdownFile(fileName: string) { + return fileName && (endsWith(fileName,'.md') + || endsWith(fileName, '.mdown') + || endsWith(fileName, '.markdown') + || endsWith(fileName, '.markdn')); +} + +function openPreview(sideBySide?: boolean): void { + const activeEditor = vscode.window.activeTextEditor; + if (!activeEditor) { + vscode.commands.executeCommand('workbench.action.navigateBack'); + return; + } + + let markdownPreviewUri = Uri.parse(`markdown://${activeEditor.document.uri.path}`); + vscode.commands.executeCommand('vscode.previewHtml', markdownPreviewUri, getViewColumn(sideBySide)); +} + +function getViewColumn(sideBySide): ViewColumn { + const active = vscode.window.activeTextEditor; + if (!active) { + return ViewColumn.One; + } + + if (!sideBySide) { + return active.viewColumn; + } + + switch (active.viewColumn) { + case ViewColumn.One: + return ViewColumn.Two; + case ViewColumn.Two: + return ViewColumn.Three; + } + + return active.viewColumn; +} + + +class MDDocumentContentProvider implements TextDocumentContentProvider { + private context; + private _onDidChange = new EventEmitter(); + + constructor(context: ExtensionContext) { + this.context = context; + } + + private getMediaPath(mediaFile) { + return this.context.asAbsolutePath(path.join('media', mediaFile)); + } + + private fixHref(resource: Uri, href: string) { + if (href) { + // Return early if href is already a URL + if (Uri.parse(href).scheme) { + return href; + } + // Otherwise convert to a file URI by joining the href with the resource location + return Uri.file(path.join(path.dirname(resource.fsPath), href)).toString(); + } + return href; + } + + private computeCustomStyleSheetIncludes(uri) : string[] { + const styles = vscode.workspace.getConfiguration('markdown')['styles']; + if (styles && Array.isArray(styles)) { + return styles.map((style) => { + return ``; + }); + } + return []; + } + + public provideTextDocumentContent(uri: Uri): Thenable { + return new Promise((approve, reject) => { + fs.readFile(uri.fsPath, (error, buffer) => { + if (error) { + return reject(error); + } + + const head = [].concat( + '', + '', + '', + '', + ``, + ``, + this.computeCustomStyleSheetIncludes(uri), + '', + '' + ).join('\n'); + + const body = md.render(buffer.toString()); + + const tail = [ + '', + '' + ].join('\n'); + + approve(head + body + tail); + }); + }); + } + + get onDidChange(): Event { + return this._onDidChange.event; + } + + public update(uri: Uri) { + this._onDidChange.fire(uri); + } +} \ No newline at end of file diff --git a/extensions/markdown/src/typings/ref.d.ts b/extensions/markdown/src/typings/ref.d.ts new file mode 100644 index 00000000000..6d55d0431fa --- /dev/null +++ b/extensions/markdown/src/typings/ref.d.ts @@ -0,0 +1,8 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +/// +/// +/// diff --git a/extensions/markdown/syntaxes/markdown.tmLanguage b/extensions/markdown/syntaxes/markdown.tmLanguage new file mode 100644 index 00000000000..62833d73399 --- /dev/null +++ b/extensions/markdown/syntaxes/markdown.tmLanguage @@ -0,0 +1,1826 @@ + + + + + fileTypes + + md + mdown + markdown + markdn + + keyEquivalent + ^~M + name + Markdown + patterns + + + include + #block + + + repository + + block + + patterns + + + include + #separator + + + include + #heading + + + include + #blockquote + + + include + #lists + + + include + #raw_block + + + include + #fenced_code_block_css + + + include + #fenced_code_block_basic + + + include + #fenced_code_block_ini + + + include + #fenced_code_block_java + + + include + #fenced_code_block_lua + + + include + #fenced_code_block_makefile + + + include + #fenced_code_block_perl + + + include + #fenced_code_block_r + + + include + #fenced_code_block_ruby + + + include + #fenced_code_block_sql + + + include + #fenced_code_block_vs_net + + + include + #fenced_code_block_xml + + + include + #fenced_code_block_xsl + + + include + #fenced_code_block_yaml + + + include + #fenced_code_block_dosbatch + + + include + #fenced_code_block_clojure + + + include + #fenced_code_block_coffee + + + include + #fenced_code_block_c + + + include + #fenced_code_block_diff + + + include + #fenced_code_block_dockerfile + + + include + #fenced_code_block_git_commit + + + include + #fenced_code_block_git_rebase + + + include + #fenced_code_block_groovy + + + include + #fenced_code_block_jade + + + include + #fenced_code_block_js + + + include + #fenced_code_block_js_regexp + + + include + #fenced_code_block_json + + + include + #fenced_code_block_less + + + include + #fenced_code_block_objc + + + include + #fenced_code_block_perl6 + + + include + #fenced_code_block_powershell + + + include + #fenced_code_block_python + + + include + #fenced_code_block_regexp_python + + + include + #fenced_code_block_shell + + + include + #fenced_code_block_ts + + + include + #fenced_code_block_tsx + + + include + #link-def + + + include + #html + + + include + #paragraph + + + repository + + blockquote + + begin + (^|\G)(>) ? + captures + + 2 + + name + punctuation.definition.quote.markdown + + + name + markup.quote.markdown + patterns + + + include + #block + + + while + (^|\G)(>) ? + + heading + + begin + (?:^|\G)(#{1,6})\s*(?=[\S[^#]]) + captures + + 1 + + name + punctuation.definition.heading.markdown + + + contentName + entity.name.section.markdown + end + \s*(#{1,6})?$\n? + name + markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown + patterns + + + include + #inline + + + + heading-setext + + patterns + + + match + ^(={3,})(?=[ \t]*$\n?) + name + markup.heading.setext.1.markdown + + + match + ^(-{3,})(?=[ \t]*$\n?) + name + markup.heading.setext.2.markdown + + + + html + + patterns + + + begin + (?i)(^|\G)(?=<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del).*</\2\s*>\s*$) + end + $ + patterns + + + include + text.html.basic + + + + + begin + (?i)(^|\G)(?=<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)) + patterns + + + include + text.html.basic + + + while + \G(?!</\2\s*>) + + + + link-def + + captures + + 1 + + name + punctuation.definition.constant.markdown + + 10 + + name + punctuation.definition.string.end.markdown + + 11 + + name + string.other.link.description.title.markdown + + 12 + + name + punctuation.definition.string.begin.markdown + + 13 + + name + punctuation.definition.string.end.markdown + + 2 + + name + constant.other.reference.link.markdown + + 3 + + name + punctuation.definition.constant.markdown + + 4 + + name + punctuation.separator.key-value.markdown + + 5 + + name + punctuation.definition.link.markdown + + 6 + + name + markup.underline.link.markdown + + 7 + + name + punctuation.definition.link.markdown + + 8 + + name + string.other.link.description.title.markdown + + 9 + + name + punctuation.definition.string.begin.markdown + + + match + ^(?x: + \s* # Leading whitespace + (\[)(.+?)(\])(:) # Reference name + [ \t]* # Optional whitespace + (<?)(\S+?)(>?) # The url + [ \t]* # Optional whitespace + (?: + ((\().+?(\))) # Match title in quotes… + | ((").+?(")) # or in parens. + )? # Title is optional + \s* # Optional whitespace + $ + ) + name + meta.link.reference.def.markdown + + list_paragraph + + begin + (^|\G)(?=\S)(?![*+-]\s|[0-9]+\.\s) + name + meta.paragraph.markdown + patterns + + + include + #inline + + + include + text.html.basic + + + include + #heading-setext + + + while + (^|\G)(?!\s*$|#|[ ]{0,3}([-*_][ ]{2,}){3,}[ \t]*$\n?|>|[ ]{0,3}[*+-]|[ ]{0,3}[0-9]+\.) + + lists + + patterns + + + begin + (^|\G)([ ]{0,3})([*+-])([ ]{1,3}|\t) + beginCaptures + + 3 + + name + punctuation.definition.list.markdown + + + comment + Currently does not support un-indented second lines. + name + markup.list.unnumbered.markdown + patterns + + + include + #list_paragraph + + + include + #block + + + while + \G([ ]{4}|\t|$) + + + begin + (^|\G)([ ]{0,3})([0-9]+\.)([ ]{1,3}|\t) + beginCaptures + + 3 + + name + punctuation.definition.list.markdown + + + name + markup.list.numbered.markdown + patterns + + + include + #list_paragraph + + + include + #block + + + while + \G([ ]{4}|\t|$) + + + + paragraph + + begin + (^|\G)(?=\S) + name + meta.paragraph.markdown + patterns + + + include + #inline + + + include + text.html.basic + + + include + #heading-setext + + + while + (^|\G)(?!\s*$|#|[ ]{0,3}([-*_][ ]{2,}){3,}[ \t]*$\n?|\s*\[.+?\]:|>) + + raw_block + + begin + (^|\G)([ ]{4}|\t) + name + markup.raw.block.markdown + while + (^|\G)([ ]{4}|\t) + + fenced_code_block_css + + begin + (^|\G)\s*([`~]{3,})\s*(css|css.erb)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.css + + + + fenced_code_block_basic + + begin + (^|\G)\s*([`~]{3,})\s*(html|htm|shtml|xhtml|inc|tmpl|tpl)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + text.html.basic + + + + fenced_code_block_ini + + begin + (^|\G)\s*([`~]{3,})\s*(ini|conf)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.ini + + + + fenced_code_block_java + + begin + (^|\G)\s*([`~]{3,})\s*(java|bsh)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.java + + + + fenced_code_block_lua + + begin + (^|\G)\s*([`~]{3,})\s*(lua)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.lua + + + + fenced_code_block_makefile + + begin + (^|\G)\s*([`~]{3,})\s*(Makefile|makefile|GNUmakefile|OCamlMakefile)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.makefile + + + + fenced_code_block_perl + + begin + (^|\G)\s*([`~]{3,})\s*(perl|pl|pm|pod|t|PL|psgi|vcl)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.perl + + + + fenced_code_block_r + + begin + (^|\G)\s*([`~]{3,})\s*(R|r|s|S|Rprofile)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.r + + + + fenced_code_block_ruby + + begin + (^|\G)\s*([`~]{3,})\s*(ruby|rb|rbx|rjs|Rakefile|rake|cgi|fcgi|gemspec|irbrc|Capfile|ru|prawn|Cheffile|Gemfile|Guardfile|Hobofile|Vagrantfile|Appraisals|Rantfile|Berksfile|Berksfile.lock|Thorfile|Puppetfile)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.ruby + + + + fenced_code_block_sql + + begin + (^|\G)\s*([`~]{3,})\s*(sql|ddl|dml)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.sql + + + + fenced_code_block_vs_net + + begin + (^|\G)\s*([`~]{3,})\s*(vb)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.asp.vb.net + + + + fenced_code_block_xml + + begin + (^|\G)\s*([`~]{3,})\s*(xml|xsd|tld|jsp|pt|cpt|dtml|rss|opml)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + text.xml + + + + fenced_code_block_xsl + + begin + (^|\G)\s*([`~]{3,})\s*(xsl|xslt)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + text.xml.xsl + + + + fenced_code_block_yaml + + begin + (^|\G)\s*([`~]{3,})\s*(yaml|yml)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.yaml + + + + fenced_code_block_dosbatch + + begin + (^|\G)\s*([`~]{3,})\s*(bat|batch)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.dosbatch + + + + fenced_code_block_clojure + + begin + (^|\G)\s*([`~]{3,})\s*(clj|cljs|clojure)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.clojure + + + + fenced_code_block_coffee + + begin + (^|\G)\s*([`~]{3,})\s*(coffee|Cakefile|coffee.erb)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.coffee + + + + fenced_code_block_c + + begin + (^|\G)\s*([`~]{3,})\s*(c|h)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.c + + + + fenced_code_block_diff + + begin + (^|\G)\s*([`~]{3,})\s*(patch|diff|rej)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.diff + + + + fenced_code_block_dockerfile + + begin + (^|\G)\s*([`~]{3,})\s*(dockerfile|Dockerfile)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.dockerfile + + + + fenced_code_block_git_commit + + begin + (^|\G)\s*([`~]{3,})\s*(COMMIT_EDITMSG|MERGE_MSG)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + text.git-commit + + + + fenced_code_block_git_rebase + + begin + (^|\G)\s*([`~]{3,})\s*(git-rebase-todo)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + text.git-rebase + + + + fenced_code_block_groovy + + begin + (^|\G)\s*([`~]{3,})\s*(groovy|gvy)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.groovy + + + + fenced_code_block_jade + + begin + (^|\G)\s*([`~]{3,})\s*(jade)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + text.jade + + + + fenced_code_block_js + + begin + (^|\G)\s*([`~]{3,})\s*(js|jsx|javascript)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.js + + + + fenced_code_block_js_regexp + + begin + (^|\G)\s*([`~]{3,})\s*(regexp)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.js.regexp + + + + fenced_code_block_json + + begin + (^|\G)\s*([`~]{3,})\s*(json|sublime-settings|sublime-menu|sublime-keymap|sublime-mousemap|sublime-theme|sublime-build|sublime-project|sublime-completions)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.json + + + + fenced_code_block_less + + begin + (^|\G)\s*([`~]{3,})\s*(less)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.css.less + + + + fenced_code_block_objc + + begin + (^|\G)\s*([`~]{3,})\s*(objectivec|mm|objc|obj-c|m|h)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.objc + + + + fenced_code_block_perl6 + + begin + (^|\G)\s*([`~]{3,})\s*(perl6|p6|pl6|pm6|nqp)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.perl.6 + + + + fenced_code_block_powershell + + begin + (^|\G)\s*([`~]{3,})\s*(powershell|ps1|psm1|psd1)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.powershell + + + + fenced_code_block_python + + begin + (^|\G)\s*([`~]{3,})\s*(python|py|py3|rpy|pyw|cpy|SConstruct|Sconstruct|sconstruct|SConscript|gyp|gypi)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.python + + + + fenced_code_block_regexp_python + + begin + (^|\G)\s*([`~]{3,})\s*(re)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.regexp.python + + + + fenced_code_block_shell + + begin + (^|\G)\s*([`~]{3,})\s*(shell|sh|bash|zsh|bashrc|bash_profile|bash_login|profile|bash_logout|.textmate_init)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.shell + + + + fenced_code_block_ts + + begin + (^|\G)\s*([`~]{3,})\s*(typescript|ts)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.ts + + + + fenced_code_block_tsx + + begin + (^|\G)\s*([`~]{3,})\s*(tsx)\s*$ + name + markup.fenced_code.block.markdown + end + (^|\G)(\2)\n + patterns + + + include + source.tsx + + + + separator + + match + (^|\G)[ ]{0,3}([-*_])([ ]{0,2}\2){2,}[ \t]*$\n? + name + meta.separator.markdown + + + + inline + + patterns + + + include + #ampersand + + + include + #bracket + + + include + #bold + + + include + #italic + + + include + #raw + + + include + #escape + + + include + #image-inline + + + include + #image-ref + + + include + #link-email + + + include + #link-inet + + + include + #link-inline + + + include + #link-ref + + + include + #link-ref-literal + + + repository + + ampersand + + comment + + Markdown will convert this for us. We match it so that the + HTML grammar will not mark it up as invalid. + + match + &(?!([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);) + name + meta.other.valid-ampersand.markdown + + bold + + begin + (?x) + (\*\*|__)(?=\S) # Open + (?= + ( + <[^>]*+> # HTML tags + | (?<raw>`+)([^`]|(?!(?<!`)\k<raw>(?!`))`)*+\k<raw> + # Raw + | \\[\\`*_{}\[\]()#.!+\->]?+ # Escapes + | \[ + ( + (?<square> # Named group + [^\[\]\\] # Match most chars + | \\. # Escaped chars + | \[ \g<square>*+ \] # Nested brackets + )*+ + \] + ( + ( # Reference Link + [ ]? # Optional space + \[[^\]]*+\] # Ref name + ) + | ( # Inline Link + \( # Opening paren + [ \t]*+ # Optional whtiespace + <?(.*?)>? # URL + [ \t]*+ # Optional whtiespace + ( # Optional Title + (?<title>['"]) + (.*?) + \k<title> + )? + \) + ) + ) + ) + | (?!(?<=\S)\1). # Everything besides + # style closer + )++ + (?<=\S)\1 # Close + ) + + captures + + 1 + + name + punctuation.definition.bold.markdown + + + end + (?<=\S)(\1) + name + markup.bold.markdown + patterns + + + applyEndPatternLast + 1 + begin + (?=<[^>]*?>) + end + (?<=>) + patterns + + + include + text.html.basic + + + + + include + #escape + + + include + #ampersand + + + include + #bracket + + + include + #raw + + + include + #italic + + + include + #image-inline + + + include + #link-inline + + + include + #link-inet + + + include + #link-email + + + include + #image-ref + + + include + #link-ref-literal + + + include + #link-ref + + + + bracket + + comment + + Markdown will convert this for us. We match it so that the + HTML grammar will not mark it up as invalid. + + match + <(?![a-z/?\$!]) + name + meta.other.valid-bracket.markdown + + escape + + match + \\[-`*_#+.!(){}\[\]\\>] + name + constant.character.escape.markdown + + image-inline + + captures + + 1 + + name + punctuation.definition.string.begin.markdown + + 10 + + name + string.other.link.description.title.markdown + + 11 + + name + punctuation.definition.string.markdown + + 12 + + name + punctuation.definition.string.markdown + + 13 + + name + string.other.link.description.title.markdown + + 14 + + name + punctuation.definition.string.markdown + + 15 + + name + punctuation.definition.string.markdown + + 16 + + name + punctuation.definition.metadata.markdown + + 2 + + name + string.other.link.description.markdown + + 4 + + name + punctuation.definition.string.end.markdown + + 5 + + name + invalid.illegal.whitespace.markdown + + 6 + + name + punctuation.definition.metadata.markdown + + 7 + + name + punctuation.definition.link.markdown + + 8 + + name + markup.underline.link.image.markdown + + 9 + + name + punctuation.definition.link.markdown + + + match + (?x: + \! # Images start with ! + (\[)((?<square>[^\[\]\\]|\\.|\[\g<square>*+\])*+)(\]) + # Match the link text. + ([ ])? # Space not allowed + (\() # Opening paren for url + (<?)(\S+?)(>?) # The url + [ \t]* # Optional whitespace + (?: + ((\().+?(\))) # Match title in parens… + | ((").+?(")) # or in quotes. + )? # Title is optional + \s* # Optional whitespace + (\)) + ) + name + meta.image.inline.markdown + + image-ref + + captures + + 1 + + name + punctuation.definition.string.begin.markdown + + 2 + + name + string.other.link.description.markdown + + 4 + + name + punctuation.definition.string.begin.markdown + + 5 + + name + punctuation.definition.constant.markdown + + 6 + + name + constant.other.reference.link.markdown + + 7 + + name + punctuation.definition.constant.markdown + + + match + \!(\[)((?<square>[^\[\]\\]|\\.|\[\g<square>*+\])*+)(\])[ ]?(\[)(.*?)(\]) + name + meta.image.reference.markdown + + italic + + begin + (?x) + (\*|_)(?=\S) # Open + (?= + ( + <[^>]*+> # HTML tags + | (?<raw>`+)([^`]|(?!(?<!`)\k<raw>(?!`))`)*+\k<raw> + # Raw + | \\[\\`*_{}\[\]()#.!+\->]?+ # Escapes + | \[ + ( + (?<square> # Named group + [^\[\]\\] # Match most chars + | \\. # Escaped chars + | \[ \g<square>*+ \] # Nested brackets + )*+ + \] + ( + ( # Reference Link + [ ]? # Optional space + \[[^\]]*+\] # Ref name + ) + | ( # Inline Link + \( # Opening paren + [ \t]*+ # Optional whtiespace + <?(.*?)>? # URL + [ \t]*+ # Optional whtiespace + ( # Optional Title + (?<title>['"]) + (.*?) + \k<title> + )? + \) + ) + ) + ) + | \1\1 # Must be bold closer + | (?!(?<=\S)\1). # Everything besides + # style closer + )++ + (?<=\S)\1 # Close + ) + + captures + + 1 + + name + punctuation.definition.italic.markdown + + + end + (?<=\S)(\1)((?!\1)|(?=\1\1)) + name + markup.italic.markdown + patterns + + + applyEndPatternLast + 1 + begin + (?=<[^>]*?>) + end + (?<=>) + patterns + + + include + text.html.basic + + + + + include + #escape + + + include + #ampersand + + + include + #bracket + + + include + #raw + + + include + #bold + + + include + #image-inline + + + include + #link-inline + + + include + #link-inet + + + include + #link-email + + + include + #image-ref + + + include + #link-ref-literal + + + include + #link-ref + + + + link-email + + captures + + 1 + + name + punctuation.definition.link.markdown + + 2 + + name + markup.underline.link.markdown + + 4 + + name + punctuation.definition.link.markdown + + + match + (<)((?:mailto:)?[-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(>) + name + meta.link.email.lt-gt.markdown + + link-inet + + captures + + 1 + + name + punctuation.definition.link.markdown + + 2 + + name + markup.underline.link.markdown + + 3 + + name + punctuation.definition.link.markdown + + + match + (<)((?:https?|ftp)://.*?)(>) + name + meta.link.inet.markdown + + link-inline + + captures + + 1 + + name + punctuation.definition.string.begin.markdown + + 10 + + name + string.other.link.description.title.markdown + + 11 + + name + punctuation.definition.string.begin.markdown + + 12 + + name + punctuation.definition.string.end.markdown + + 13 + + name + string.other.link.description.title.markdown + + 14 + + name + punctuation.definition.string.begin.markdown + + 15 + + name + punctuation.definition.string.end.markdown + + 16 + + name + punctuation.definition.metadata.markdown + + 2 + + name + string.other.link.title.markdown + + 4 + + name + punctuation.definition.string.end.markdown + + 5 + + name + invalid.illegal.whitespace.markdown + + 6 + + name + punctuation.definition.metadata.markdown + + 7 + + name + punctuation.definition.link.markdown + + 8 + + name + markup.underline.link.markdown + + 9 + + name + punctuation.definition.link.markdown + + + match + (?x: + (\[)((?<square>[^\[\]\\]|\\.|\[\g<square>*+\])*+)(\]) + # Match the link text. + ([ ])? # Space not allowed + (\() # Opening paren for url + (<?)(.*?)(>?) # The url + [ \t]* # Optional whitespace + (?: + ((\().+?(\))) # Match title in parens… + | ((").+?(")) # or in quotes. + )? # Title is optional + \s* # Optional whitespace + (\)) + ) + name + meta.link.inline.markdown + + link-ref + + captures + + 1 + + name + punctuation.definition.string.begin.markdown + + 2 + + name + string.other.link.title.markdown + + 4 + + name + punctuation.definition.string.end.markdown + + 5 + + name + punctuation.definition.constant.begin.markdown + + 6 + + name + constant.other.reference.link.markdown + + 7 + + name + punctuation.definition.constant.end.markdown + + + match + (\[)((?<square>[^\[\]\\]|\\.|\[\g<square>*+\])*+)(\])[ ]?(\[)([^\]]*+)(\]) + name + meta.link.reference.markdown + + link-ref-literal + + captures + + 1 + + name + punctuation.definition.string.begin.markdown + + 2 + + name + string.other.link.title.markdown + + 4 + + name + punctuation.definition.string.end.markdown + + 5 + + name + punctuation.definition.constant.begin.markdown + + 6 + + name + punctuation.definition.constant.end.markdown + + + match + (\[)((?<square>[^\[\]\\]|\\.|\[\g<square>*+\])*+)(\])[ ]?(\[)(\]) + name + meta.link.reference.literal.markdown + + raw + + captures + + 1 + + name + punctuation.definition.raw.markdown + + 3 + + name + punctuation.definition.raw.markdown + + + match + (`+)([^`]|(?!(?<!`)\1(?!`))`)*+(\1) + name + markup.raw.inline.markdown + + + + + scopeName + text.html.markdown + uuid + 0A1D9874-B448-11D9-BD50-000D93B6E43C + + diff --git a/extensions/markdown/tsconfig.json b/extensions/markdown/tsconfig.json new file mode 100644 index 00000000000..e5187e71148 --- /dev/null +++ b/extensions/markdown/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "outDir": "out", + "noLib": true, + "sourceMap": true, + "rootDir": "." + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file