EnlighterJS / Plugin.WordPress

:package: Official WordPress Plugin of EnlighterJS
http://wordpress.org/plugins/enlighter/
GNU General Public License v2.0
117 stars 17 forks source link

Copy and Extern action results in extra XML data in output #367

Closed HarmVeenstra closed 1 year ago

HarmVeenstra commented 1 year ago

If users copy PowerShell code from blog posts on my website powershellisfun.com, they receive extra XML tags like this in the output:

$codeblock = ""

The original code was:

$codeblock = "``````"

(Blog post : https://powershellisfun.com/2023/02/01/export-pipeline-output-to-a-markdown-file-using-powershell/)

Another example:

Write-Host ("[Install printer driver(s)]n") -ForegroundColor Green

Original code:

Write-Host ("`n[Add printerdriver(s) to Windows]") -ForegroundColor Green

(Blog post: https://powershellisfun.com/2022/12/05/adding-printer-drivers-and-printers-using-microsoft-intune-and-powershell/)

HarmVeenstra commented 1 year ago

GitHub removed that, it looks like this

image

and

image

AndiDittrich commented 1 year ago

please test and reproduce your issue within a clean environment

HarmVeenstra commented 1 year ago

And how should I do that? I don't have another Wordpress site?

AndiDittrich commented 1 year ago

local webserver or staging environment such issues are in 99,9% of all cases caused by a theme or third party plugin.... for me it's extremely frustrating and time consuming to debug users websites..

without providing a real code snippet i'm unable to test it. btw i'll move it to the wordpress plugin repo - please answer all questions within the issue template..

HarmVeenstra commented 1 year ago

For example this code:

Start-Transcript -Path c:\windows\temp\printers.log

Read printers.csv as input

$Printers = Import-Csv .\printers.csv

Add all printer drivers by scanning for the .inf files and installing them using pnputil.exe

$infs = get-childitem -Path . -Filter "*.inf" -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Fullname

$totalnumberofinfs = $infs.Count $currentnumber = 1 Write-Host ("[Install printer driver(s)]`n") -ForegroundColor Green Foreach ($inf in $infs) { Write-Host ("[{0}/{1}] Adding inf file {2}" -f $currentnumber, $totalnumberofinfs, $inf) -ForegroundColor Green try { c:\windows\sysnative\Pnputil.exe /a $inf | Out-Null } catch { try { c:\windows\system32\Pnputil.exe /a $inf | Out-Null } catch { C:\Windows\SysWOW64\pnputil.exe /a $inf | Out-Null } } $currentnumber++ }

Add all installed drivers to Windows using the CSV list for the correct names

$totalnumberofdrivers = ($printers.drivername | Select-Object -Unique).count $currentnumber = 1 Write-Host ("`n[Add printerdriver(s) to Windows]") -ForegroundColor Green foreach ($driver in $printers.drivername | Select-Object -Unique) { Write-Host ("[{0}/{1}] Adding printerdriver {2}" -f $currentnumber, $totalnumberofdrivers, $driver) -ForegroundColor Green Add-PrinterDriver -Name $driver $currentnumber++ }

is translated to this

image

AndiDittrich commented 1 year ago

do you've enabled "markdown" as editing method but still using the visual integration ?

HarmVeenstra commented 1 year ago

I did enable MarkDown support in WordPress, yes. I use Enlighter with PowerShell support for better visuals and line numbers. The screenshot above is from what you get when using the Copy button, it adds XML-like tags

HarmVeenstra commented 1 year ago

image Looks like this on the WordPress page

AndiDittrich commented 1 year ago

disable the markdown support. you cannot use both.

HarmVeenstra commented 1 year ago

image

Switched it and yes! Thanks, forgot about that!