Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Forum Discussion Format/Code does not work

hervé_piponhervé_pipon Member Posts: 60 ✭✭
Hello,

When I want to use Format/Code on the forum, it doesn't work.
See on https://forum.onshape.com/discussion/21555/skfitspline-and-bsplinecurve-controlpoints/
Find "test: same with code formatting" at the beginning

I'm using Chrome Version 115.0.5790.110

During Edit I see :


On the Forum it appears like this:


Comments

  • S1monS1mon Member Posts: 2,964 PRO
    It's very buggy and hard to use, but if you create an empty code block first, and then paste into that I think it works. Here's a random FS snippet:

    export function convertToMatrix(flatArray, uCount, vCount)
    {
        var result = zeroMatrix(uCount, vCount);
        for (var i = 0; i < uCount; i += 1)
        {
            for (var j = 0; j < vCount; j += 1)
            {
                result[i][j] = flatArray[i * vCount + j];
            }
        }
        return result;
    }
    Let's see if this works.
  • EvanReeseEvanReese Member, Mentor Posts: 2,122 ✭✭✭✭✭
    It's definitely buggy. You shouldn't have to do this if it just worked, but you can click the top right button to toggle the html view and make sure it didn't add some extra stuff

    Evan Reese
  • hervé_piponhervé_pipon Member Posts: 60 ✭✭
    S1mon , I read a discussion on this way, and already test it : it doesn't improve.
    Evan_Reese I test different way , and the html view toggle doesn't change anything.

    For those who want to read the code it is not very pleasant without formatting. :(

    What's weird is that it displays correctly while editing.
  • EvanReeseEvanReese Member, Mentor Posts: 2,122 ✭✭✭✭✭
    Test of paste, then convert to "code block" :
    <div>&nbsp; &nbsp; skFitSpline(sketch1, "spline1", {</div><div>&nbsp; &nbsp;&nbsp;"points" : [</div><div>&nbsp; &nbsp;&nbsp;vector( 0 , 0) * centimeter,</div><div>&nbsp; &nbsp;&nbsp;vector( 100, 100) * centimeter</div><div>&nbsp; &nbsp;&nbsp;],</div><div>&nbsp; &nbsp;&nbsp;"startDerivative" : vector(150 , 0) * centimeter,</div><div>&nbsp; &nbsp;&nbsp;"endDerivative" : vector(0 , 150) * centimeter,</div><div>&nbsp; &nbsp;&nbsp;});</div>

    Test of set to "code block" then paste:
    <div>&nbsp; &nbsp; skFitSpline(sketch1, "spline1", {</div><div>&nbsp; &nbsp;&nbsp;"points" : [</div><div>&nbsp; &nbsp;&nbsp;vector( 0 , 0) * centimeter,</div><div>&nbsp; &nbsp;&nbsp;vector( 100, 100) * centimeter</div><div>&nbsp; &nbsp;&nbsp;],</div><div>&nbsp; &nbsp;&nbsp;"startDerivative" : vector(150 , 0) * centimeter,</div><div>&nbsp; &nbsp;&nbsp;"endDerivative" : vector(0 , 150) * centimeter,</div><div>&nbsp; &nbsp;&nbsp;});</div>

    Evan Reese
  • EvanReeseEvanReese Member, Mentor Posts: 2,122 ✭✭✭✭✭
    Yeah that didn't work...
    Evan Reese
  • hervé_piponhervé_pipon Member Posts: 60 ✭✭
    a few tests later ,

    When I write directly in the editor : it works normally  :)
    When I copy paste : it bugs  :(

    When I write a simple line of code , and I inspect it inside the code tag the text is:

    <pre class="CodeBlock"><code>skFitSpline(sketch1, "spline1", {
    "points" : [</code></pre>

    After a copy paste the text is:

    <pre class="CodeBlock"><code><div>skFitSpline(sketch1, "spline1", {</div><div>"points" : [</div></code></pre>

    I seems that some <div> tag where added : I don't know if it is the editor who change the behaviour ?

  • hervé_piponhervé_pipon Member Posts: 60 ✭✭
    If I copy paste from a correctly formatted code on the forum, it works fine  :)
  • hervé_piponhervé_pipon Member Posts: 60 ✭✭
    To make it to work,

    you effectivly have to leave the HTML mode
    --  Once in text mode, you can copy the code; disregard existing text that is no longer properly formatted
    --  Go back to HTML mode
    --  Select the pasted code, which is not displayed correctly, but it does not matter
    --  Apply the Code tag

    Everything is back to normal  :)

    not very user friendly
Sign In or Register to comment.