Skip to content

Commit

Permalink
Hello World!
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardomozart committed Oct 16, 2019
1 parent 5609792 commit 0334e28
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 28 deletions.
2 changes: 1 addition & 1 deletion OLWInsertCode/OLWInsertCode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenLiveWriter.Api">
<HintPath>C:\Users\Julian\AppData\Local\OpenLiveWriter\app-0.6.0.0\OpenLiveWriter.Api.dll</HintPath>
<HintPath>C:\Users\hp\AppData\Local\OpenLiveWriter\app-0.6.2\OpenLiveWriter.Api.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
Expand Down
18 changes: 11 additions & 7 deletions OLWInsertCode/VSCodePaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ public class VSCodePaster : ContentSource {

public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content) {
DialogResult result = DialogResult.OK;


string s = Environment.NewLine;
string html = null;
if (Clipboard.ContainsText(TextDataFormat.Rtf)) {
string s = Clipboard.GetText(TextDataFormat.Rtf);
string html = RtfParser.ParseRtf(s);
content = String.Format("<div class=\"jmbcodeblock\">{0}<pre>{1}{0}</pre>{0}</div>{0}", Environment.NewLine, html);
}
else {
content = "Clipboard is empty of RTF text. Did you copy some code from Visual Studio?";
s = Clipboard.GetText(TextDataFormat.Rtf);
html = RtfParser.ParseRtf(s);
} else {
// content = "Clipboard is empty of RTF text. Did you copy some code from Visual Studio?";
s = Clipboard.GetText();
html = System.Net.WebUtility.HtmlEncode(s);
}

content = String.Format("<div class=\"jmbcodeblock\">{0}<pre>{1}{0}</pre>{0}</div>{0}<p></p>", Environment.NewLine, html);
return result;
}
}
Expand Down
68 changes: 48 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Open Live Writer paste code from VS
===

_Pasting code copied from Visual Studio into Open Live Writer_
_Fork from [OLWInsertCode](https://github.com/coldscientist/OLWInsertCode) from Julian M Bucknall to allow pasting code from any program into Open Live Writer_

Introduction
---
Expand All @@ -14,9 +14,29 @@ At the time I wrote this, I just wanted to mimic the color choices I'd set in Vi
Using with Open Live Writer
===

Compiling the code with Visual Studio will produce a DLL called `OLWInsertCode.dll`. Make sure you are not running Open Live Writer, then copy this DLL to the `Plugins` folder off from the installation folder for Open Live Writer (you might need to create it if this is the first plugin you're using). Restart Open Live Writer.
You may download it from [here](https://github.com/coldscientist/OLWInsertCode/releases).

To paste some code, highlight and copy it from Visual Studio. Switch to Open Live Writer, go to the Insert tab, and look in the Plug-ins ribbon group. Select Paste Code from VS and the code will be inserted into the document, as formatted in Visual Studio.
By default OLW will look in the Plugins folder inside the application path (e.g: `C:\Users\UserName\AppData\Local\OpenLiveWriter\app-0.5.1.3\Plugins`) but this path will change as OLW auto-updates itself (i.e. the app number will change). Make sure you are not running Open Live Writer. To install copy the plugin to that path using the latest `…\app-x.x.x.x` folder present on your system. Each time OLW updates to a new version you will need to re-copy or move the plugin into the new `…\app-x.x.x.x` folder. Restart Open Live Writer.

Alternatively use this approach: OLW (like WLW before it) checks the registry for plugins too and so you can add a registry key telling OLW where to find the plugin. Whilst this feature is supported by OLW this should enable the plugin to survive OLW auto updates without you having to do anything. Just download and extract the plugin to a folder on your harddrive and then add a new registry key to `HKEY_CURRENT_USER\SOFTWARE\OpenLiveWriter\PluginAssemblies` with the name (can be anything) and the location of the plugin. For example:

![OLW PluginAssemblies](Screenshots/InsertCode-OLW-PluginAssemblies.png)

To paste some code, highlight and copy it from any RTF program. Switch to Open Live Writer, go to the Insert tab, and look in the Plug-ins ribbon group. Select PasteCodefromVS and the code will be inserted into the document, as formatted in the program you copied the text from.

![OLWInsertCode](Screenshots/InserCode-OLW.png)

Compilling
===

Compilling the code with Visual Studio or MSBuild will produce a DLL called `OLWInsertCode.dll`.

1. You'll need to edit `OLWInsertCode.csproj` file and change `OpenLiveWriter.Api` Reference directory with your Open Live Writer installation directory.
1. You can compile the code through Visual Studio or through MSBuild (doesn't require Visual Studio) typing the following command at **Command prompt**:

```
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "C:\Users\hp\Documents\GitHub\OLWInsertCode\OLWInsertCode\OLWInsertCode.csproj"
```

Code block format
===
Expand All @@ -27,20 +47,28 @@ The code will be wrapped in a special code block like this:

You can then style both the `.jmbcodeblock` and `.jmbcodeblock pre` selectors as you wish. As an example, in my main blog's CSS I use:

pre, code {
font-family: Inconsolata, Consolas, "Courier New", Courier, monospace;
}

.jmbcodeblock pre {
font-size: 16px;
line-height: 1.1;
color: Black;
background: White;
border: 1px solid #5F5F5F;
overflow: auto;
margin-bottom: 20px;
padding: 10px 20px;
max-height: 400px;
}


```
div.jmbcodeblock {
margin-bottom: 30px;
}
pre {
font-size: 16px;
border: 1px solid #ccc;
max-height: 400px;
background-color: rgb(40, 42, 54);
padding: 1em;
margin: .5em 0;
overflow: auto;
color: rgb(248, 248, 242);
text-shadow: 0 1px rgba(0,0,0,0.3);
font-family: Consolas,SFMono-Regular,Liberation Mono,Menlo,monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
tab-size: 4;
hyphens: none;
}
```
Binary file added Screenshots/InserCode-OLW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/InsertCode-OLW-PluginAssemblies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0334e28

Please # to comment.