Custom translator has problem with   (InDreamweaver 8)

Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default Custom translator has problem with   (InDreamweaver 8)

    Hi,

    I'm having trouble with my custom translator that works correctly in DW MX
    2004, but behaves differently in DW 8. I've provided a simplified version of
    my translator below (along with a sample test *.htm file). Thanks in advance
    for any help!

    This simple translator takes my custom body tag:
    <custombody>

    and replaces it with an ordinary body tag with green background:
    <body bgcolor="#00FF00" style="background-color:#00FF00">

    It also translates the closing tag. In DW MX 2004, I can open the page and
    the background color appears green as expected. However in DW 8, when I open
    the page the background color is just plain white. If I make a change to the
    text (in Code View) and select Refresh, the background correctly turns green.
    So it's as though the translation fails when the file is opened, but works
    correctly upon refresh.

    Something to note is that my test *.htm file has a table cell containing only
    an &nbsp;. If I remove the cell containing the &nbsp;, the translation works
    correctly (I can see the green background just after opening the page). I
    don't know why the non breaking space would cause a problem, though.

    Here is my test *.htm file:
    -----------------------------------------------
    <html>

    <custombody>
    <table>

    <tr><td>
    this is the first cell
    </td></tr>

    <tr><td>
    &nbsp;
    </td></tr>

    <tr><td>
    this is the last cell
    </td></tr>

    </table>
    </custombody>
    </html>
    -----------------------------------------------

    And here is my translator file:

    -----------------------------------------------
    <html>
    <head>
    <title>Custom Body Tag</title>
    <meta http-equiv="Content-Type" content="text/html; charset=">

    <script language="JavaScript"
    src="../Shared/MM/Scripts/Class/FileClass.js"></script>
    <script language="JavaScript">

    function getTranslatorInfo()
    {
    returnArray = new Array( 6 );

    returnArray[ 0 ] = "CUSTOM_BODY_TAG"; // translatorClass
    returnArray[ 1 ] = "Custom Body Tags"; // title
    returnArray[ 2 ] = "0"; // nExtensions
    returnArray[ 3 ] = "1"; // nRegExps
    returnArray[ 4 ] = "<custombody"; // regExps
    returnArray[ 5 ] = "byString"; // runDefault

    return returnArray;
    }

    function translateMarkup( docName, siteRoot, docContent )
    {
    var x = convert( docName, docContent);

    // File for debugging
    DWfile.write( docName + '.trans', x );

    return x;
    }

    function convert( docName, docContent)
    {
    var tag_start, tag_end, output;

    output = "";
    tag_start = docContent.indexOf( '<custombody' );
    tag_end = docContent.indexOf( '</custombody' );

    if ( tag_start == -1 ) return docContent;

    // substring() returns up to but not including the end position

    output += docContent.substring( 0, tag_start );
    output += '<MM:BeginLock translatorClass="CUSTOM_BODY_TAG" type="mvt"
    depFiles="" orig="%3Ccustombody%3E">';
    output += '<body bgcolor="#00FF00" style="background-color:#00FF00">';
    output += '<MM:EndLock>';
    output += docContent.substring( tag_start+12, tag_end );
    output += '<MM:BeginLock translatorClass="CUSTOM_BODY_TAG" type="mvt"
    depFiles="" orig="%3C/custombody%3E">';
    output += '</body>';
    output += '<MM:EndLock>';
    output += docContent.substring( tag_end+13, docContent.length );

    return output;
    }

    </script>

    </head>
    <body>
    </body>
    </html>
    -----------------------------------------------

    Here is my *.mxi file:

    -----------------------------------------------
    <macromedia-extension
    name="Custom Body Tag"
    version="1.0.0"
    requires-restart="true"
    type="Suite">

    <author name="TBD" />

    <products>
    <product name="Dreamweaver" version="7" primary="true" />
    </products>

    <description><![CDATA[This extension provides....]]></description>

    <license-agreement>
    <![CDATA[SAMPLE THIRD PARTY LICENSE TEXT:<br>
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
    nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut
    wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
    lobortis nisl ut aliquip ex ea commodo consequat.]]>
    </license-agreement>

    <files>
    <file source="CustomBody_Trans.htm"
    destination="$dreamweaver/configuration/translators" />
    </files>

    <ui-access>
    <![CDATA[This extension provides a custom property inspector...]]>
    </ui-access>

    </macromedia-extension>
    -----------------------------------------------


    mydev123 Guest

  2. Similar Questions and Discussions

    1. Extension Manager CS4 not installing extensions inDreamweaver CS4
      Just installed CS4 Design Premium. Now i want to install some extensions to Dreamweaver. When I click on the extension to install it I get a...
    2. ColdFusion Login Wizard: How do you access this inDreamweaver CS3
      The 'ColdFusion MX 7 Extensions' (CFMXDreamWeaverExtensions.mxp) could be installed for 'Dreamweaver MX 2004' using the 'Adobe Extension Manager'....
    3. Problems when Creating Pages from Templates inDreamweaver 8
      When creating new pages from templates in Dreamweaver 8(Ver 8.0.2). The full path for images is not created i.e. in template the code is <img...
    4. EditTextOnly.htm/translator problem
      I have the following message when one of our users tries to open attempts unsucessfully to log in: "The Following translators were not loaded due...
    5. What does &nbsp; mean
      Newbie here. What does &nbsp mean in code?
  3. #2

    Default Re: Custom translator has problem with &nbsp; (In Dreamweaver 8)

    Take a look in the "Server Model SSI.htm" translator. Search for
    "debugTranslator" and you'll find a simple mechanism for looking at the
    what the text of your page looks like "before" and "after" translation.

    Hope this helps,
    Randy

    > I'm having trouble with my custom translator that works correctly in DW MX
    > 2004, but behaves differently in DW 8...
    Randy Edmunds Guest

  4. #3

    Default Re: Custom translator has problem with &nbsp; (InDreamweaver 8)

    Hi Randy,

    I appreciate your help. Per your suggestion, I've played with DWfile.write()
    to see what the code looks like before and after translation. Both of my
    beginning and end <custombody> tags look correct to me. That is:

    <custombody>

    Is translated to the following when I open my test file:

    <MM:BeginLock translatorClass="CUSTOM_BODY_TAG" type="custombody" depFiles=""
    orig="%3Ccustombody%3E">
    <body bgcolor="#00FF00" style="background-color:#00FF00">
    <MM:EndLock>

    And the close tag:

    </custombody>

    Is translated to:

    <MM:BeginLock translatorClass="CUSTOM_BODY_TAG" type="custombody" depFiles=""
    orig="%3C/custombody%3E">
    </body>
    <MM:EndLock>

    I say it looks correct because I also installed the example "<kent>" tag
    translator, and my translated code looks similar as far as the BeginLock and
    Endlock. And I did use a hex editor to make sure there weren't any strange
    white characters and that carriage-returns/line feeds are correct.

    I did notice that after I edit the test HTML in code view, and select Refresh,
    the translation is run again. This time the translated code shows some
    automatic formatting where Dreamweaver has moved the &nbsp; up to the same line
    as the open <TD> tag. That's the only difference I see.

    Do you have any other suggestions? Would you know where I can find an example
    translator that works on tags pairs like <body> and </body>? The examples I've
    seen are for single tags like the <kent> translator.


    mydev123 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139