Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jaliyaudagedara opened this issue Oct 20, 2021 · 12 comments

Comments

@jaliyaudagedara
Copy link

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
Copy link
Member

olegtk commented Oct 20, 2021

@KirillOsenkov

@KirillOsenkov
Copy link
Member

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:

string result = ToolsOptionsPage.Instance.BeforeCodeSnippet;

@KirillOsenkov
Copy link
Member

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
Copy link
Member

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

@Ziflin
Copy link

Ziflin commented Jul 8, 2022

@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
Copy link

ploeh commented Jul 26, 2022

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

@kkbruce
Copy link

kkbruce commented Dec 1, 2022

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
Copy link

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
Copy link

ploeh commented Jan 7, 2023

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
Copy link
Member

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
Copy link

ploeh commented Jan 29, 2023

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
Copy link
Author

Looks good to me.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants