Rename MarkDown -> Markdown to resolve differences for non-Windows machines (#3758)

This commit is contained in:
C. Augusto Proiete 2020-07-15 14:23:59 -03:00 committed by GitHub
parent 6131181ea4
commit 5a590512bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 744 additions and 744 deletions

View File

@ -207,7 +207,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "previewpane", "previewpane"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PreviewHandlerCommon", "src\modules\previewpane\Common\PreviewHandlerCommon.csproj", "{AF2349B8-E5B6-4004-9502-687C1C7730B1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PreviewHandlerCommon", "src\modules\previewpane\Common\PreviewHandlerCommon.csproj", "{AF2349B8-E5B6-4004-9502-687C1C7730B1}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownPreviewHandler", "src\modules\previewpane\MarkDownPreviewHandler\MarkdownPreviewHandler.csproj", "{6A71162E-FC4C-4A2C-B90F-3CF94F59A9BB}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownPreviewHandler", "src\modules\previewpane\MarkdownPreviewHandler\MarkdownPreviewHandler.csproj", "{6A71162E-FC4C-4A2C-B90F-3CF94F59A9BB}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-MarkdownPreviewHandler", "src\modules\previewpane\PreviewPaneUnitTests\UnitTests-MarkdownPreviewHandler.csproj", "{A2B51B8B-8F90-424E-BC97-F9AB7D76CA1A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-MarkdownPreviewHandler", "src\modules\previewpane\PreviewPaneUnitTests\UnitTests-MarkdownPreviewHandler.csproj", "{A2B51B8B-8F90-424E-BC97-F9AB7D76CA1A}"
EndProject EndProject

View File

@ -1,103 +1,103 @@
// Copyright (c) Microsoft Corporation // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System; using System;
using System.IO; using System.IO;
using Markdig; using Markdig;
using Markdig.Extensions.Figures; using Markdig.Extensions.Figures;
using Markdig.Extensions.Tables; using Markdig.Extensions.Tables;
using Markdig.Renderers; using Markdig.Renderers;
using Markdig.Renderers.Html; using Markdig.Renderers.Html;
using Markdig.Syntax; using Markdig.Syntax;
using Markdig.Syntax.Inlines; using Markdig.Syntax.Inlines;
namespace MarkdownPreviewHandler namespace MarkdownPreviewHandler
{ {
/// <summary> /// <summary>
/// Callback if extension blocks external images. /// Callback if extension blocks external images.
/// </summary> /// </summary>
public delegate void ImagesBlockedCallBack(); public delegate void ImagesBlockedCallBack();
/// <summary> /// <summary>
/// Markdig Extension to process html nodes in markdown AST. /// Markdig Extension to process html nodes in markdown AST.
/// </summary> /// </summary>
public class HTMLParsingExtension : IMarkdownExtension public class HTMLParsingExtension : IMarkdownExtension
{ {
/// <summary> /// <summary>
/// Callback if extension blocks external images. /// Callback if extension blocks external images.
/// </summary> /// </summary>
private readonly ImagesBlockedCallBack imagesBlockedCallBack; private readonly ImagesBlockedCallBack imagesBlockedCallBack;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="HTMLParsingExtension"/> class. /// Initializes a new instance of the <see cref="HTMLParsingExtension"/> class.
/// </summary> /// </summary>
/// <param name="imagesBlockedCallBack">Callback function if image is blocked by extension.</param> /// <param name="imagesBlockedCallBack">Callback function if image is blocked by extension.</param>
/// <param name="baseUrl">Absolute path of markdown file.</param> /// <param name="baseUrl">Absolute path of markdown file.</param>
public HTMLParsingExtension(ImagesBlockedCallBack imagesBlockedCallBack, string baseUrl = "") public HTMLParsingExtension(ImagesBlockedCallBack imagesBlockedCallBack, string baseUrl = "")
{ {
this.imagesBlockedCallBack = imagesBlockedCallBack; this.imagesBlockedCallBack = imagesBlockedCallBack;
this.BaseUrl = baseUrl; this.BaseUrl = baseUrl;
} }
/// <summary> /// <summary>
/// Gets or sets path to directory containing markdown file. /// Gets or sets path to directory containing markdown file.
/// </summary> /// </summary>
public string BaseUrl { get; set; } public string BaseUrl { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public void Setup(MarkdownPipelineBuilder pipeline) public void Setup(MarkdownPipelineBuilder pipeline)
{ {
// Make sure we don't have a delegate twice // Make sure we don't have a delegate twice
pipeline.DocumentProcessed -= this.PipelineOnDocumentProcessed; pipeline.DocumentProcessed -= this.PipelineOnDocumentProcessed;
pipeline.DocumentProcessed += this.PipelineOnDocumentProcessed; pipeline.DocumentProcessed += this.PipelineOnDocumentProcessed;
} }
/// <inheritdoc/> /// <inheritdoc/>
public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer)
{ {
} }
/// <summary> /// <summary>
/// Process nodes in markdown AST. /// Process nodes in markdown AST.
/// </summary> /// </summary>
/// <param name="document">Markdown Document.</param> /// <param name="document">Markdown Document.</param>
public void PipelineOnDocumentProcessed(MarkdownDocument document) public void PipelineOnDocumentProcessed(MarkdownDocument document)
{ {
foreach (var node in document.Descendants()) foreach (var node in document.Descendants())
{ {
if (node is Block) if (node is Block)
{ {
if (node is Table) if (node is Table)
{ {
node.GetAttributes().AddClass("table table-striped table-bordered"); node.GetAttributes().AddClass("table table-striped table-bordered");
} }
else if (node is QuoteBlock) else if (node is QuoteBlock)
{ {
node.GetAttributes().AddClass("blockquote"); node.GetAttributes().AddClass("blockquote");
} }
else if (node is Figure) else if (node is Figure)
{ {
node.GetAttributes().AddClass("figure"); node.GetAttributes().AddClass("figure");
} }
else if (node is FigureCaption) else if (node is FigureCaption)
{ {
node.GetAttributes().AddClass("figure-caption"); node.GetAttributes().AddClass("figure-caption");
} }
} }
else if (node is Inline) else if (node is Inline)
{ {
if (node is LinkInline link) if (node is LinkInline link)
{ {
if (link.IsImage) if (link.IsImage)
{ {
link.Url = "#"; link.Url = "#";
link.GetAttributes().AddClass("img-fluid"); link.GetAttributes().AddClass("img-fluid");
this.imagesBlockedCallBack(); this.imagesBlockedCallBack();
} }
} }
} }
} }
} }
} }
} }

View File

@ -1,36 +1,36 @@
// Copyright (c) Microsoft Corporation // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Common; using Common;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
namespace MarkdownPreviewHandler namespace MarkdownPreviewHandler
{ {
/// <summary> /// <summary>
/// Implementation of preview handler for markdown files. /// Implementation of preview handler for markdown files.
/// </summary> /// </summary>
[Guid("45769bcc-e8fd-42d0-947e-02beef77a1f5")] [Guid("45769bcc-e8fd-42d0-947e-02beef77a1f5")]
[ClassInterface(ClassInterfaceType.None)] [ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)] [ComVisible(true)]
public class MarkdownPreviewHandler : FileBasedPreviewHandler public class MarkdownPreviewHandler : FileBasedPreviewHandler
{ {
private MarkdownPreviewHandlerControl markdownPreviewHandlerControl; private MarkdownPreviewHandlerControl markdownPreviewHandlerControl;
/// <inheritdoc /> /// <inheritdoc />
public override void DoPreview() public override void DoPreview()
{ {
this.markdownPreviewHandlerControl.DoPreview(this.FilePath); this.markdownPreviewHandlerControl.DoPreview(this.FilePath);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override IPreviewHandlerControl CreatePreviewHandlerControl() protected override IPreviewHandlerControl CreatePreviewHandlerControl()
{ {
PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.MarkdownFileHandlerLoaded()); PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.MarkdownFileHandlerLoaded());
this.markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl(); this.markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl();
return this.markdownPreviewHandlerControl; return this.markdownPreviewHandlerControl;
} }
} }
} }

View File

@ -1,161 +1,161 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="..\..\..\..\installer\Version.props" /> <Import Project="..\..\..\..\installer\Version.props" />
<!-- We don't have GenerateAssemblyInfo task until we use .net core, so we generate it with WriteLinesToFile --> <!-- We don't have GenerateAssemblyInfo task until we use .net core, so we generate it with WriteLinesToFile -->
<PropertyGroup> <PropertyGroup>
<AssemblyTitle>MarkdownPreviewHandler</AssemblyTitle> <AssemblyTitle>MarkdownPreviewHandler</AssemblyTitle>
<AssemblyDescription>PowerToys MarkdownPreviewHandler</AssemblyDescription> <AssemblyDescription>PowerToys MarkdownPreviewHandler</AssemblyDescription>
<AssemblyCompany>Microsoft Corp.</AssemblyCompany> <AssemblyCompany>Microsoft Corp.</AssemblyCompany>
<AssemblyCopyright>Copyright (C) 2020 Microsoft Corporation</AssemblyCopyright> <AssemblyCopyright>Copyright (C) 2020 Microsoft Corporation</AssemblyCopyright>
<AssemblyProduct>PowerToys</AssemblyProduct> <AssemblyProduct>PowerToys</AssemblyProduct>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<AssemblyVersionFiles Include="Generated Files\AssemblyInfo.cs" /> <AssemblyVersionFiles Include="Generated Files\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<Target Name="GenerateAssemblyInfo" BeforeTargets="PrepareForBuild"> <Target Name="GenerateAssemblyInfo" BeforeTargets="PrepareForBuild">
<ItemGroup> <ItemGroup>
<HeaderLines Include="// Copyright (c) Microsoft Corporation" /> <HeaderLines Include="// Copyright (c) Microsoft Corporation" />
<HeaderLines Include="// The Microsoft Corporation licenses this file to you under the MIT license." /> <HeaderLines Include="// The Microsoft Corporation licenses this file to you under the MIT license." />
<HeaderLines Include="// See the LICENSE file in the project root for more information." /> <HeaderLines Include="// See the LICENSE file in the project root for more information." />
<HeaderLines Include="#pragma warning disable SA1516" /> <HeaderLines Include="#pragma warning disable SA1516" />
<HeaderLines Include="using System.Reflection%3b" /> <HeaderLines Include="using System.Reflection%3b" />
<HeaderLines Include="using System.Resources%3b" /> <HeaderLines Include="using System.Resources%3b" />
<HeaderLines Include="using System.Runtime.CompilerServices%3b" /> <HeaderLines Include="using System.Runtime.CompilerServices%3b" />
<HeaderLines Include="using System.Runtime.InteropServices%3b" /> <HeaderLines Include="using System.Runtime.InteropServices%3b" />
<HeaderLines Include="[assembly: AssemblyTitle(&quot;$(AssemblyTitle)&quot;)]" /> <HeaderLines Include="[assembly: AssemblyTitle(&quot;$(AssemblyTitle)&quot;)]" />
<HeaderLines Include="[assembly: AssemblyDescription(&quot;$(AssemblyDescription)&quot;)]" /> <HeaderLines Include="[assembly: AssemblyDescription(&quot;$(AssemblyDescription)&quot;)]" />
<HeaderLines Include="[assembly: AssemblyConfiguration(&quot;&quot;)]" /> <HeaderLines Include="[assembly: AssemblyConfiguration(&quot;&quot;)]" />
<HeaderLines Include="[assembly: AssemblyCompany(&quot;$(AssemblyCompany)&quot;)]" /> <HeaderLines Include="[assembly: AssemblyCompany(&quot;$(AssemblyCompany)&quot;)]" />
<HeaderLines Include="[assembly: AssemblyCopyright(&quot;$(AssemblyCopyright)&quot;)]" /> <HeaderLines Include="[assembly: AssemblyCopyright(&quot;$(AssemblyCopyright)&quot;)]" />
<HeaderLines Include="[assembly: AssemblyProduct(&quot;$(AssemblyProduct)&quot;)]" /> <HeaderLines Include="[assembly: AssemblyProduct(&quot;$(AssemblyProduct)&quot;)]" />
<HeaderLines Include="[assembly: AssemblyTrademark(&quot;&quot;)]" /> <HeaderLines Include="[assembly: AssemblyTrademark(&quot;&quot;)]" />
<HeaderLines Include="[assembly: AssemblyCulture(&quot;&quot;)]" /> <HeaderLines Include="[assembly: AssemblyCulture(&quot;&quot;)]" />
<HeaderLines Include="[assembly: ComVisible(false)]" /> <HeaderLines Include="[assembly: ComVisible(false)]" />
<HeaderLines Include="[assembly: NeutralResourcesLanguage(&quot;en-US&quot;)]" /> <HeaderLines Include="[assembly: NeutralResourcesLanguage(&quot;en-US&quot;)]" />
<HeaderLines Include="[assembly: AssemblyVersion(&quot;$(Version).0&quot;)]" /> <HeaderLines Include="[assembly: AssemblyVersion(&quot;$(Version).0&quot;)]" />
<HeaderLines Include="[assembly: AssemblyFileVersion(&quot;$(Version).0&quot;)]" /> <HeaderLines Include="[assembly: AssemblyFileVersion(&quot;$(Version).0&quot;)]" />
</ItemGroup> </ItemGroup>
<WriteLinesToFile File="Generated Files\AssemblyInfo.cs" Lines="@(HeaderLines)" Overwrite="true" Encoding="Unicode" WriteOnlyWhenDifferent="true" /> <WriteLinesToFile File="Generated Files\AssemblyInfo.cs" Lines="@(HeaderLines)" Overwrite="true" Encoding="Unicode" WriteOnlyWhenDifferent="true" />
</Target> </Target>
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6A71162E-FC4C-4A2C-B90F-3CF94F59A9BB}</ProjectGuid> <ProjectGuid>{6A71162E-FC4C-4A2C-B90F-3CF94F59A9BB}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MarkdownPreviewHandler</RootNamespace> <RootNamespace>MarkdownPreviewHandler</RootNamespace>
<AssemblyName>MarkdownPreviewHandler</AssemblyName> <AssemblyName>MarkdownPreviewHandler</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath> <IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\</OutputPath> <OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\MarkdownPreviewPaneDocumentation.xml</DocumentationFile> <DocumentationFile>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\MarkdownPreviewPaneDocumentation.xml</DocumentationFile>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\</OutputPath> <OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\MarkdownPreviewPaneDocumentation.xml</DocumentationFile> <DocumentationFile>$(SolutionDir)$(Platform)\$(Configuration)\modules\FileExplorerPreview\MarkdownPreviewPaneDocumentation.xml</DocumentationFile>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>false</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile> </AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="HTMLParsingExtension.cs" /> <Compile Include="HTMLParsingExtension.cs" />
<Compile Include="MarkdownPreviewHandler.cs" /> <Compile Include="MarkdownPreviewHandler.cs" />
<Compile Include="MarkdownPreviewHandlerControl.cs"> <Compile Include="MarkdownPreviewHandlerControl.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Generated Files\AssemblyInfo.cs"> <Compile Include="Generated Files\AssemblyInfo.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\Settings.Designer.cs"> <Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
</Compile> </Compile>
<Compile Include="Telemetry\Events\MarkdownFileHandlerLoaded.cs" /> <Compile Include="Telemetry\Events\MarkdownFileHandlerLoaded.cs" />
<Compile Include="Telemetry\Events\MarkdownFilePreviewed.cs" /> <Compile Include="Telemetry\Events\MarkdownFilePreviewed.cs" />
<Compile Include="Telemetry\Events\MarkdownFilePreviewError.cs" /> <Compile Include="Telemetry\Events\MarkdownFilePreviewError.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="HtmlAgilityPack"> <PackageReference Include="HtmlAgilityPack">
<Version>1.11.23</Version> <Version>1.11.23</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Markdig.Signed"> <PackageReference Include="Markdig.Signed">
<Version>0.20.0</Version> <Version>0.20.0</Version>
</PackageReference> </PackageReference>
<PackageReference Include="StyleCop.Analyzers"> <PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version> <Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json"> <AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link> <Link>StyleCop.json</Link>
</AdditionalFiles> </AdditionalFiles>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj"> <ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj">
<Project>{5D00D290-4016-4CFE-9E41-1E7C724509BA}</Project> <Project>{5D00D290-4016-4CFE-9E41-1E7C724509BA}</Project>
<Name>Telemetry</Name> <Name>Telemetry</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj"> <ProjectReference Include="..\common\PreviewHandlerCommon.csproj">
<Project>{af2349b8-e5b6-4004-9502-687c1c7730b1}</Project> <Project>{af2349b8-e5b6-4004-9502-687c1c7730b1}</Project>
<Name>PreviewHandlerCommon</Name> <Name>PreviewHandlerCommon</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -1,192 +1,192 @@
// Copyright (c) Microsoft Corporation // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using Common; using Common;
using Markdig; using Markdig;
using MarkdownPreviewHandler.Properties; using MarkdownPreviewHandler.Properties;
using MarkdownPreviewHandler.Telemetry.Events; using MarkdownPreviewHandler.Telemetry.Events;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using PreviewHandlerCommon; using PreviewHandlerCommon;
namespace MarkdownPreviewHandler namespace MarkdownPreviewHandler
{ {
/// <summary> /// <summary>
/// Win Form Implementation for Markdown Preview Handler. /// Win Form Implementation for Markdown Preview Handler.
/// </summary> /// </summary>
public class MarkdownPreviewHandlerControl : FormHandlerControl public class MarkdownPreviewHandlerControl : FormHandlerControl
{ {
/// <summary> /// <summary>
/// Extension to modify markdown AST. /// Extension to modify markdown AST.
/// </summary> /// </summary>
private readonly HTMLParsingExtension extension; private readonly HTMLParsingExtension extension;
/// <summary> /// <summary>
/// Markdig Pipeline builder. /// Markdig Pipeline builder.
/// </summary> /// </summary>
private readonly MarkdownPipelineBuilder pipelineBuilder; private readonly MarkdownPipelineBuilder pipelineBuilder;
/// <summary> /// <summary>
/// Markdown HTML header. /// Markdown HTML header.
/// </summary> /// </summary>
private readonly string htmlHeader = "<!doctype html><style>body{width:100%;margin:0;font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}.container{padding:5%}body img{max-width:100%;height:auto}body h1,body h2,body h3,body h4,body h5,body h6{margin-top:24px;margin-bottom:16px;font-weight:600;line-height:1.25}body h1,body h2{padding-bottom:.3em;border-bottom:1px solid #eaecef}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji}body h3{font-size:1.25em}body h4{font-size:1em}body h5{font-size:.875em}body h6{font-size:.85em;color:#6a737d}pre{font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;background-color:#f6f8fa;border-radius:3px;padding:16px;font-size:85%}a{color:#0366d6}strong{font-weight:600}em{font-style:italic}code{padding:.2em .4em;margin:0;font-size:85%;background-color:#f6f8fa;border-radius:3px}hr{border-color:#EEE -moz-use-text-color #FFF;border-style:solid none;border-width:.5px 0;margin:18px 0}table{display:block;width:100%;overflow:auto;border-spacing:0;border-collapse:collapse}tbody{display:table-row-group;vertical-align:middle;border-color:inherit;vertical-align:inherit;border-color:inherit}table tr{background-color:#fff;border-top:1px solid #c6cbd1}tr{display:table-row;vertical-align:inherit;border-color:inherit}table td,table th{padding:6px 13px;border:1px solid #dfe2e5}th{font-weight:600;display:table-cell;vertical-align:inherit;font-weight:bold;text-align:-internal-center}thead{display:table-header-group;vertical-align:middle;border-color:inherit}td{display:table-cell;vertical-align:inherit}code,pre,tt{font-family:SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;color:#24292e;overflow-x:auto}pre code{font-size:inherit;color:inherit;word-break:normal}blockquote{background-color:#fff;border-radius:3px;padding:15px;font-size:14px;display:block;margin-block-start:1em;margin-block-end:1em;margin-inline-start:40px;margin-inline-end:40px;padding:0 1em;color:#6a737d;border-left:.25em solid #dfe2e5}</style><body><div class=\"container\">"; private readonly string htmlHeader = "<!doctype html><style>body{width:100%;margin:0;font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}.container{padding:5%}body img{max-width:100%;height:auto}body h1,body h2,body h3,body h4,body h5,body h6{margin-top:24px;margin-bottom:16px;font-weight:600;line-height:1.25}body h1,body h2{padding-bottom:.3em;border-bottom:1px solid #eaecef}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji}body h3{font-size:1.25em}body h4{font-size:1em}body h5{font-size:.875em}body h6{font-size:.85em;color:#6a737d}pre{font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;background-color:#f6f8fa;border-radius:3px;padding:16px;font-size:85%}a{color:#0366d6}strong{font-weight:600}em{font-style:italic}code{padding:.2em .4em;margin:0;font-size:85%;background-color:#f6f8fa;border-radius:3px}hr{border-color:#EEE -moz-use-text-color #FFF;border-style:solid none;border-width:.5px 0;margin:18px 0}table{display:block;width:100%;overflow:auto;border-spacing:0;border-collapse:collapse}tbody{display:table-row-group;vertical-align:middle;border-color:inherit;vertical-align:inherit;border-color:inherit}table tr{background-color:#fff;border-top:1px solid #c6cbd1}tr{display:table-row;vertical-align:inherit;border-color:inherit}table td,table th{padding:6px 13px;border:1px solid #dfe2e5}th{font-weight:600;display:table-cell;vertical-align:inherit;font-weight:bold;text-align:-internal-center}thead{display:table-header-group;vertical-align:middle;border-color:inherit}td{display:table-cell;vertical-align:inherit}code,pre,tt{font-family:SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;color:#24292e;overflow-x:auto}pre code{font-size:inherit;color:inherit;word-break:normal}blockquote{background-color:#fff;border-radius:3px;padding:15px;font-size:14px;display:block;margin-block-start:1em;margin-block-end:1em;margin-inline-start:40px;margin-inline-end:40px;padding:0 1em;color:#6a737d;border-left:.25em solid #dfe2e5}</style><body><div class=\"container\">";
/// <summary> /// <summary>
/// Markdown HTML footer. /// Markdown HTML footer.
/// </summary> /// </summary>
private readonly string htmlFooter = "</div></body></html>"; private readonly string htmlFooter = "</div></body></html>";
/// <summary> /// <summary>
/// RichTextBox control to display if external images are blocked. /// RichTextBox control to display if external images are blocked.
/// </summary> /// </summary>
private RichTextBox infoBar; private RichTextBox infoBar;
/// <summary> /// <summary>
/// Extended Browser Control to display markdown html. /// Extended Browser Control to display markdown html.
/// </summary> /// </summary>
private WebBrowserExt browser; private WebBrowserExt browser;
/// <summary> /// <summary>
/// True if external image is blocked, false otherwise. /// True if external image is blocked, false otherwise.
/// </summary> /// </summary>
private bool infoBarDisplayed = false; private bool infoBarDisplayed = false;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MarkdownPreviewHandlerControl"/> class. /// Initializes a new instance of the <see cref="MarkdownPreviewHandlerControl"/> class.
/// </summary> /// </summary>
public MarkdownPreviewHandlerControl() public MarkdownPreviewHandlerControl()
{ {
this.extension = new HTMLParsingExtension(this.ImagesBlockedCallBack); this.extension = new HTMLParsingExtension(this.ImagesBlockedCallBack);
this.pipelineBuilder = new MarkdownPipelineBuilder().UseAdvancedExtensions().UseEmojiAndSmiley(); this.pipelineBuilder = new MarkdownPipelineBuilder().UseAdvancedExtensions().UseEmojiAndSmiley();
this.pipelineBuilder.Extensions.Add(this.extension); this.pipelineBuilder.Extensions.Add(this.extension);
} }
/// <summary> /// <summary>
/// Start the preview on the Control. /// Start the preview on the Control.
/// </summary> /// </summary>
/// <param name="dataSource">Path to the file.</param> /// <param name="dataSource">Path to the file.</param>
public override void DoPreview<T>(T dataSource) public override void DoPreview<T>(T dataSource)
{ {
this.infoBarDisplayed = false; this.infoBarDisplayed = false;
try try
{ {
if (!(dataSource is string filePath)) if (!(dataSource is string filePath))
{ {
throw new ArgumentException($"{nameof(dataSource)} for {nameof(MarkdownPreviewHandler)} must be a string but was a '{typeof(T)}'"); throw new ArgumentException($"{nameof(dataSource)} for {nameof(MarkdownPreviewHandler)} must be a string but was a '{typeof(T)}'");
} }
string fileText = File.ReadAllText(filePath); string fileText = File.ReadAllText(filePath);
Regex imageTagRegex = new Regex(@"<[ ]*img.*>"); Regex imageTagRegex = new Regex(@"<[ ]*img.*>");
if (imageTagRegex.IsMatch(fileText)) if (imageTagRegex.IsMatch(fileText))
{ {
this.infoBarDisplayed = true; this.infoBarDisplayed = true;
} }
this.extension.BaseUrl = Path.GetDirectoryName(filePath); this.extension.BaseUrl = Path.GetDirectoryName(filePath);
MarkdownPipeline pipeline = this.pipelineBuilder.Build(); MarkdownPipeline pipeline = this.pipelineBuilder.Build();
string parsedMarkdown = Markdown.ToHtml(fileText, pipeline); string parsedMarkdown = Markdown.ToHtml(fileText, pipeline);
string markdownHTML = $"{this.htmlHeader}{parsedMarkdown}{this.htmlFooter}"; string markdownHTML = $"{this.htmlHeader}{parsedMarkdown}{this.htmlFooter}";
this.InvokeOnControlThread(() => this.InvokeOnControlThread(() =>
{ {
this.browser = new WebBrowserExt this.browser = new WebBrowserExt
{ {
DocumentText = markdownHTML, DocumentText = markdownHTML,
Dock = DockStyle.Fill, Dock = DockStyle.Fill,
IsWebBrowserContextMenuEnabled = false, IsWebBrowserContextMenuEnabled = false,
ScriptErrorsSuppressed = true, ScriptErrorsSuppressed = true,
ScrollBarsEnabled = true, ScrollBarsEnabled = true,
AllowNavigation = false, AllowNavigation = false,
}; };
this.Controls.Add(this.browser); this.Controls.Add(this.browser);
if (this.infoBarDisplayed) if (this.infoBarDisplayed)
{ {
this.infoBar = this.GetTextBoxControl(Resources.BlockedImageInfoText); this.infoBar = this.GetTextBoxControl(Resources.BlockedImageInfoText);
this.Resize += this.FormResized; this.Resize += this.FormResized;
this.Controls.Add(this.infoBar); this.Controls.Add(this.infoBar);
} }
}); });
PowerToysTelemetry.Log.WriteEvent(new MarkdownFilePreviewed()); PowerToysTelemetry.Log.WriteEvent(new MarkdownFilePreviewed());
} }
catch (Exception e) catch (Exception e)
{ {
PowerToysTelemetry.Log.WriteEvent(new MarkdownFilePreviewError { Message = e.Message }); PowerToysTelemetry.Log.WriteEvent(new MarkdownFilePreviewError { Message = e.Message });
this.InvokeOnControlThread(() => this.InvokeOnControlThread(() =>
{ {
this.Controls.Clear(); this.Controls.Clear();
this.infoBarDisplayed = true; this.infoBarDisplayed = true;
this.infoBar = this.GetTextBoxControl(Resources.MarkdownNotPreviewedError); this.infoBar = this.GetTextBoxControl(Resources.MarkdownNotPreviewedError);
this.Resize += this.FormResized; this.Resize += this.FormResized;
this.Controls.Add(this.infoBar); this.Controls.Add(this.infoBar);
}); });
} }
finally finally
{ {
base.DoPreview(dataSource); base.DoPreview(dataSource);
} }
} }
/// <summary> /// <summary>
/// Gets a textbox control. /// Gets a textbox control.
/// </summary> /// </summary>
/// <param name="message">Message to be displayed in textbox.</param> /// <param name="message">Message to be displayed in textbox.</param>
/// <returns>An object of type <see cref="RichTextBox"/>.</returns> /// <returns>An object of type <see cref="RichTextBox"/>.</returns>
private RichTextBox GetTextBoxControl(string message) private RichTextBox GetTextBoxControl(string message)
{ {
RichTextBox richTextBox = new RichTextBox RichTextBox richTextBox = new RichTextBox
{ {
Text = message, Text = message,
BackColor = Color.LightYellow, BackColor = Color.LightYellow,
Multiline = true, Multiline = true,
Dock = DockStyle.Top, Dock = DockStyle.Top,
ReadOnly = true, ReadOnly = true,
}; };
richTextBox.ContentsResized += this.RTBContentsResized; richTextBox.ContentsResized += this.RTBContentsResized;
richTextBox.ScrollBars = RichTextBoxScrollBars.None; richTextBox.ScrollBars = RichTextBoxScrollBars.None;
richTextBox.BorderStyle = BorderStyle.None; richTextBox.BorderStyle = BorderStyle.None;
return richTextBox; return richTextBox;
} }
/// <summary> /// <summary>
/// Callback when RichTextBox is resized. /// Callback when RichTextBox is resized.
/// </summary> /// </summary>
/// <param name="sender">Reference to resized control.</param> /// <param name="sender">Reference to resized control.</param>
/// <param name="e">Provides data for the resize event.</param> /// <param name="e">Provides data for the resize event.</param>
private void RTBContentsResized(object sender, ContentsResizedEventArgs e) private void RTBContentsResized(object sender, ContentsResizedEventArgs e)
{ {
RichTextBox richTextBox = (RichTextBox)sender; RichTextBox richTextBox = (RichTextBox)sender;
richTextBox.Height = e.NewRectangle.Height + 5; richTextBox.Height = e.NewRectangle.Height + 5;
} }
/// <summary> /// <summary>
/// Callback when form is resized. /// Callback when form is resized.
/// </summary> /// </summary>
/// <param name="sender">Reference to resized control.</param> /// <param name="sender">Reference to resized control.</param>
/// <param name="e">Provides data for the event.</param> /// <param name="e">Provides data for the event.</param>
private void FormResized(object sender, EventArgs e) private void FormResized(object sender, EventArgs e)
{ {
if (this.infoBarDisplayed) if (this.infoBarDisplayed)
{ {
this.infoBar.Width = this.Width; this.infoBar.Width = this.Width;
} }
} }
/// <summary> /// <summary>
/// Callback when image is blocked by extension. /// Callback when image is blocked by extension.
/// </summary> /// </summary>
private void ImagesBlockedCallBack() private void ImagesBlockedCallBack()
{ {
this.infoBarDisplayed = true; this.infoBarDisplayed = true;
} }
} }
} }

View File

@ -1,81 +1,81 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.42000 // Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace MarkdownPreviewHandler.Properties { namespace MarkdownPreviewHandler.Properties {
using System; using System;
/// <summary> /// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc. /// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary> /// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder // This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { internal class Resources {
private static global::System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() { internal Resources() {
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MarkdownPreviewHandler.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MarkdownPreviewHandler.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
} }
} }
/// <summary> /// <summary>
/// Overrides the current thread's CurrentUICulture property for all /// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class. /// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture { internal static global::System.Globalization.CultureInfo Culture {
get { get {
return resourceCulture; return resourceCulture;
} }
set { set {
resourceCulture = value; resourceCulture = value;
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Some pictures have been blocked to help prevent the sender from identifying this computer. Open this item to view pictures.. /// Looks up a localized string similar to Some pictures have been blocked to help prevent the sender from identifying this computer. Open this item to view pictures..
/// </summary> /// </summary>
internal static string BlockedImageInfoText { internal static string BlockedImageInfoText {
get { get {
return ResourceManager.GetString("BlockedImageInfoText", resourceCulture); return ResourceManager.GetString("BlockedImageInfoText", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to The markdown could not be preview due to an internal error.. /// Looks up a localized string similar to The markdown could not be preview due to an internal error..
/// </summary> /// </summary>
internal static string MarkdownNotPreviewedError { internal static string MarkdownNotPreviewedError {
get { get {
return ResourceManager.GetString("MarkdownNotPreviewedError", resourceCulture); return ResourceManager.GetString("MarkdownNotPreviewedError", resourceCulture);
} }
} }
} }
} }

View File

@ -1,128 +1,128 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata"> <xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
<xsd:complexType> <xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="data"> <xsd:element name="data">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:schema> </xsd:schema>
<resheader name="resmimetype"> <resheader name="resmimetype">
<value>text/microsoft-resx</value> <value>text/microsoft-resx</value>
</resheader> </resheader>
<resheader name="version"> <resheader name="version">
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="BlockedImageInfoText" xml:space="preserve"> <data name="BlockedImageInfoText" xml:space="preserve">
<value>Some pictures have been blocked to help prevent the sender from identifying this computer. Open this item to view pictures.</value> <value>Some pictures have been blocked to help prevent the sender from identifying this computer. Open this item to view pictures.</value>
<comment>This text is displayed if image is blocked from being displayed.</comment> <comment>This text is displayed if image is blocked from being displayed.</comment>
</data> </data>
<data name="MarkdownNotPreviewedError" xml:space="preserve"> <data name="MarkdownNotPreviewedError" xml:space="preserve">
<value>The markdown could not be preview due to an internal error.</value> <value>The markdown could not be preview due to an internal error.</value>
<comment>This text is displayed if markdown fails to preview</comment> <comment>This text is displayed if markdown fails to preview</comment>
</data> </data>
</root> </root>

View File

@ -1,23 +1,23 @@
// Copyright (c) Microsoft Corporation // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events; using Microsoft.PowerToys.Telemetry.Events;
namespace MarkdownPreviewHandler.Telemetry.Events namespace MarkdownPreviewHandler.Telemetry.Events
{ {
/// <summary> /// <summary>
/// A telemetry event that is triggered when an error occurs while attempting to view a markdown file in the preview pane. /// A telemetry event that is triggered when an error occurs while attempting to view a markdown file in the preview pane.
/// </summary> /// </summary>
public class MarkdownFilePreviewError : EventBase, IEvent public class MarkdownFilePreviewError : EventBase, IEvent
{ {
/// <summary> /// <summary>
/// Gets or sets the error message. /// Gets or sets the error message.
/// </summary> /// </summary>
public string Message { get; set; } public string Message { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance; public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
} }
} }

View File

@ -1,20 +1,20 @@
// Copyright (c) Microsoft Corporation // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Diagnostics.Tracing; using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events; using Microsoft.PowerToys.Telemetry.Events;
namespace MarkdownPreviewHandler.Telemetry.Events namespace MarkdownPreviewHandler.Telemetry.Events
{ {
/// <summary> /// <summary>
/// A telemetry event that is triggered when a markdown file is viewed in the preview pane. /// A telemetry event that is triggered when a markdown file is viewed in the preview pane.
/// </summary> /// </summary>
[EventData] [EventData]
public class MarkdownFilePreviewed : EventBase, IEvent public class MarkdownFilePreviewed : EventBase, IEvent
{ {
/// <inheritdoc/> /// <inheritdoc/>
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
} }
} }

View File

@ -108,7 +108,7 @@
<Project>{AF2349B8-E5B6-4004-9502-687C1C7730B1}</Project> <Project>{AF2349B8-E5B6-4004-9502-687C1C7730B1}</Project>
<Name>PreviewHandlerCommon</Name> <Name>PreviewHandlerCommon</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\MarkDownPreviewHandler\MarkdownPreviewHandler.csproj"> <ProjectReference Include="..\MarkdownPreviewHandler\MarkdownPreviewHandler.csproj">
<Project>{6a71162e-fc4c-4a2c-b90f-3cf94f59a9bb}</Project> <Project>{6a71162e-fc4c-4a2c-b90f-3cf94f59a9bb}</Project>
<Name>MarkdownPreviewHandler</Name> <Name>MarkdownPreviewHandler</Name>
</ProjectReference> </ProjectReference>