header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
What's the trick to use {code} {/code}
Last Post 29 Feb 2008 12:57 PM by Don Jones. 11 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
kscrissUser is Offline
Basic Member
Basic Member
Posts:128

--
05 Feb 2008 12:13 PM

    Even when I use the less than and greater than signs is does not format the script correctly for me.

    My blog: http://blogs.powershellcentral.com/kscriss/
    Don JonesUser is Offline
    PowerShell MVP
    Basic Member
    Basic Member
    Posts:134
    Avatar

    --
    08 Feb 2008 08:15 AM
    If Code Then
    Depends on the language you're looking to have it format.
    - Don Jones
    www.ConcentratedTech.com
    Subscribe (RSS) or visit for weekly PowerShell tips and lessons
    Don JonesUser is Offline
    PowerShell MVP
    Basic Member
    Basic Member
    Posts:134
    Avatar

    --
    08 Feb 2008 08:15 AM
    - Don Jones
    www.ConcentratedTech.com
    Subscribe (RSS) or visit for weekly PowerShell tips and lessons
    kscrissUser is Offline
    Basic Member
    Basic Member
    Posts:128

    --
    11 Feb 2008 09:00 AM
    function ConvertIIS-LogFile
    {
    param( )
    begin { }
    process
    {
    $file = [System.IO.File]::openText( $_.fullname )
    while($line = $file.ReadLine())
    { if(!$line.StartsWith('#') -and ($line.Length -gt 19))
    { $UTCdatestring = $line.Substring(0, 19)
    $WorkDate = Get-Date($UTCdatestring)
    $LocalWorkDate = $WorkDate.tolocaltime()
    $FormatLocalWorkDate = $LocalWorkDate.ToString("yyyy-MM-dd HH:mm:ss")
    $StringLength = $line.length
    $RestOfString = $line.substring(19,$StringLength - 19)
    # $RestOfString | Out-Host
    $OutString = "$FormatLocalWorkDate"+"$RestOfString"
    Write-Output $OutString
    }
    ElseIF ($line.contains("Date:"))
    {
    $UTCdatestring = $line.Substring(7, 19)
    $WorkDate = Get-Date($UTCdatestring)
    $LocalWorkDate = $WorkDate.tolocaltime()
    $FormatLocalWorkDate = $LocalWorkDate.ToString("yyyy-MM-dd HH:mm:ss")
    $BeginString = $line.substring(0,6)
    $StringLength = $line.length
    $RestOfString = $line.substring(7+19,$StringLength - 19 -7)
    # $RestOfString | Out-Host
    $OutString = "$BeginString"+"$FormatLocalWorkDate"+"$RestOfString"
    Write-Output $OutString
    }
    Else
    {
    Write-Output $line
    }
    }
    }
    End {}
    } </ code>
    My blog: http://blogs.powershellcentral.com/kscriss/
    kscrissUser is Offline
    Basic Member
    Basic Member
    Posts:128

    --
    11 Feb 2008 09:01 AM
    I still don't get it.
    My blog: http://blogs.powershellcentral.com/kscriss/
    kscrissUser is Offline
    Basic Member
    Basic Member
    Posts:128

    --
    11 Feb 2008 09:09 AM
    Public Sub HelloWorld()
    Response.Write("Hello World")
    End Sub
    </ code>
    My blog: http://blogs.powershellcentral.com/kscriss/
    kscrissUser is Offline
    Basic Member
    Basic Member
    Posts:128

    --
    13 Feb 2008 07:55 AM
    O.K. This is another test. I am using the script HightLight-Syntax.ps1 from the script vault. I am calling the script in this way.

    ./HightLight-Syntax.ps1 ./HighLight-Syntax.ps1 > out.htm

    I am using the script to HightLight itself and am sending the output to out.htm. Now I will attemp to cut and past a code snipped from this output into this post.

    Highlight-Syntax.ps1
    # version 1.0
    # by Jeff Hillman
    #
    # this script uses regular expressions to highlight PowerShell
    # syntax with HTML.

    param( [string] $code, [switch] $LineNumbers )
    # $LineNumbers=$True
    "$code = Code variable"| Out-Host
    "$LineNumbers = LineNumbers variable " | Out-Host
    if ( Test-Path $code -ErrorAction SilentlyContinue )
    {
    $code = Get-Content $code | Out-String
    }

    $backgroundColor = "#DDDDDD"
    $foregroundColor = "#000000"
    $stringColor = "#800000"
    $commentColor = "#008000"
    $operatorColor = "#C86400"
    $numberColor = "#800000"
    $keywordColor = "#C86400"
    $typeColor = "#404040"
    $variableColor = "#000080"
    $cmdletColor = "#C86400"
    $lineNumberColor = "#404040"

    filter Html-Encode( [switch] $Regex )
    {
    # some regular expressions operate on strings that have already
    # been through this filter, so the patterns need to be updated
    # to look for the encoded characters instead of the literal ones.
    # we do it with this filter instead of directly in the regular
    # expression so the expressions can be a bit more
    My blog: http://blogs.powershellcentral.com/kscriss/
    kscrissUser is Offline
    Basic Member
    Basic Member
    Posts:128

    --
    13 Feb 2008 07:56 AM
    That did work using the "QUICK REPLY". I'll try a new forum post next: i.e. not using the "Quick Reply".
    My blog: http://blogs.powershellcentral.com/kscriss/
    kscrissUser is Offline
    Basic Member
    Basic Member
    Posts:128

    --
    13 Feb 2008 07:56 AM
    That did work using the "QUICK REPLY". I'll try a new forum post next: i.e. not using the "Quick Reply".
    My blog: http://blogs.powershellcentral.com/kscriss/
    Don JonesUser is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    13 Feb 2008 09:50 AM
    I'm not certain what the expectation is. The CODE tags aren't designed to color-code PowerShell script, if that's what you're after. They're primarily designed to provide a mononspaced font in a scrollable region - the forums software doesn't provide syntax highlighting for PowerShell (which is tough to do since PowerShell is a dynamic language of sorts).
    kscrissUser is Offline
    Basic Member
    Basic Member
    Posts:128

    --
    13 Feb 2008 10:19 AM
    How do I take the STARS 5-Stars off this post? I was playing with the STARS and now I can't take them off? Do you think I put them on but touching the star feature near the "Add Reply" button?

    Am I the only one that sees these stars, by this I mean are the stars just for me or all to see?
    My blog: http://blogs.powershellcentral.com/kscriss/
    Don JonesUser is Offline
    PowerShell MVP
    Basic Member
    Basic Member
    Posts:134
    Avatar

    --
    29 Feb 2008 12:57 PM
    The stars are part of the rating system. They don't come off - wouldn't be fair for someone to be able to remove a bad rating :).
    - Don Jones
    www.ConcentratedTech.com
    Subscribe (RSS) or visit for weekly PowerShell tips and lessons
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer