Posting Code on worpress

  • Unknown's avatar

    Hi, I’m trying to use the [code] tag from (http://en.support.wordpress.com/code/posting-source-code/) but i can't figure out how to make a "return feed" or "line break", my code is always displayed on one line. I tried several languages without success . My code are for AppleScript... many thanks for your help. Best regards

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    I’ll tag this thread for Staff assistance. Please subscribe to the thread so you are notified when they respond and please be patient while waiting.

  • Unknown's avatar
  • Unknown's avatar

    My code between [code][/code] tags is mangled to 1 line with HTML
    tags in the visual editor as well. How can I prevent that?

  • Can you show me an example of a post where this happens?

  • Unknown's avatar

    Unfortunately I have already updated the post by hand in text view mode.

    The mangled code line looks something like this (all on one line):
    [code]function x
    {
    #keepwhitespace $something=""
    }[/code]
    Notice the “
    ” that are added…

    It’s the visual editor that mangles the code, so I formatted the code in text view…

  • Can you try pasting the code into a forum post here using the “code” buttons and seeing what happens? At the very least, that would give me the exact bit of code to test with.

  • Unknown's avatar

    Okay here we go: code that will be mangled in the visual tab of a WP post editor:

    [code language="PowerShell" autolinks="false" gutter="false"]
    Test-Code "Solution framework_v*.WSP is installed in solution store" {
    arrange {
    $solutionName = "framework_v*.WSP"
    }
    act {
    $solution = Get-SPSolution $solutionName # NOTE: mijn Get-SPSolution voor SharePoint 2007 ondersteunt wildcards!
    }
    assert {
    Assert-That { $solution –ne $null } -FailMessage "Solution "$solutionName" not found in solution store"
    Assert-That { $solution.Deployed } -FailMessage “Solution "$solutionName" is not deployed"
    }
    }

    Test-Code "Feature "Error Page control adapter" is activated (at web application scope)" {
    arrange {
    $webAppUrl = "http://portal.nl"
    $featureIdentity = "Feature-ErrorPageControlAdapter"
    $featureIsInstalled = $false
    $webAppScopedFeatureIsActivated = $false
    }
    act {
    # Get the feature from the list of all installed features in the server farm
    $feature = Get-SPFeature -Identity $featureIdentity
    $featureIsInstalled = ($feature -ne $null -and $feature.Status -eq "Online")
    if ($featureIsInstalled)
    {
    $webAppScopedFeatureIsActivated = ((Get-SPFeature -Identity $featureIdentity -WebAppUrl $webAppUrl) -ne $null)
    }
    }
    assert {
    Assert-That { $featureIsInstalled } -FailMessage "Feature "$featureIdentity" is not installed in the farm."
    Assert-That { $webAppScopedFeatureIsActivated } -FailMessage "Feature "$featureIdentity" is not activated at webapplication "$webAppUrl"."
    }
    }
    [/code]

  • So, just so we’re on the same page, is this an example of what you are seeing:

    testing code display

    Where the lines are truncated? Or are you seeing the whole code chunk end up on a single long line?

  • Unknown's avatar

    It looks okay now, but when I edited the text of post (in visual tab) several times, the code line got chunked up on one single line with
    and “#keepwhitespace” entries in the code text.

  • I am guessing that you’ll be better off doing any code editing in the “text” tab.

  • Unknown's avatar

    Yup, first type and format all the text in visual mode and then add code.

    I tried the grit short code as well, but that ended up with large amounts of whitespace after a large code block…

  • So, after a lot of testing, I think we’ve got it figured out.

    Try setting the “code” tags before you type/paste in the code (in the visual editor) and see if that makes a difference.

  • Unknown's avatar

    Hmmm, that could indeed be the cause: I tried several methods on formatting the code, including

    
    

    , before I settled on [code].

  • Let me know if it fixes the issue for you.

  • The topic ‘Posting Code on worpress’ is closed to new replies.