Code Monkey home page Code Monkey logo

Comments (37)

mysticmind avatar mysticmind commented on August 22, 2024 2

Glad that you have got it working 👏
I will release v3.14.0 in my morning tomo.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024 1

Acknowledge the issue which you have posted, let me check and get back to you shortly.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024 1

I see, it doesn't. Would it be possible to add an option to overwrite it? (as in always set it to given value)?

The way for you to make it work is to have pre-process step to massage the html to add the language class to pre tag and then send it to the converter to process the same.

Edit: currently, we don't have an option to override or set it based on some config.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024 1

The output:

image

It doesn't seem to do it properly. So either you sent me wrong version or I'm doing something wrong. Also it seems that 2x new line is added for

tags

I am heading to bed now, will check and revert to you tomorrow.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024 1

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

@PrzemyslawKlys I have applied a local fix in my dev and providing the output below. please confirm if it looks fine.

###############################################################################################################################################################################################################################################
# Author Thiago Beier [email protected]   
# Version: 1.0 - 2020-03-09  
# List sum of total users, total enabled accounts, total disabled accounts in ADDS (you can restrict the search to a specific OU - line 12 and 13
# Toronto, CANADA   
# Email: [email protected] 
# https://www.linkedin.com/in/tbeier/ 
# https://twitter.com/thiagobeier
# thiagobeier.wordpress.com
###############################################################################################################################################################################################################################################  

#Get-ADUser -Filter * -SearchBase "OU=Field,OU=Users,OU=Toronto,DC=canada,DC=local" |fl name | measure
$userstotal = Get-ADUser -Filter * -SearchBase "DC=canada,DC=local" |fl name | measure
$usersenabled = Get-ADUser -Filter {Enabled -eq $true} | fl name | measure
$usersdisabled = Get-ADUser -Filter {Enabled -eq $false} | fl name | measure
write-host -ForegroundColor Magenta "########################## ADDS - TGAM - Users Report ###########################"
Write-Host -ForegroundColor Yellow "Total Users" $userstotal.Count
Write-Host -ForegroundColor Green "Enabled Users" $usersenabled.Count
Write-Host -ForegroundColor Cyan "Disabled Users" $usersdisabled.Count
write-host -ForegroundColor Magenta "#################################################################################"




<span class="powerShell__com">###############################################################################################################################################################################################################################################</span> 
<span class="powerShell__com"># Author Thiago Beier [email protected]   </span> 
<span class="powerShell__com"># Version: 1.0 - 2020-03-09  </span> 
<span class="powerShell__com"># List sum of total users, total enabled accounts, total disabled accounts in ADDS (you can restrict the search to a specific OU - line 12 and 13</span> 
<span class="powerShell__com"># Toronto, CANADA   </span> 
<span class="powerShell__com"># Email: [email protected] </span> 
<span class="powerShell__com"># https://www.linkedin.com/in/tbeier/ </span> 
<span class="powerShell__com"># https://twitter.com/thiagobeier</span> 
<span class="powerShell__com"># thiagobeier.wordpress.com</span> 
<span class="powerShell__com">###############################################################################################################################################################################################################################################  </span> 
 
