From b9bce8831fbb3b1045f7528bbbf787077eb3d311 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Thu, 11 Jul 2019 15:25:47 +0200 Subject: [PATCH 1/2] Add source.cpp contentName --- syntaxes/markdown.tmLanguage | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntaxes/markdown.tmLanguage b/syntaxes/markdown.tmLanguage index 3e53866..e71d843 100644 --- a/syntaxes/markdown.tmLanguage +++ b/syntaxes/markdown.tmLanguage @@ -1145,7 +1145,7 @@ while (^|\G)(?!\s*([`~]{3,})\s*$) contentName - meta.embedded.block.cpp + meta.embedded.block.cpp source.cpp patterns @@ -4161,4 +4161,4 @@ uuid 0A1D9874-B448-11D9-BD50-000D93B6E43C - \ No newline at end of file + From 3e76631ae0da0066fa6fb7fd52fa367d7750a7f1 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 27 Aug 2019 12:01:33 +0200 Subject: [PATCH 2/2] Modify build script --- build.js | 13 +++++++++---- syntaxes/markdown.tmLanguage | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/build.js b/build.js index b31609d..ef15402 100644 --- a/build.js +++ b/build.js @@ -28,7 +28,7 @@ const languages = [ { name: 'clojure', language: 'clojure', identifiers: ['clj', 'cljs', 'clojure'], source: 'source.clojure' }, { name: 'coffee', language: 'coffee', identifiers: ['coffee', 'Cakefile', 'coffee.erb'], source: 'source.coffee' }, { name: 'c', language: 'c', identifiers: ['c', 'h'], source: 'source.c' }, - { name: 'cpp', language: 'cpp', identifiers: ['cpp', 'c\\+\\+', 'cxx'], source: 'source.cpp' }, + { name: 'cpp', language: 'cpp', identifiers: ['cpp', 'c\\+\\+', 'cxx'], source: 'source.cpp', additionalContentName: ['source.cpp'] }, { name: 'diff', language: 'diff', identifiers: ['patch', 'diff', 'rej'], source: 'source.diff' }, { name: 'dockerfile', language: 'dockerfile', identifiers: ['dockerfile', 'Dockerfile'], source: 'source.dockerfile' }, { name: 'git_commit', identifiers: ['COMMIT_EDITMSG', 'MERGE_MSG'], source: 'text.git-commit' }, @@ -62,7 +62,7 @@ const languages = [ { name: 'markdown', language: 'markdown', identifiers: ['markdown', 'md'], source: 'text.html.markdown' }, ]; -const fencedCodeBlockDefinition = (name, identifiers, sourceScope, language) => { +const fencedCodeBlockDefinition = (name, identifiers, sourceScope, language, additionalContentName) => { if (!Array.isArray(sourceScope)) { sourceScope = [sourceScope]; } @@ -72,6 +72,11 @@ const fencedCodeBlockDefinition = (name, identifiers, sourceScope, language) => const scopes = sourceScope.map(scope => `- { include: '${scope}' }`).join('\n'); + let contentName = `meta.embedded.block.${language}`; + if (additionalContentName) { + contentName += ` ${additionalContentName.join(' ')}`; + } + return `fenced_code_block_${name}: begin: (^|\\G)(\\s*)(\`{3,}|~{3,})\\s*(?i:(${identifiers.join('|')})(\\s+[^\`~]*)?$) @@ -88,7 +93,7 @@ const fencedCodeBlockDefinition = (name, identifiers, sourceScope, language) => patterns: - begin: (^|\\G)(\\s*)(.*) while: (^|\\G)(?!\\s*([\`~]{3,})\\s*$) - contentName: meta.embedded.block.${language} + contentName: ${contentName} patterns: ${indent(4, scopes)} `; @@ -104,7 +109,7 @@ const fencedCodeBlockInclude = (name) => const fencedCodeBlockDefinitions = () => languages - .map(language => fencedCodeBlockDefinition(language.name, language.identifiers, language.source, language.language)) + .map(language => fencedCodeBlockDefinition(language.name, language.identifiers, language.source, language.language, language.additionalContentName)) .join('\n'); diff --git a/syntaxes/markdown.tmLanguage b/syntaxes/markdown.tmLanguage index e71d843..3a2e017 100644 --- a/syntaxes/markdown.tmLanguage +++ b/syntaxes/markdown.tmLanguage @@ -4161,4 +4161,4 @@ uuid 0A1D9874-B448-11D9-BD50-000D93B6E43C - + \ No newline at end of file