Ye, that's exactly what I mean. I assumed we were not able to get such information since the API does not have anything of the sort, but I thought I'd ask anyway.
How about the Post Title? Does anyone know the id or name WLW uses to represent the div that holds the Post Title? If I know that I can at least get the title.
I already have code that allows me to get the HTML from the WLW editor. Therefore, I am able to easily extract the post tile by using the following regular expression pattern.
@"<div[\s]+class=postTitle.*?>(?<postTitle>.*?)</div>"I then do a match against the post's HTML and voila!
Leo Vildosola wrote:
I already have code that allows me to get the HTML from the WLW editor. Therefore, I am able to easily extract the post tile by using the following regular expression pattern.
@"<div[\s]+class=postTitle.*?>(?<postTitle>.*?)</div>"
I then do a match against the post's HTML and voila!
That is an interesting answer, for when I posed that to the WLW team the answer was that HTML was not accessible through a plugin...care to share?
I have isolated the code in an assembly. If you use my Code Snippet plugin for Windows Live Writer or my Digg This plugin for Windows Live Writer, you will get an assembly called WLWPluginBase.dll in your plugin folder. All my plugins use that same assembly. This is where all that code is isolated. You can add a reference in your own plugin and use code similar to the following to get the HTML code or just the plain text.
if ((null != item) && !string.IsNullOrEmpty(Win32IEHelper.GetSelectedText(item.Handle)))
{
string selectedText = (whichSelectedTextFormatToGet ? Win32IEHelper.GetSelectedHtml(item.Handle)
: Win32IEHelper.GetSelectedText(item.Handle));
if (!string.IsNullOrEmpty(selectedText))
{
// Do whatever you want with selectedText and then return the modified text.
newContent = selectedText;
}
}