<span class="powerShell__com">#Get-ADUser -Filter * -SearchBase "OU=Field,OU=Users,OU=Toronto,DC=canada,DC=local" |fl name | measure</span> 
<span class="powerShell__variable">$userstotal</span> = Get<span class="powerShell__operator">-</span>ADUser <span class="powerShell__operator">-</span><span class="powerShell__keyword">Filter</span> <span class="powerShell__operator">*</span> <span class="powerShell__operator">-</span>SearchBase <span class="powerShell__string">"DC=canada,DC=local"</span> <span class="powerShell__operator">|</span><span class="powerShell__alias">fl</span> name <span class="powerShell__operator">|</span> measure 
<span class="powerShell__variable">$usersenabled</span> = Get<span class="powerShell__operator">-</span>ADUser <span class="powerShell__operator">-</span><span class="powerShell__keyword">Filter</span> {Enabled <span class="powerShell__operator">-</span>eq <span class="powerShell__variable">$true</span>} <span class="powerShell__operator">|</span> <span class="powerShell__alias">fl</span> name <span class="powerShell__operator">|</span> measure 
<span class="powerShell__variable">$usersdisabled</span> = Get<span class="powerShell__operator">-</span>ADUser <span class="powerShell__operator">-</span><span class="powerShell__keyword">Filter</span> {Enabled <span class="powerShell__operator">-</span>eq <span class="powerShell__variable">$false</span>} <span class="powerShell__operator">|</span> <span class="powerShell__alias">fl</span> name <span class="powerShell__operator">|</span> measure 
write<span class="powerShell__operator">-</span>host <span class="powerShell__operator">-</span>ForegroundColor Magenta <span class="powerShell__string">"########################## ADDS - TGAM - Users Report ###########################"</span> 
Write<span class="powerShell__operator">-</span>Host <span class="powerShell__operator">-</span>ForegroundColor Yellow <span class="powerShell__string">"Total Users"</span> <span class="powerShell__variable">$userstotal</span>.Count 
Write<span class="powerShell__operator">-</span>Host <span class="powerShell__operator">-</span>ForegroundColor Green <span class="powerShell__string">"Enabled Users"</span> <span class="powerShell__variable">$usersenabled</span>.Count 
Write<span class="powerShell__operator">-</span>Host <span class="powerShell__operator">-</span>ForegroundColor Cyan <span class="powerShell__string">"Disabled Users"</span> <span class="powerShell__variable">$usersdisabled</span>.Count 
write<span class="powerShell__operator">-</span>host <span class="powerShell__operator">-</span>ForegroundColor Magenta <span class="powerShell__string">"#################################################################################"</span>

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

Yes. The first PRE is the one I need, the 2nd pre is one that seems to be doing coloring (so doubled code). Is there a way to "pick" which one I want?

