1 Reply Latest reply on Aug 15, 2007 5:52 PM by Newsgroup_User

    Help with source code formatting

    wloughney
      I have tried using the source formatting options in DW8 but it seems to work inconsistently. Some tags it seems to recognize and others it doesn't. And not any specific ones but it seems to be more how they are nested. Most of the xhtml and css I write is hand coded. I use DW because, for the most part, it does not change the code I write to what it thinks it should be. (DW8 seems to change it a little more than prior versions).

      And the ability to get an approximate idea of how it looks in "real time" is a big plus. For all but the most simple pages I have to browser preview due to the limitations of DW's Design View. But all the tools are there to make it work very fast. So I am a dedicated DW user.

      In many cases I want to print the code and have it look nice for off-line review, documentation and trouble shooting. What i want is typically available it other products for other languages (C, VB, Xbase, etc).

      Here is how it should look.
      (You need to use a little imagination since the forum strips out leading spaces or tabs. Just picture it with 2-3 spaces in front of each new tag to indent them.)

      <tag1>Start of file. (doctype, html, etc)
      <tag2>Initial info about the page (typically in the head) like metatags, links to css etc.</tag2>
      <tag3>general page content as in the body.
      <tag4>First things that are special about this page as in a div.
      <tag4a>breakdown on the first things about the page like in a p.</tag4a>
      <tag4b>more about the first things on the page. This should word wrap both on screen and
      on the printout of the page. These generally would be different points since the screen size
      may be 120 chars wide and the page size may be 90. Another p.</tag4b>
      </tag4>
      <tag5>Second thing that make the page special.
      <tag5a>specific detail on second thing.</tag5a>
      <tag5b>additional detail on second things.</tag5b>
      </tag5>
      </tag3><!--End of body -->
      </tag1><!--End of page like /html -->

      If I could just start at the top of the page and code to the end it would all probably work easier. But that's never how it happens. I bring in snippets from a library, code from other applications, templates and other elements that are all formatted a little different . if the last time that piece of code was only indented 2 levels and in this case it is 7 levels than it changes the visual layout of the code a lot. If the last time an image was on the left with code to the right and this time it is the opposite it changes the visual layout of the code as well. And of course using a different CSS file may do that as well.
      Note that most of these changes do not impact the visual look of the page when displayed. I am just talking about how the code looks on screen and printed out.

      After working on the page for a while it starts to look more like this:
      (Just picture a few random spaces in front of some tags since the formatting gets lost.)

      <tag1>Start of file. (doctype, html, etc)
      <tag2>Initial info about the page (typically in the head) like metatags, links to css etc.</tag2>
      <tag3>general page content as in the body.
      <tag4>First things that are special about this page as in a div.
      <tag4a>breakdown on the first things about the page like in a p.</tag4a>
      <tag4b>more about the first things on the page. This should word wrap both on screen and on the printout of the page. These generally would be different points since the screen size may be 120 chars wide and the page size may be 90. Another p.</tag4b</tag4>
      <tag5>Second thing that make the page special.
      <tag5a>specific detail on second thing.</tag5a><tag5b>additional detail on second things.</tag5b></tag5>
      </tag3><!--End of body --></tag1><!--End of page like /html -->

      Still readable but as the page gets longer (500-1000 lines) it gets less readable.

      I would like the <tags> to print in BOLD, ideally defining which should and should not be bold (div, table, etc). Besides reformatting the code as desired to look good on screen and print good, it would be really useful to have a tree display even if only on the printout. This is really useful for troubleshooting and documentation writers.

      It would look something like this printed:

      |--<tag1>Start of file. (doctype, html, etc)
      | <tag2>Initial info about the page (typically in the head) like metatags, links to css etc.</tag2>
      | |--<tag3>general page content as in the body.
      | | |--<tag4>First things that are special about this page as in a div.
      | | | <tag4a>breakdown on the first things about the page like in a p.</tag4a>
      | | | |--<tag4b>more about the first things on the page. This should word wrap both on screen and
      | | | | on the printout of the page. These generally would be different points since the screen size
      | | | | may be 120 chars wide and the page size may be 90. Another p.
      | | | |--</tag4b>
      | | |--</tag4>
      | |
      | | |--<tag5>Second thing that make the page special.
      | | | <tag5a>specific detail on second thing.</tag5a>
      | | | <tag5b>additional detail on second things.</tag5b>
      | | |--</tag5>
      | |--</tag3><!--End of body -->
      |--</tag1><!--End of page like /html -->

      Ideally this would be available as a DW extension, but I would consider using an external editor called by DW. So does anybody have some suggestions?

      Thanks,
      Walter
        • 1. Re: Help with source code formatting
          Level 7
          Walter,

          DW attempts to maintain source formatting as you go, but you can
          override the settings (for example by manually editing in Code View).

          Have you tried:

          Commands > Apply Source Formatting

          This will re-format you entire page.

          Printing only prints the page how it is formatted. It won't do any extra
          formatting.

          Hope this helps,
          Randy


          > I have tried using the source formatting options in DW8 but it seems to work
          > inconsistently. Some tags it seems to recognize and others it doesn't. And not
          > any specific ones but it seems to be more how they are nested. Most of the
          > xhtml and css I write is hand coded. I use DW because, for the most part, it
          > does not change the code I write to what it thinks it should be. (DW8 seems to
          > change it a little more than prior versions).