microsoft / VS-PPT

Productivity Power Tools - a set of Visual Studio extensions improving developer productivity.
http://aka.ms/extendvs
Other
885 stars 146 forks source link

Copy As Html 2022: BeforeCodeSnippet and AfterCodeSnippet options not being honored #252

Open jaliyaudagedara opened 3 years ago

jaliyaudagedara commented 3 years ago

I have modified HTML Copy options (under Tools > Options > Productive Power Tools > HTML Copy) adding BeforeCodeSnippet and AfterCodeSnippet. It doesn't seem to honor these. image

BeforeCodeSnippt,

</pre></div>

AfterCodeSnippet,

<div style="margin: 10px 0; padding: 5px 10px; overflow: auto; border: 1px #c0c0c0 solid;"><pre style="{font-weight}{font-style}{color}{background};font-size:8pt;margin:5px 0px 5px 1px">

When I do Copy Html Markup on following, image

The output,

<pre style="font-family:Cascadia Mono;font-size:13px;color:black;background:white;"><span style="color:green;">//&nbsp;See&nbsp;https://aka.ms/new-console-template&nbsp;for&nbsp;more&nbsp;information</span>
Console.WriteLine(<span style="color:#a31515;">&quot;Hello,&nbsp;World!&quot;</span>);</pre>

It's missing the wrapper.

Environment Information:

Microsoft Visual Studio Enterprise 2022 Preview
Version 17.0.0 Preview 6.0
VisualStudio.17.Preview/17.0.0-pre.6.0+31815.197
Microsoft .NET Framework
Version 4.8.04161

Installed Version: Enterprise

Copy As HTML 2022 Version: 17.0.1
olegtk commented 3 years ago

@Kirillosenkov

KirillOsenkov commented 3 years ago

One weird thing I'm noticing is that the copy as html assembly is loaded twice: image

@olegtk any idea why that is?

Also it feels like changes to the Copy HTML page in Tools Options have no effect. When reading the values here, we get the default values: https://github.com/microsoft/VS-PPT/blob/ee92b43da16d78a1f0e7b117f5a8c24a1704d581/src/CopyAsHtml/CopyAsHtml/HtmlMarkupProvider.cs#L38

KirillOsenkov commented 3 years ago

Yup, the extension reads the ToolsOptionsPage.Instance from the CopyAsHtml assembly, but the tools options page edits the ToolsOptionsPage.Instance from the CopyAsHtml2022 assembly.

KirillOsenkov commented 3 years ago

@olegtk back to you, the problem is with having two copies of the assembly loaded (regular and 2022)

Ziflin commented 2 years ago

@olegtk @KirillOsenkov Has this been fixed in 2022? I just re-installed the latest and it appears that none of the options are being honored. We have been using a custom BeforeCodeSnippet for years to adjust the font size for code pasted into OneNote and not being able to set the to our previous setting is quite frustrating.

Was there some way to get this to work properly?

I'm also noticing that the pasted output is not properly inserting line breaks for lines ending with comments. This results in the next line of code appearing on the same line as the previous. I think this is because the "ReplaceLineBreaksWithBR" option is not being honored and OneNote requires it to format pre blocks properly?

ploeh commented 2 years ago

I'm having this problem as well. Is there a workaround or update for this?

kkbruce commented 1 year ago

Copy As Html is an important function for us to make PowerPoint or documents. Now we can only copy the VS code to VSC to achieve the effect similar to Copy As Html. Hopes it can be repaired as soon as possible.

daryllabar commented 1 year ago

Simplest thing I've found is to open VS 2019 and use Copy As Html there. It works and appears to honor settings correctly.

ploeh commented 1 year ago

Simplest thing I've found is to open VS 2019 and use Copy As Html there. It works and appears to honor settings correctly.

That's what I'm currently doing, but it's also the only reason I have for keeping VS 2019 around. That's not a sustainable solution, as support of that is going to run out. Likewise, sooner or later, there will be language features that aren't supported in VS 2019, so that opening a solution in that version may no longer work.

BertanAygun commented 1 year ago

Hi,

I just pushed a version 17.0.2 to https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.CopyAsHtml2022 fixing this issue.

The copy operation also now honors "Use accurate classifier' option in Text Editor -> Advanced settings so that copied text includes correct colors in code files.

Thanks, Bertan

ploeh commented 1 year ago

Casual testing seems to indicate that it now works for my use case. I'll write again if I discover any issues. Thank you.

jaliyaudagedara commented 1 year ago

Looks good to me. image