Is there a way I can test it on more files? (I've got like few thousands of them).

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

As additional question - will your code convert link within <P> tags to markdown as well?

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

Yes. The first PRE is the one I need, the 2nd pre is one that seems to be doing coloring (so doubled code). Is there a way to "pick" which one I want?

Is there a way I can test it on more files? (I've got like few thousands of them).

With regards to picking which one you want, you have to run a pre-process step (using something like HtmlAgilityPack) to remove what you don't need from the html and then pass it to the converter.

The attached zip file contains the NuGet package file which you can use for your tests. Unzip into a folder and add the folder as a NuGet source to use
ReverseMarkdown.3.13.0-test.zip

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

Is it possible to provide language flavor for PRE tags? So one can decide if it's powershell, c#, js or something else?

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

As additional question - will your code convert link within <P> tags to markdown as well?

Any child elements of anchor tag gets processed. Please run a test with your use case and let me know your results.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

Is it possible to provide language flavor for PRE tags? So one can decide if it's powershell, c#, js or something else?

Language parsing will work if you use Github flavoured markdown with the config below:

var config = new Config
{
    GithubFlavored = true
};

Look at some of the examples in in unit tests. Search for language.

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

Ye, but I mean giving it a name. Such as: ```powershell

###############################################################################################################################################################################################################################################
# Author Thiago Beier [email protected]   
# Version: 1.0 - 2020-03-09  
# List sum of total users, total enabled accounts, total disabled accounts in ADDS (you can restrict the search to a specific OU - line 12 and 13
# Toronto, CANADA   
# Email: [email protected] 
# https://www.linkedin.com/in/tbeier/ 
# https://twitter.com/thiagobeier
# thiagobeier.wordpress.com
###############################################################################################################################################################################################################################################  

#Get-ADUser -Filter * -SearchBase "OU=Field,OU=Users,OU=Toronto,DC=canada,DC=local" |fl name | measure
$userstotal = Get-ADUser -Filter * -SearchBase "DC=canada,DC=local" |fl name | measure
$usersenabled = Get-ADUser -Filter {Enabled -eq $true} | fl name | measure
$usersdisabled = Get-ADUser -Filter {Enabled -eq $false} | fl name | measure
write-host -ForegroundColor Magenta "########################## ADDS - TGAM - Users Report ###########################"
Write-Host -ForegroundColor Yellow "Total Users" $userstotal.Count
Write-Host -ForegroundColor Green "Enabled Users" $usersenabled.Count
Write-Host -ForegroundColor Cyan "Disabled Users" $usersdisabled.Count
write-host -ForegroundColor Magenta "#################################################################################"

I've used GitHubFlavored and it just gave me ``` which is enough, but cooler would be with PowerShell formatting.

###############################################################################################################################################################################################################################################
# Author Thiago Beier [email protected]   
# Version: 1.0 - 2020-03-09  
# List sum of total users, total enabled accounts, total disabled accounts in ADDS (you can restrict the search to a specific OU - line 12 and 13
# Toronto, CANADA   
# Email: [email protected] 
# https://www.linkedin.com/in/tbeier/ 
# https://twitter.com/thiagobeier
# thiagobeier.wordpress.com
###############################################################################################################################################################################################################################################  

#Get-ADUser -Filter * -SearchBase "OU=Field,OU=Users,OU=Toronto,DC=canada,DC=local" |fl name | measure
$userstotal = Get-ADUser -Filter * -SearchBase "DC=canada,DC=local" |fl name | measure
$usersenabled = Get-ADUser -Filter {Enabled -eq $true} | fl name | measure
$usersdisabled = Get-ADUser -Filter {Enabled -eq $false} | fl name | measure
write-host -ForegroundColor Magenta "########################## ADDS - TGAM - Users Report ###########################"
Write-Host -ForegroundColor Yellow "Total Users" $userstotal.Count
Write-Host -ForegroundColor Green "Enabled Users" $usersenabled.Count
Write-Host -ForegroundColor Cyan "Disabled Users" $usersdisabled.Count
write-host -ForegroundColor Magenta "#################################################################################"

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

Ye, but I mean giving it a name. Such as: ```powershell

###############################################################################################################################################################################################################################################
# Author Thiago Beier [email protected]   
# Version: 1.0 - 2020-03-09  
# List sum of total users, total enabled accounts, total disabled accounts in ADDS (you can restrict the search to a specific OU - line 12 and 13
# Toronto, CANADA   
# Email: [email protected] 
# https://www.linkedin.com/in/tbeier/ 
# https://twitter.com/thiagobeier
# thiagobeier.wordpress.com
###############################################################################################################################################################################################################################################  

#Get-ADUser -Filter * -SearchBase "OU=Field,OU=Users,OU=Toronto,DC=canada,DC=local" |fl name | measure
$userstotal = Get-ADUser -Filter * -SearchBase "DC=canada,DC=local" |fl name | measure
$usersenabled = Get-ADUser -Filter {Enabled -eq $true} | fl name | measure
$usersdisabled = Get-ADUser -Filter {Enabled -eq $false} | fl name | measure
write-host -ForegroundColor Magenta "########################## ADDS - TGAM - Users Report ###########################"
Write-Host -ForegroundColor Yellow "Total Users" $userstotal.Count
Write-Host -ForegroundColor Green "Enabled Users" $usersenabled.Count
Write-Host -ForegroundColor Cyan "Disabled Users" $usersdisabled.Count
write-host -ForegroundColor Magenta "#################################################################################"

I've used GitHubFlavored and it just gave me ``` which is enough, but cooler would be with PowerShell formatting.

###############################################################################################################################################################################################################################################
# Author Thiago Beier [email protected]   
# Version: 1.0 - 2020-03-09  
# List sum of total users, total enabled accounts, total disabled accounts in ADDS (you can restrict the search to a specific OU - line 12 and 13
# Toronto, CANADA   
# Email: [email protected] 
# https://www.linkedin.com/in/tbeier/ 
# https://twitter.com/thiagobeier
# thiagobeier.wordpress.com
###############################################################################################################################################################################################################################################  

#Get-ADUser -Filter * -SearchBase "OU=Field,OU=Users,OU=Toronto,DC=canada,DC=local" |fl name | measure
$userstotal = Get-ADUser -Filter * -SearchBase "DC=canada,DC=local" |fl name | measure
$usersenabled = Get-ADUser -Filter {Enabled -eq $true} | fl name | measure
$usersdisabled = Get-ADUser -Filter {Enabled -eq $false} | fl name | measure
write-host -ForegroundColor Magenta "########################## ADDS - TGAM - Users Report ###########################"
Write-Host -ForegroundColor Yellow "Total Users" $userstotal.Count
Write-Host -ForegroundColor Green "Enabled Users" $usersenabled.Count
Write-Host -ForegroundColor Cyan "Disabled Users" $usersdisabled.Count
write-host -ForegroundColor Magenta "#################################################################################"

if your pre tag has any language marker class then it will add the language to the fenced code block. See the examples in unit tests. Also you can see the Pre.cs to see how this works.

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

I see, it doesn't. Would it be possible to add an option to overwrite it? (as in always set it to given value)?

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

The output:

image

It doesn't seem to do it properly. So either you sent me wrong version or I'm doing something wrong. Also it seems that 2x new line is added for

tags

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

Any luck?

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

@PrzemyslawKlys quick note, I will be spending time on this today to try and sort it out, please await for an update from me later today.

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

Thank you. Take your time. Personal stuff is more important! I am not in hurry.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

I am re-reading the responses from you and looks like using GitHubFlavored gives you the right output albeit you want the language marker. There are 2 ways to achieve this, 1)you can do a pre-process step to add class highlight-powershell to the parent div in your content like below:

<div class="highlight-powershell">
<pre>....</pre>
</div>

Or as your requested, a config can be added to include a default language if one is not found.

In summary, the latter to add config is a trivial thing to do. If you can make do with the pre-processing, it is also fine. Let me know your thoughts.

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

It's not giving right output. If you check the screen shot (last one) - it's all in one line. PowerShell doesn't work like that and line breaks are necessary. There is no requirement for ; or any other char that splits commands (it's even bad practice in Powershell). Same for VBS or some other old code. That's why I need line breaks.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

