Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #744402

    My site contains software documentation. It is important that I can display code correctly. I am unable to insert this code into most elements

    <doc>
    <p>
    <s>some text </s>
    <s> some text </s>
    </p>
    <p>
    <s>some text </s>
    <s>some text </s>
    </p>
    </doc>

    What I have tried and did not work:
    formatting the code as preformatted
    wrapping the code between ,

     or <tt> tags
    escaping the whole code
    
    With some of the methods above, the code displays correctly the first time I publish the page but if I need to edit the page later, upon clicking edit, the code gets interpreted instead of just displayed.
    
    The only thing that works is using the Code Element with 'pre' wrapping and with 'Escape HTML Code' ticked.
    
    The Code Element cannot be inserted into other elements, though. How can I insert the code into a table for example?

    • This topic was modified 7 years, 9 months ago by mjakubicek.
    #746191

    Hey mjakubicek,

    Yes that is correct the code shows up only if you tick Escape HTML. To insert the code where you cannot insert the codeblock element please use the shortcode below.

    [av_codeblock wrapper_element='' wrapper_element_attributes='' escape_html='aviaTBescape_html' custom_class='']
    /* YOUR CODE HERE */
    
    /* END YOUR CODE HERE */
    [/av_codeblock]

    You can easily view the shortcode for page elements by activating debug mode http://kriesi.at/documentation/enfold/enable-advanced-layout-builder-debug/

    Best regards,
    Vinay

    #749655

    hi Vinay,
    I am sorry, but we have had still problem with it. We use code tags and when we save it, it is OK. However, after next saving (making some changes and save), the shortcode tags are interpreted and are not preserved.
    Could please insert following code to our website and try a few times to modify including saving the page. Here is the testing webpage: https://www.sketchengine.co.uk/shortcode/

    Shorcode:

    <doc>
    <p>
    <s>some text </s>
    <s> some text </s>
    </p>
    <p>
    <s>some text </s>
    <s>some text </s>
    </p>
    </doc>

    (temporary login credentials are attached in private content)

    I suppose this way can be faster. If your way works, we will use it on other pages.

    Thank you in advance

    #751720

    Hi,

    We have edited your test page and added a code inside the shortcode provided. The code shows fine in the front end. You cannot add code in text editor directly as it is processed by default.

    Please review the test page :)

    Best regards,
    Vinay

    • This reply was modified 7 years, 9 months ago by Vinay.
    #752614

    I added my code above and saved. It was OK until I wanted to edit the page again. See the screen of the current code (it was interpreted by the editor in spite of the “avia block” tags around): https://www.sketchengine.co.uk/wp-content/uploads/code-interpreted.png

    (the screen shows that I cannot edit this page now and then save it because I would lose the original code.)

    #755226

    Hi,

    Sorry for the late reply!
    From your screenshot it seems like you are adding your content in visual tab instead of Text tab. Please try using Text tab

    Best regards,
    Yigit

    #756930

    I inserted in in Text tab. The code is interpreted in admin interface (see the screenshot above), but it is OK on the web page.
    The problem lies in the fact that it is differently displayed in admin interface and commonly on the web page.
    So, the shortcode works, but it is confusing because I see something else than on the web page.

    #762401

    Hi,

    Sorry for the late reply.

    Please use the codeblock element to insert html or other code.

    Code Block can do 2 things.

    1. Display the code as is.
    2. Run the code and display the result.

    I have once again checked for any issue with the code block on your site and confirm that code block element is working fine both in frontend and backend as intended.

    Best regards,
    Vinay

    Please note you are using < s > i’m not sure if that’s supported. please use proper html syntax.

    • This reply was modified 7 years, 8 months ago by Vinay.
    #763572

    OK, but how to combine a code block with an accordion content (in the Avia Layout Builder)?

    See the following page

    shortcode <doc pub="1977"> is OK…

    Now please edit this page. When you open the accordion with the shortcode, it was interpreted and the code disappeared.

    I cannot find any sustainable solution.

    #766389

    Hi,

    Sorry for the delay, to display the code block element in a accordion element please enable the debug mode http://kriesi.at/documentation/enfold/enable-advanced-layout-builder-debug/

    1. Create a new page and copy the shortcode of the code block element.
    2. Paste the shortcode in the accordion tab in text mode.

    Please view the test page in private :)

    Feel free to let us know if you have any question.

    Best regards,
    Vinay

    #767266

    Hi,

    when you look at the same page now (in private) and open the “Display as code” accordion, you will see

    
    <doc>
    <s>some text </s>
    <s> some text </s>
    <s>some text </s>
    <s>some text </s>
    </doc>
    

    The problem starts when you edit the page, open this accordion and will see only interpreted code (in visual mode). OK, you click on text mode, but the <doc> tags have disappeared.

    I would need a solution which works also with repeating editing page (e.g. I would add some code or text on the page)

    Try to create a page with the code (above) and then twice edit that page, the code will be interpreted during second and following editing.

    #769754

    Hi,

    Please try the following solution. This is originally intended for xml codes but it should work in your situation.

    // https://kriesi.at/support/topic/need-a-raw-codeblock-visual-element/#post-739681

    Best regards,
    Ismael

    #770973

    Hi,

    I have tried, but it doesn’t help me. How can I use that solution?
    I should insert the following code just into an article (in the Text mode) or to the function.php? :

    function xml_shortcode( $atts, $content ) {
    	$filter = array('<br>','<br />');
    	$content = str_replace($filter, '', $content);
        return "<code><pre>" . esc_html($content) . "</pre></code>";
    }
    
    add_shortcode( 'avaxml', 'xml_shortcode' );

    thanks.

    #771464

    Hi!

    Add it in the functions.php file then use the [avaxml] shortcode in a code block. Ex:

    [avaxml]
    code here
    [/avaxml]

    Regards,
    Ismael

    #771674

    Hi,

    I have added that code in the functions.php but the problem is remaining. Look at https://www.sketchengine.co.uk/_test-2/#toggle-id-1 – there <code> tags around my xml tags. Then try editing the page, the code gets interpreted if you re-edit the page.

    #772165

    Hey!

    I created a test page and it seems to be working as expected. (see private field)

    Cheers!
    Ismael

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.