├── .gitattributes ├── .github ├── CONTRIBUTING.md ├── FUNDING.yml └── ISSUE_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── ZenCodingVS.sln ├── appveyor.yml ├── art ├── example1.png ├── example2.png ├── example3.png ├── example4.png └── example5.png ├── lib └── ZenCoding.dll └── src ├── Commands └── Expander.cs ├── Properties └── AssemblyInfo.cs ├── Resources └── Icon.png ├── ZenCodingPackage.cs ├── ZenCodingVS.csproj ├── source.extension.cs └── source.extension.vsixmanifest /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Looking to contribute something? **Here's how you can help.** 4 | 5 | Please take a moment to review this document in order to make the contribution 6 | process easy and effective for everyone involved. 7 | 8 | Following these guidelines helps to communicate that you respect the time of 9 | the developers managing and developing this open source project. In return, 10 | they should reciprocate that respect in addressing your issue or assessing 11 | patches and features. 12 | 13 | 14 | ## Using the issue tracker 15 | 16 | The issue tracker is the preferred channel for [bug reports](#bug-reports), 17 | [features requests](#feature-requests) and 18 | [submitting pull requests](#pull-requests), but please respect the 19 | following restrictions: 20 | 21 | * Please **do not** use the issue tracker for personal support requests. Stack 22 | Overflow is a better place to get help. 23 | 24 | * Please **do not** derail or troll issues. Keep the discussion on topic and 25 | respect the opinions of others. 26 | 27 | * Please **do not** open issues or pull requests which *belongs to* third party 28 | components. 29 | 30 | 31 | ## Bug reports 32 | 33 | A bug is a _demonstrable problem_ that is caused by the code in the repository. 34 | Good bug reports are extremely helpful, so thanks! 35 | 36 | Guidelines for bug reports: 37 | 38 | 1. **Use the GitHub issue search** — check if the issue has already been 39 | reported. 40 | 41 | 2. **Check if the issue has been fixed** — try to reproduce it using the 42 | latest `master` or development branch in the repository. 43 | 44 | 3. **Isolate the problem** — ideally create an 45 | [SSCCE](http://www.sscce.org/) and a live example. 46 | Uploading the project on cloud storage (OneDrive, DropBox, et el.) 47 | or creating a sample GitHub repository is also helpful. 48 | 49 | 50 | A good bug report shouldn't leave others needing to chase you up for more 51 | information. Please try to be as detailed as possible in your report. What is 52 | your environment? What steps will reproduce the issue? What browser(s) and OS 53 | experience the problem? Do other browsers show the bug differently? What 54 | would you expect to be the outcome? All these details will help people to fix 55 | any potential bugs. 56 | 57 | Example: 58 | 59 | > Short and descriptive example bug report title 60 | > 61 | > A summary of the issue and the Visual Studio, browser, OS environments 62 | > in which it occurs. If suitable, include the steps required to reproduce the bug. 63 | > 64 | > 1. This is the first step 65 | > 2. This is the second step 66 | > 3. Further steps, etc. 67 | > 68 | > `` - a link to the project/file uploaded on cloud storage or other publicly accessible medium. 69 | > 70 | > Any other information you want to share that is relevant to the issue being 71 | > reported. This might include the lines of code that you have identified as 72 | > causing the bug, and potential solutions (and your opinions on their 73 | > merits). 74 | 75 | 76 | ## Feature requests 77 | 78 | Feature requests are welcome. But take a moment to find out whether your idea 79 | fits with the scope and aims of the project. It's up to *you* to make a strong 80 | case to convince the project's developers of the merits of this feature. Please 81 | provide as much detail and context as possible. 82 | 83 | 84 | ## Pull requests 85 | 86 | Good pull requests, patches, improvements and new features are a fantastic 87 | help. They should remain focused in scope and avoid containing unrelated 88 | commits. 89 | 90 | **Please ask first** before embarking on any significant pull request (e.g. 91 | implementing features, refactoring code, porting to a different language), 92 | otherwise you risk spending a lot of time working on something that the 93 | project's developers might not want to merge into the project. 94 | 95 | Please adhere to the [coding guidelines](#code-guidelines) used throughout the 96 | project (indentation, accurate comments, etc.) and any other requirements 97 | (such as test coverage). 98 | 99 | Adhering to the following process is the best way to get your work 100 | included in the project: 101 | 102 | 1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, 103 | and configure the remotes: 104 | 105 | ```bash 106 | # Clone your fork of the repo into the current directory 107 | git clone https://github.com//.git 108 | # Navigate to the newly cloned directory 109 | cd 110 | # Assign the original repo to a remote called "upstream" 111 | git remote add upstream https://github.com/madskristensen/.git 112 | ``` 113 | 114 | 2. If you cloned a while ago, get the latest changes from upstream: 115 | 116 | ```bash 117 | git checkout master 118 | git pull upstream master 119 | ``` 120 | 121 | 3. Create a new topic branch (off the main project development branch) to 122 | contain your feature, change, or fix: 123 | 124 | ```bash 125 | git checkout -b 126 | ``` 127 | 128 | 4. Commit your changes in logical chunks. Please adhere to these [git commit 129 | message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) 130 | or your code is unlikely be merged into the main project. Use Git's 131 | [interactive rebase](https://help.github.com/articles/interactive-rebase) 132 | feature to tidy up your commits before making them public. Also, prepend name of the feature 133 | to the commit message. For instance: "SCSS: Fixes compiler results for IFileListener.\nFixes `#123`" 134 | 135 | 5. Locally merge (or rebase) the upstream development branch into your topic branch: 136 | 137 | ```bash 138 | git pull [--rebase] upstream master 139 | ``` 140 | 141 | 6. Push your topic branch up to your fork: 142 | 143 | ```bash 144 | git push origin 145 | ``` 146 | 147 | 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) 148 | with a clear title and description against the `master` branch. 149 | 150 | 151 | ## Code guidelines 152 | 153 | - Always use proper indentation. 154 | - In Visual Studio under `Tools > Options > Text Editor > C# > Advanced`, make sure 155 | `Place 'System' directives first when sorting usings` option is enabled (checked). 156 | - Before committing, organize usings for each updated C# source file. Either you can 157 | right-click editor and select `Organize Usings > Remove and sort` OR use extension 158 | like [BatchFormat](http://visualstudiogallery.msdn.microsoft.com/a7f75c34-82b4-4357-9c66-c18e32b9393e). 159 | - Before committing, run Code Analysis in `Debug` configuration and follow the guidelines 160 | to fix CA issues. Code Analysis commits can be made separately. 161 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: madskristensen 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Installed product versions 2 | - Visual Studio: [example 2015 Professional] 3 | - This extension: [example 1.1.21] 4 | 5 | ### Description 6 | Replace this text with a short description 7 | 8 | ### Steps to recreate 9 | 1. Replace this 10 | 2. text with 11 | 3. the steps 12 | 4. to recreate 13 | 14 | ### Current behavior 15 | Explain what it's doing and why it's wrong 16 | 17 | ### Expected behavior 18 | Explain what it should be doing after it's fixed. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | packages 2 | 3 | # User files 4 | *.suo 5 | *.user 6 | *.sln.docstates 7 | .vs/ 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Rr]elease/ 12 | x64/ 13 | [Bb]in/ 14 | [Oo]bj/ 15 | 16 | # MSTest test Results 17 | [Tt]est[Rr]esult*/ 18 | [Bb]uild[Ll]og.* 19 | 20 | # NCrunch 21 | *.ncrunchsolution 22 | *.ncrunchproject 23 | _NCrunch_WebCompiler -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Road map 2 | 3 | - [ ] nothing yet... 4 | 5 | Features that have a checkmark are complete and available for 6 | download in the 7 | [CI build](http://vsixgallery.com/extension/9514d70e-a7b1-4876-847d-b0d2ad0962bf/). 8 | 9 | # Change log 10 | 11 | These are the changes to each version that has been released 12 | on the official Visual Studio extension gallery. 13 | 14 | ## 1.2 15 | 16 | - [x] Fixed indentation issue (#1) 17 | 18 | ## 1.1 19 | 20 | - [x] Work on non-empty lines 21 | 22 | ## 1.0 23 | 24 | - [x] ZenCoding generator 25 | - [x] Lorem Ipsum generator 26 | - [x] Lorem Pixel image generator 27 | - [x] PlaceHold.it image generator -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2016 Mads Kristensen 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZenCoding 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/p6lyd0fetoa1amgy?svg=true)](https://ci.appveyor.com/project/madskristensen/zencodingvs) 4 | 5 | Download this extension from the [Marketplace](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.ZenCoding) 6 | or get the [CI build](http://vsixgallery.com/extension/9514d70e-a7b1-4876-847d-b0d2ad0962bf/). 7 | 8 | --------------------------------------- 9 | 10 | Provides ZenCoding for the HTML Editor - full support for static HTML, Razor and WebForms. 11 | 12 | See the [change log](CHANGELOG.md) for changes and road map. 13 | 14 | ## Features 15 | 16 | - HTML ZenCoding 17 | - Lorem Ipsum generator 18 | - Lorem Pixel image generator 19 | - PlaceHold.it image generator 20 | 21 | ### HTML ZenCoding 22 | ZenCoding is a quick way to generate HTML markup by using a CSS based syntax. 23 | 24 | To invoke ZenCoding, write the syntax and hit the `TAB` key to generate the markup. 25 | 26 | #### Examples: 27 | 28 | Syntax __ul>li\*3__ generates: 29 | 30 | ![Example1](art/example1.png) 31 | 32 | Syntax __#foo>span__ generates: 33 | 34 | ![Example2](art/example2.png) 35 | 36 | Syntax __ul>li\*4>a{test $}__ generates: 37 | 38 | ![Example3](art/example3.png) 39 | 40 | ### Lorem Ipsum generator 41 | As part of ZenCoding, you can now generate Lorem Ipsum code directly in the HTML editor. Simply type `lorem` and hit `TAB` and a 30 word Lorem Ipsum text is inserted. 42 | 43 | Type `lorem10` and a 10 word Lorem Ipsum text is inserted. 44 | This can be used in conjuction with ZenCoding like so: `ul>li*5>lorem3` 45 | 46 | ### Lorem Pixel generator 47 | As part of ZenCoding, you can also generate Lorem Pixel code directly in the HTML editor. Simply type `pix-200x200-animals` and hit `TAB` and a img tag with a 200x200 image of an animal is inserted: 48 | 49 | ![Example4](art/example4.png) 50 | 51 | ### PlaceHold.it generator 52 | ZenCoding also support [PlaceHold.it](http://placehold.it/) if you prefer blank images. Type `place-50` and hit `TAB` to have a 50 pixels square image. Use `place-200x100` to insert a rectangular image: 53 | 54 | ![Example5](art/example5.png) 55 | 56 | You can choose the background color by adding the hexadecimal value after the size like this `place-150x240-EEEDDD`. You can even add text to the image by using `place-150x240-EEE-t=This%20is%20some%20text`. 57 | 58 | ## Contribute 59 | Check out the [contribution guidelines](.github/CONTRIBUTING.md) 60 | if you want to contribute to this project. 61 | 62 | For cloning and building this project yourself, make sure 63 | to install the 64 | [Extensibility Tools 2015](https://visualstudiogallery.msdn.microsoft.com/ab39a092-1343-46e2-b0f1-6a3f91155aa6) 65 | extension for Visual Studio which enables some features 66 | used by this project. 67 | 68 | ## License 69 | [Apache 2.0](LICENSE) -------------------------------------------------------------------------------- /ZenCodingVS.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28117.3001 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZenCodingVS", "src\ZenCodingVS.csproj", "{6904ECAD-A905-447E-8AC4-0542D40E17E3}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DFF7938C-ED40-49F5-96AF-4F514CFB1409}" 9 | ProjectSection(SolutionItems) = preProject 10 | appveyor.yml = appveyor.yml 11 | CHANGELOG.md = CHANGELOG.md 12 | README.md = README.md 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {6904ECAD-A905-447E-8AC4-0542D40E17E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {6904ECAD-A905-447E-8AC4-0542D40E17E3}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {6904ECAD-A905-447E-8AC4-0542D40E17E3}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {6904ECAD-A905-447E-8AC4-0542D40E17E3}.Release|Any CPU.Build.0 = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | GlobalSection(ExtensibilityGlobals) = postSolution 30 | SolutionGuid = {5A16C84E-DB31-485A-B8FB-F44DBD038E57} 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2022 2 | 3 | install: 4 | - ps: (new-object Net.WebClient).DownloadString("https://raw.github.com/madskristensen/ExtensionScripts/master/AppVeyor/vsix.ps1") | iex 5 | 6 | before_build: 7 | - ps: Vsix-IncrementVsixVersion | Vsix-UpdateBuildVersion 8 | - ps: Vsix-TokenReplacement src\source.extension.cs 'Version = "([0-9\\.]+)"' 'Version = "{version}"' 9 | 10 | build_script: 11 | - nuget restore -Verbosity quiet 12 | - msbuild /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m 13 | 14 | after_test: 15 | - ps: Vsix-PushArtifacts | Vsix-PublishToGallery 16 | -------------------------------------------------------------------------------- /art/example1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/ZenCodingVS/764bd99ccdc961fa97c05c5444332dd32fa25c85/art/example1.png -------------------------------------------------------------------------------- /art/example2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/ZenCodingVS/764bd99ccdc961fa97c05c5444332dd32fa25c85/art/example2.png -------------------------------------------------------------------------------- /art/example3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/ZenCodingVS/764bd99ccdc961fa97c05c5444332dd32fa25c85/art/example3.png -------------------------------------------------------------------------------- /art/example4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/ZenCodingVS/764bd99ccdc961fa97c05c5444332dd32fa25c85/art/example4.png -------------------------------------------------------------------------------- /art/example5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/ZenCodingVS/764bd99ccdc961fa97c05c5444332dd32fa25c85/art/example5.png -------------------------------------------------------------------------------- /lib/ZenCoding.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/ZenCodingVS/764bd99ccdc961fa97c05c5444332dd32fa25c85/lib/ZenCoding.dll -------------------------------------------------------------------------------- /src/Commands/Expander.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using System.Linq; 4 | using System.Text.RegularExpressions; 5 | using Microsoft.VisualStudio.Commanding; 6 | using Microsoft.VisualStudio.Shell; 7 | using Microsoft.VisualStudio.Text; 8 | using Microsoft.VisualStudio.Text.Classification; 9 | using Microsoft.VisualStudio.Text.Editor; 10 | using Microsoft.VisualStudio.Text.Editor.Commanding; 11 | using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; 12 | using Microsoft.VisualStudio.Utilities; 13 | using ZenCoding; 14 | 15 | namespace ZenCodingVS 16 | { 17 | [Export(typeof(ICommandHandler))] 18 | [Name(nameof(Expander))] 19 | [ContentType("HTML")] 20 | [ContentType("html-delegation")] // VS 2022 21 | [ContentType("WebForms")] // VS 2022 22 | [ContentType("HTMLX")] 23 | [ContentType("Razor")] 24 | [ContentType("LegacyRazorCSharp")] // VS 2022 25 | [TextViewRole(PredefinedTextViewRoles.PrimaryDocument)] 26 | internal class Expander : ICommandHandler 27 | { 28 | private static readonly Regex _bracket = new Regex(@"<([a-z0-9]*)\b[^>]*>([^<]*)", RegexOptions.IgnoreCase); 29 | private static readonly Regex _quotes = new Regex("(=\"()\")", RegexOptions.IgnoreCase); 30 | private static readonly Span _emptySpan = new Span(); 31 | 32 | [Import] 33 | private readonly IClassifierAggregatorService _classifierService = default; 34 | 35 | [Import] 36 | private readonly IEditorCommandHandlerServiceFactory _commandService = default; 37 | 38 | public string DisplayName => Vsix.Name; 39 | 40 | public bool ExecuteCommand(TabKeyCommandArgs args, CommandExecutionContext executionContext) 41 | { 42 | ThreadHelper.ThrowIfNotOnUIThread(); 43 | 44 | if (InvokeZenCoding(args)) 45 | { 46 | return true; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | public CommandState GetCommandState(TabKeyCommandArgs args) 53 | { 54 | return CommandState.Available; 55 | } 56 | 57 | private bool InvokeZenCoding(TabKeyCommandArgs args) 58 | { 59 | ThreadHelper.ThrowIfNotOnUIThread(); 60 | ITextView view = args.TextView; 61 | 62 | Span zenSpan = GetSyntaxSpan(view, out var syntax); 63 | 64 | if (zenSpan.IsEmpty || !view.Selection.SelectedSpans[0].IsEmpty) 65 | { 66 | return false; 67 | } 68 | 69 | var parser = new Parser(); 70 | var result = parser.Parse(syntax, ZenType.HTML); 71 | 72 | if (!string.IsNullOrEmpty(result)) 73 | { 74 | try 75 | { 76 | ITextSelection selection = UpdateTextBuffer(view, zenSpan, result); 77 | 78 | //var formatRangeCmd = new CommandID(new Guid("{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}"), 0x70); 79 | //var isFormatted = formatRangeCmd.Execute(); 80 | 81 | IEditorCommandHandlerService service = _commandService.GetService(view); 82 | var cmd = new FormatSelectionCommandArgs(view, view.TextBuffer); 83 | service.Execute((v, b) => cmd, null); 84 | 85 | var formattedSpan = new Span(zenSpan.Start, selection.SelectedSpans[0].Length); 86 | SetCaret(view, formattedSpan, false); 87 | 88 | selection.Clear(); 89 | 90 | return true; 91 | } 92 | catch (Exception ex) 93 | { 94 | System.Diagnostics.Debug.Write(ex); 95 | } 96 | } 97 | 98 | return false; 99 | } 100 | 101 | 102 | private bool SetCaret(ITextView view, Span zenSpan, bool isReverse) 103 | { 104 | var text = view.TextBuffer.CurrentSnapshot.GetText(); 105 | Span quote = FindTabSpan(zenSpan, isReverse, text, _quotes); 106 | Span bracket = FindTabSpan(zenSpan, isReverse, text, _bracket); 107 | 108 | if (bracket.Start > 0 && (quote.Start == 0 || 109 | (!isReverse && (bracket.Start < quote.Start)) || 110 | (isReverse && (bracket.Start > quote.Start)))) 111 | { 112 | quote = bracket; 113 | } 114 | 115 | if (zenSpan.Contains(quote.Start)) 116 | { 117 | MoveTab(view, quote); 118 | return true; 119 | } 120 | else if (!isReverse) 121 | { 122 | MoveTab(view, new Span(zenSpan.End, 0)); 123 | return true; 124 | } 125 | 126 | return false; 127 | } 128 | 129 | private void MoveTab(ITextView view, Span quote) 130 | { 131 | view.Caret.MoveTo(new SnapshotPoint(view.TextBuffer.CurrentSnapshot, quote.Start)); 132 | } 133 | 134 | private static Span FindTabSpan(Span zenSpan, bool isReverse, string text, Regex regex) 135 | { 136 | MatchCollection matches = regex.Matches(text); 137 | 138 | if (!isReverse) 139 | { 140 | foreach (Match match in matches) 141 | { 142 | Group group = match.Groups[2]; 143 | 144 | if (group.Index >= zenSpan.Start) 145 | { 146 | return new Span(group.Index, group.Length); 147 | } 148 | } 149 | } 150 | else 151 | { 152 | for (var i = matches.Count - 1; i >= 0; i--) 153 | { 154 | Group group = matches[i].Groups[2]; 155 | 156 | if (group.Index < zenSpan.End) 157 | { 158 | return new Span(group.Index, group.Length); 159 | } 160 | } 161 | } 162 | 163 | return _emptySpan; 164 | } 165 | 166 | private ITextSelection UpdateTextBuffer(ITextView view, Span zenSpan, string result) 167 | { 168 | view.TextBuffer.Replace(zenSpan, result); 169 | 170 | var point = new SnapshotPoint(view.TextBuffer.CurrentSnapshot, zenSpan.Start); 171 | var snapshot = new SnapshotSpan(point, result.Length); 172 | view.Selection.Select(snapshot, false); 173 | 174 | return view.Selection; 175 | } 176 | 177 | private Span GetSyntaxSpan(ITextView view, out string text) 178 | { 179 | var position = view.Caret.Position.BufferPosition.Position; 180 | text = string.Empty; 181 | 182 | if (position == 0) 183 | { 184 | return _emptySpan; 185 | } 186 | 187 | ITextSnapshotLine line = view.TextBuffer.CurrentSnapshot.GetLineFromPosition(position); 188 | IClassifier classifier = _classifierService.GetClassifier(view.TextBuffer); 189 | ClassificationSpan last = classifier.GetClassificationSpans(line.Extent).LastOrDefault(); 190 | SnapshotPoint start = last?.Span.End ?? line.Start; 191 | 192 | if (start > position) 193 | { 194 | return _emptySpan; 195 | } 196 | 197 | text = line.Snapshot.GetText(start, position - start).Trim(); 198 | var offset = position - start - text.Length; 199 | 200 | return Span.FromBounds(start + offset, position); 201 | } 202 | } 203 | } 204 | 205 | -------------------------------------------------------------------------------- /src/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using ZenCodingVS; 4 | 5 | [assembly: AssemblyTitle(Vsix.Name)] 6 | [assembly: AssemblyDescription(Vsix.Description)] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany(Vsix.Author)] 9 | [assembly: AssemblyProduct(Vsix.Name)] 10 | [assembly: AssemblyCopyright(Vsix.Author)] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | 14 | [assembly: ComVisible(false)] 15 | 16 | [assembly: AssemblyVersion(Vsix.Version)] 17 | [assembly: AssemblyFileVersion(Vsix.Version)] 18 | -------------------------------------------------------------------------------- /src/Resources/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/ZenCodingVS/764bd99ccdc961fa97c05c5444332dd32fa25c85/src/Resources/Icon.png -------------------------------------------------------------------------------- /src/ZenCodingPackage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Microsoft.VisualStudio.Shell; 4 | 5 | namespace ZenCodingVS 6 | { 7 | [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] 8 | [InstalledProductRegistration(Vsix.Name, Vsix.Description, Vsix.Version)] 9 | [Guid("7c1ab83e-2477-4554-a538-f3204dcd63dd")] 10 | public sealed class ZenCodingPackage : AsyncPackage 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ZenCodingVS.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(VisualStudioVersion) 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | true 7 | Program 8 | $(DevEnvDir)\devenv.exe 9 | /rootsuffix Exp 10 | 11 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 2.0 19 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 20 | {6904ECAD-A905-447E-8AC4-0542D40E17E3} 21 | Library 22 | Properties 23 | ZenCodingVS 24 | ZenCodingVS 25 | v4.7.2 26 | true 27 | true 28 | true 29 | true 30 | true 31 | false 32 | 33 | 34 | true 35 | full 36 | false 37 | bin\Debug\ 38 | DEBUG;TRACE 39 | prompt 40 | 4 41 | 42 | 43 | pdbonly 44 | true 45 | bin\Release\ 46 | TRACE 47 | prompt 48 | 4 49 | 50 | 51 | 52 | 53 | 54 | True 55 | True 56 | source.extension.vsixmanifest 57 | 58 | 59 | 60 | 61 | 62 | Resources\LICENSE 63 | true 64 | 65 | 66 | Designer 67 | VsixManifestGenerator 68 | source.extension.cs 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | ..\lib\ZenCoding.dll 78 | 79 | 80 | 81 | 82 | true 83 | 84 | 85 | 86 | 87 | 16.0.206 88 | 89 | 90 | 17.0.5232 91 | runtime; build; native; contentfiles; analyzers; buildtransitive 92 | all 93 | 94 | 95 | 96 | 97 | 104 | -------------------------------------------------------------------------------- /src/source.extension.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This file was generated by VSIX Synchronizer 4 | // 5 | // ------------------------------------------------------------------------------ 6 | namespace ZenCodingVS 7 | { 8 | internal sealed partial class Vsix 9 | { 10 | public const string Id = "9514d70e-a7b1-4876-847d-b0d2ad0962bf"; 11 | public const string Name = "ZenCoding"; 12 | public const string Description = @"Provides ZenCoding for the HTML Editor - full support for static HTML, Razor and WebForms."; 13 | public const string Language = "en-US"; 14 | public const string Version = "1.2"; 15 | public const string Author = "Mads Kristensen"; 16 | public const string Tags = "emmet, zencoding, html"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | ZenCoding 6 | Provides ZenCoding for the HTML Editor - full support for static HTML, Razor and WebForms. 7 | https://github.com/madskristensen/ZenCodingVS 8 | Resources\LICENSE 9 | https://github.com/madskristensen/ZenCodingVS/blob/master/CHANGELOG.md 10 | Resources\Icon.png 11 | Resources\Icon.png 12 | emmet, zencoding, html 13 | 14 | 15 | 16 | 17 | amd64 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | --------------------------------------------------------------------------------