Ye, but I mean giving it a name. Such as: ```powershell

###############################################################################################################################################################################################################################################
# Author Thiago Beier [email protected]   
# Version: 1.0 - 2020-03-09  
# List sum of total users, total enabled accounts, total disabled accounts in ADDS (you can restrict the search to a specific OU - line 12 and 13
# Toronto, CANADA   
# Email: [email protected] 
# https://www.linkedin.com/in/tbeier/ 
# https://twitter.com/thiagobeier
# thiagobeier.wordpress.com
###############################################################################################################################################################################################################################################  

#Get-ADUser -Filter * -SearchBase "OU=Field,OU=Users,OU=Toronto,DC=canada,DC=local" |fl name | measure
$userstotal = Get-ADUser -Filter * -SearchBase "DC=canada,DC=local" |fl name | measure
$usersenabled = Get-ADUser -Filter {Enabled -eq $true} | fl name | measure
$usersdisabled = Get-ADUser -Filter {Enabled -eq $false} | fl name | measure
write-host -ForegroundColor Magenta "########################## ADDS - TGAM - Users Report ###########################"
Write-Host -ForegroundColor Yellow "Total Users" $userstotal.Count
Write-Host -ForegroundColor Green "Enabled Users" $usersenabled.Count
Write-Host -ForegroundColor Cyan "Disabled Users" $usersdisabled.Count
write-host -ForegroundColor Magenta "#################################################################################"

I've used GitHubFlavored and it just gave me ``` which is enough, but cooler would be with PowerShell formatting.

###############################################################################################################################################################################################################################################
# Author Thiago Beier [email protected]   
# Version: 1.0 - 2020-03-09  
# List sum of total users, total enabled accounts, total disabled accounts in ADDS (you can restrict the search to a specific OU - line 12 and 13
# Toronto, CANADA   
# Email: [email protected] 
# https://www.linkedin.com/in/tbeier/ 
# https://twitter.com/thiagobeier
# thiagobeier.wordpress.com
###############################################################################################################################################################################################################################################  

