Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • myro 7 posts 27 karma points
    Jan 17, 2010 @ 20:14
    myro
    0

    macro for Prettify4Umbraco.

    Hello and thanks fot this package.

    my problem is that every time i want to insert a code snippet into Ritch TextEditor data type, i have to edit the html and insert manually the <pre>  tag, handling also the html encoding.

    It would be greate to have a macro that handles the this for me every time i want to use Prettify4Umbraco.
    I have started building the macro by myself but i have encurred into a problem posted here

    Without the ability to handle breaklines and quotes into macros, i cannot integrate the Prettify4Umbraco.
    or maybe i'm doing something wrong.

    Can you please help, providing me any good hint? it would be great to heve this feature into this package. I would be happy to share the macro once is done.

    Thank you.

     

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jan 17, 2010 @ 21:06
    Morten Bock
    0

    Hi myro.

    There should be no need for a macro. What I have done is just add a style to the style dropdown. Follow the guide here:

    http://our.umbraco.org/wiki/how-tos/customizing-the-wysiwyg-rich-text-editor-(tinymce)/add-styles-to-the-drop-down-menu-for-editors-to-use

    What you need is a style like:
    Name: pre
    Alias:pre

    Then you can use this style in TinyMCE. Just select the text, and start typing in your code. Like you, I sometimes also need to use the html view to get the whitespace right if I copy paste some code, but mostly it works just fine.

  • myro 7 posts 27 karma points
    Jan 19, 2010 @ 12:17
    myro
    0

    Hello Morten!
    Thank you very much for your tip. It's definitely a better solution than the one i was trying to implement. Thank you.

    I got just one problem:
    everytime i press the save or save and publish button, all the text inside the <pre> tags gets additional <br /> for every breakline.

    example:
    if I write into the RTE :

    <p>this is a normal text</p>
    <pre>string a ="sample code";<br /></pre>
    <p>this is a normale text</p>

    and press the save button, the text becomes:

    <p>this is a normal text</p>
    <pre>string a ="sample code";<br /><br /></pre>
    <p>this is a normale text</p>

    if i press it again, it becomes:

    <p>this is a normal text</p>
    <pre>string a ="sample code";<br /><br /><br /><br /></pre>
    <p>this is a normale text</p>

    Can you please help me again?
    thank you very much.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jan 19, 2010 @ 17:18
    Morten Bock
    0

    Hi Myro

    It should not be necessary with the <br/> in the first place. I write my code like this:

    <p>blah</p>
    <pre>
    public void test()
    {
      string blah = "blah";
    }
    </pre>
    <p>blah</p>
    But I have not experienced the added br tags in my install, so I don't know exactly what happens there.

     

  • myro 7 posts 27 karma points
    Jan 19, 2010 @ 17:42
    myro
    0

    I don't know then....

    Even I paste your sample code from the RTE's HTML, and then i press twice time the button publish, the RTE's HTML becomes:

    <p>blah</p>
    <pre>public void test()<br /><br />{<br /><br />  string blah = "blah";<br /><br />}<br /><br /></pre>
    <p>blah</p>

    I'm using: umbraco v 4.0.3 (Assembly version: 1.0.3625.27276)
    can you please post me your umbraco's version?

     

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jan 19, 2010 @ 17:59
    Morten Bock
    0

    I can see that I am actually using umbraco v 4.0.2.1 (Assembly version: 1.0.3441.17657)

    I don't know if that makes any difference in this matter.

  • myro 7 posts 27 karma points
    Jan 20, 2010 @ 10:23
    myro
    0

    I see that this problem happens mostly when using the RTE in FireFox. Looks like a TinyMCE browser's compatibility problem.
    I' ve found this fix: http://sourceforge.net/tracker/index.php?func=detail&aid=2671750&group_id=103281&atid=738747

    I will try to implement that plug in into umbraco, and I if it works i will post here the solution.
    Thank you again for you time.

     

  • Josh Reid 182 posts 258 karma points
    May 08, 2010 @ 00:55
    Josh Reid
    0

    @myro (and anyone who has this problem)...

    The multiple line-break issue seems to be caused by tidy in the Umbraco Settings - So set tidy to false ie:

        <!-- clean editor content with use of tidy -->
        <TidyEditorContent>False</TidyEditorContent>

    Hope this helps ;)

    J

Please Sign in or register to post replies

Write your reply to:

Draft