#Get-ADUser -Filter * -SearchBase "OU=Field,OU=Users,OU=Toronto,DC=canada,DC=local" |fl name | measure
$userstotal = Get-ADUser -Filter * -SearchBase "DC=canada,DC=local" |fl name | measure
$usersenabled = Get-ADUser -Filter {Enabled -eq $true} | fl name | measure
$usersdisabled = Get-ADUser -Filter {Enabled -eq $false} | fl name | measure
write-host -ForegroundColor Magenta "########################## ADDS - TGAM - Users Report ###########################"
Write-Host -ForegroundColor Yellow "Total Users" $userstotal.Count
Write-Host -ForegroundColor Green "Enabled Users" $usersenabled.Count
Write-Host -ForegroundColor Cyan "Disabled Users" $usersdisabled.Count
write-host -ForegroundColor Magenta "#################################################################################"

I meant to refer to this output which you have posted using the version published in NuGet. Ignore the test build which I provided you which seems to be messing up with the line breaks.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

BTW, I am adding the config option DefaultCodeBlockLanguage which you can set. If language is not detectable using the class names or if it is missing, the above config will come into play when GithubFlavored option is used. I believe, this should help with your use case.

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

That's great! It will help a lot. I can then make easy logic "detecting" in HTML what I'm dealing with and simply set an option before conversion. Much easier than trying to scan HTML first and then update HTML with value :-)

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

DefaultCodeBlockLanguage option added via f82cdad

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

@PrzemyslawKlys I have released v3.13.0 to NuGet. Please run your use case with GithubFlavored = true and DefaultCodeBlockLanguage = "powershell" and please let me know if it yields the desired result for the sample in question.

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

DefaultCodeBlockLanguage works. Adding spaces, doesn't.

Here's another example:
image

PageProjectDescription.zip

if you click on the .HTML you will see the output is ok. But markdown seems to ignore it.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

@PrzemyslawKlys I now understand the issue what you have highlighted. Trying to workout a solution.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

@PrzemyslawKlys I had to revamp the whole implementation of pre tag conversation to handle few varying use cases including yours. Can you please try with the one attached and let me know
ReverseMarkdown.3.14.0.zip

Once you confirm, I will plan to do a release to NuGet.

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

There's no DLL packed :-) just PDB files

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

My bad, sorry about, please check the below:
ReverseMarkdown.3.14.0.zip

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

No change. Still the same output :(

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

hmm. something is a miss. I have attached the file and the output for your reference. Can you please check the output on the attached file?
output.zip

Also can you please share the output generated on your end as a file?

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

I have added added the code changes in a feature branch for reference https://github.com/mysticmind/reversemarkdown-net/tree/revamp_pre_tag_converter.

from reversemarkdown-net.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 22, 2024

Ye, yours look correct.

This is the final config before I use it.

UnknownTags                   : Drop
GithubFlavored                : True
RemoveComments                : False
WhitelistUriSchemes           :
SmartHrefHandling             : False
TableWithoutHeaderRowHandling : Default
ListBulletChar                : -
DefaultCodeBlockLanguage      : powershell

Now, it worked. You know I'm using your library in PowerShell (wrote module around it)

This works, and preserves spaces

$Content = Get-Content -Path $Path -Raw

This doesn't work, as in your library doesn't seem to be able to find linefeeds.

$Content = Get-Content -Path $Path

My fault!

Description of -RAW switch: The commands in this example get the contents of a file as one string, instead of an array of strings. By default, without the Raw dynamic parameter, content is returned as an array of newline-delimited strings.

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

Added some refactoring, fixed via cb4afb4

from reversemarkdown-net.

mysticmind avatar mysticmind commented on August 22, 2024

v3.14.0 is available in NuGet. Looking at your html samples, I managed to squeeze in some enhancements as well, you can check the release notes here

from reversemarkdown-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.