HTMLEditorKit adds spaces and tags.  Can I make it stop?

I've developed an application that scores boat races and outputs the results in very compact HTML. One way to keep the HTML compact is to make tactical decisions about what tags to leave out, such as "</td>".
Another is to put in virtually no white space unless it is part of the end user's display.
This is all well and good when I save directly to the disk. But if I first display the string as HTML in a JEditorPane, it seems that the HTMLEditorKit wants to reformat the document, adding all the missing tags and a bunch of spaces and returns as well. THe prettier document is now twice the size (28k vs 14k). This is without me having made any editing changes.
I can, of course save the original string directly, but I would like to give users the ability to edit before saving. Is there some sort of "don't make changes I did not ask for" fix to this item?

I don't know of any easy way to do what you want with JEditorPane
There are some packages that do HTML formatting for you. For example, you might be able to use JTidy (I've never tried it) to format the text before saving it. It has different options which you may be able to use to control the level of formatting.
Or if you want full control over formatting, you could try using the ParserCallback class. It parses a text string and notifies you every time it finds a tag or attributes. You could then simply format the tag and attributes in the format you want. This example might get you started:
import java.io.*;
import java.net.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.text.html.parser.*;
public class ParserCallbackTest extends HTMLEditorKit.ParserCallback
     private int tabLevel = 1;
     public void handleComment(char[] data, int pos)
          displayData(new String(data));
     public void handleEndOfLineString(String eol)
     public void handleEndTag(HTML.Tag tag, int pos)
          tabLevel--;
          displayData("/" + tag);
     public void handleError(String errorMsg, int pos)
          displayData(pos + ":" + errorMsg);
     public void handleMutableTag(HTML.Tag tag, MutableAttributeSet a, int pos)
          displayData("mutable:" + tag + ": " + pos + ": " + a);
     public void handleSimpleTag(HTML.Tag tag, MutableAttributeSet a, int pos)
          displayData( tag + "::" + a );
//          tabLevel++;
     public void handleStartTag(HTML.Tag tag, MutableAttributeSet a, int pos)
          displayData( tag + ":" + a );
          tabLevel++;
     public void handleText(char[] data, int pos)
          displayData( new String(data) );
     private void displayData(String text)
          for (int i = 0; i < tabLevel; i++)
               System.out.print("\t");
          System.out.println(text);
     public static void main(String[] args)
     throws IOException
          ParserCallbackTest parser = new ParserCallbackTest();
          // args[0] is the file to parse
          Reader reader = new FileReader(args[0]);
//          URLConnection conn = new URL(args[0]).openConnection();
//          Reader reader = new InputStreamReader(conn.getInputStream());
          try
               new ParserDelegator().parse(reader, parser, true);
          catch (IOException e)
               System.out.println(e);
}You can use a StringReader class as the input to the parser.

Similar Messages

  • Why are Mail and Firefox swapping places when the computer wakes, and how can I make them stop?

    If I put my MacBook Air to sleep with Firefox as the top application, when I wake the computer, Mail will jump to the top. If Mail is on top when the computer sleeps, when I wake the computer, Firefox will leap to the top.
    This has only happened for the last week or two; the two aps have otherwise coexisted peacefully for the last couple years.
    Does anyone know what's happening and how to make it stop?
    Thanks,
    Pitsligo

    See: Firefox > Preferences > Advanced > General : Accessibility : [ ] "Warn me when web sites try to redirect or reload the page"
    See: [[Options window - Advanced panel#General_tab]]
    See also: http://kb.mozillazine.org/accessibility.blockautorefresh

  • HT4623 I downloaded ios7 and initially it was working fine. Now it is flashing from my home screen to the white screen with the black apple every 3-5 seconds. It's so annoying and I can't make it stop! I tried shutting down all the way - nope! HELP!

    I downloaded ios7 on my iphone 5 yesterday. All day it worked fine, then last evening it started blinking from the white screen with the black apple to my home screen. Each screen only stays up for 3-5 seconds then switches back. I have tried shutting down and it is still happening! Does anyone know how to fix this issue without having to go into the store?

    Your power adapter is OK. If the only place it will not work is in your home, your house wiring and / or the appliances connected to it are likely to be the reason your Mac will not charge.
    From Troubleshooting MagSafe adapters:
    Identify line noise issues.
    Unplug the power adapter from the wall, let it sit for 60 seconds, then plug the adapter back in.
    If the adapter works after this 60-second "rest", you most likely have a line noise issue with your power source. You should reset the adapter periodically by repeating this moment of rest. This issue occurs when the AC adapter's "over voltage protection" feature senses ground noise and then turns off the adapter.
    Some possible sources of line noise include lights with ballasts, refrigerators, or mini-refrigerators that are on the same electrical circuit as your computer. This behavior may not occur if you plug the power adapter into an uninterruptible power supply (UPS) or plug it into a different circuit.
    Unless the adapter continues to exhibit this behavior on a known good outlet, it does not need to be replaced.
    Household wiring problems are very common. They can also be very dangerous. Fortunately most problems can be easily fixed by a qualified electrician.

  • Slow computer due to only 25 GB of storage available.  BUT...most of what's on the HD is labelled as "other".  What is this, and how can I make more space?  THANK YOU!

    SLOW MACBOOKPRO G4 === due to only 25 GB of storage available.  BUT...most of what's on the HD is labelled as "other".  What is this, and how can I make more space?  THANK YOU!

    I apologize for not knowing how or where to post the etre report, so I just copy&paste it here.
    My system is slow o
    Hardware Information:
              MacBook Pro (15-inch, Mid 2010)
              MacBook Pro - model: MacBookPro6,2
              1 2.4 GHz Intel Core i5 CPU: 2 cores
              4 GB RAM
    Video Information:
              Intel HD Graphics - VRAM: 288 MB
              NVIDIA GeForce GT 330M - VRAM: 256 MB
    System Software:
              OS X 10.9.1 (13B42) - Uptime: 0 days 16:57:32
    Disk Information:
              Hitachi HTS545032B9SA02 disk0 : (320.07 GB)
                        EFI (disk0s1) <not mounted>: 209.7 MB
                        Macintosh HD (disk0s2) /: 319.21 GB (143.12 GB free)
                        Recovery HD (disk0s3) <not mounted>: 650 MB
              MATSHITADVD-R   UJ-898 
    USB Information:
              Apple Inc. BRCM2070 Hub
                        Apple Inc. Bluetooth USB Host Controller
              Apple Internal Memory Card Reader
              Apple Inc. Apple Internal Keyboard / Trackpad
              Apple Computer, Inc. IR Receiver
              Apple Inc. Built-in iSight
    FireWire Information:
    Thunderbolt Information:
    Kernel Extensions:
              com.symantec.kext.internetSecurity          (1.3.2f5)
              com.symantec.kext.pf          (4.2.1f7)
              com.symantec.kext.ips          (3.2f8)
              com.symantec.kext.SymAPComm          (11.2.2f3)
              com.symantec.kext.fw          (1.0.3f5)
    Problem System Launch Daemons:
    Problem System Launch Agents:
    Launch Daemons:
              [System] com.adobe.fpsaud.plist 3rd-Party support link
              [System] com.google.keystone.daemon.plist 3rd-Party support link
              [System] com.symantec.avscandaemon.plist 3rd-Party support link
              [System] com.symantec.deepsight-extractor.plist 3rd-Party support link
              [System] com.symantec.diskMountNotify.plist 3rd-Party support link
              [System] com.symantec.MissedTasks.plist 3rd-Party support link
              [System] com.symantec.navapd.plist 3rd-Party support link
              [System] com.symantec.navapdaemonsl.plist 3rd-Party support link
              [System] com.symantec.Sched501-1.plist 3rd-Party support link
              [System] com.symantec.sharedsettings.plist 3rd-Party support link
              [System] com.symantec.symdaemon.plist 3rd-Party support link
              [System] com.symantec.symSchedDaemon.plist 3rd-Party support link
    Launch Agents:
              [System] com.conduit.loader.agent.plist 3rd-Party support link
              [System] com.google.keystone.agent.plist 3rd-Party support link
              [System] com.hp.help.tocgenerator.plist 3rd-Party support link
              [System] com.mga.updater.plist 3rd-Party support link
              [System] com.symantec.uiagent.application.plist 3rd-Party support link
    User Launch Agents:
    User Login Items:
              Garmin Lifetime Map Updater
              Steam
              iTunesHelper
              Skype
              Steam
              Mail
              GamePadCompanionLauncher
              Mac Game Store Helper
              HPEventHandler
              SymSecondaryLaunch
    Internet Plug-ins:
              JavaAppletPlugin: Version: 14.9.0 - SDK 10.7 Outdated! Update
              FlashPlayer-10.6: Version: 12.0.0.38 - SDK 10.6 3rd-Party support link
              Default Browser: Version: 537 - SDK 10.9
              Flash Player: Version: 12.0.0.38 - SDK 10.6 3rd-Party support link
              QuickTime Plugin: Version: 7.7.3
              o1dbrowserplugin: Version: 4.9.1.16010 3rd-Party support link
              npgtpo3dautoplugin: Version: 0.1.44.29 - SDK 10.5 3rd-Party support link
              GarminGpsControl: Version: 3.0.1.0 Release - SDK 10.4 3rd-Party support link
              googletalkbrowserplugin: Version: 4.9.1.16010 3rd-Party support link
              iPhotoPhotocast: Version: 7.0 - SDK 10.8
    Audio Plug-ins:
              BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
              AirPlay: Version: 1.9 - SDK 10.9
              AppleAVBAudio: Version: 2.0.0 - SDK 10.9
              iSightAudio: Version: 7.7.3 - SDK 10.9
    User Internet Plug-ins:
              BrowserPlus_2.9.8: Version: 2.9.8 3rd-Party support link
              LogitechDeviceDetection: Version: 1.0.0.76 - SDK 10.7 3rd-Party support link
    3rd Party Preference Panes:
              BrowserPlus  3rd-Party support link
              Flash Player  3rd-Party support link
              GamePadCompanionPrefPanel  3rd-Party support link
              Norton\nQuickMenu  3rd-Party support link
    Bad Fonts:
              None
    Old Applications:
              /Applications/iWork '09
              /Users/[redacted]/Downloads
                        Mystery Case Files Dire Grove CE:          Version: 1.0.8 - SDK 10.5 3rd-Party support link
                        Mystery Case Files Escape from Ravenhearst CE:          Version: 1.0.8 - SDK 10.5 3rd-Party support link
                        Weird Park Broken Tune Collectors Edition:          Version: 1.2 - SDK 10.5 3rd-Party support link
                        Call of Duty 4 Modern Warfare-1:          Version: 1.2 - SDK 10.5 3rd-Party support link
                        Anna-1:          Version: 1.0.8 - SDK 10.5 3rd-Party support link
                        Call of Duty 4 Modern Warfare:          Version: 1.0.8 - SDK 10.5 3rd-Party support link
                        Drawn The Painted Tower:          Version: 1.0.7 - SDK 10.5 3rd-Party support link
              Mayan Prophecies - Ship of Spirits CE:          Version: 1.0 - SDK 10.5 3rd-Party support link
                        /Applications/MacGameStore/Demos/Mayan Prophecies Ship of Spirits CE/Mayan Prophecies - Ship of Spirits CE.app
              Garmin Lifetime Map Updater:          Version: 2.1 - SDK 10.5 3rd-Party support link
              Google Chrome:          Version: 20.0.1132.47 - SDK 10.5 3rd-Party support link
              FacebookVideoCalling:          Version: 1.2.0.157 - SDK 10.5 3rd-Party support link
                        /Users/[redacted]/Library/Application Support/Facebook/video/1.2.0.158/FacebookVideoCalling.app
    Time Machine:
              Time Machine not configured!
    Top Processes by CPU:
                   8%          WindowServer
                   2%          HP Utility
                   1%          EtreCheck
                   1%          NortonAutoProtect
                   0%          mds
    Top Processes by Memory:
              315 MB          SymAVScanDaemon
              111 MB          DashboardClient
              102 MB          WindowServer
              94 MB          mds_stores
              90 MB          Mail
    Virtual Memory Information:
              36 MB          Free RAM
              1.23 GB          Active RAM
              1.18 GB          Inactive RAM
              758 MB          Wired RAM
              1.27 GB          Page-ins
              21 MB          Page-outs
    Thank-You

  • Can't add information and tags in itunes with Windows 8

    I just got a new computer with Windows 8.  I installed itunes and moved my library but it won't allow me to add information and tags.  The box won't open when I right click on a track, and when I try to do it from file and get info the area is greyed out.

    Repair iTunes Security Permissions
    Right-click on your main iTunes folder and click Properties, then go to the Security tab and click Advanced. Use the Change Permissions... button grant to your account (or the Users group) and SYSTEM full control of this folder, subfolders and files, then tick the option to Replace permissions entries... which will repair permissions throughout the library. When complete switch to the General tab, click in the Read-only check box to clear it, then click Apply.
    If you don't have the option to change the permissions then use the Owner tab and Edit... button to take ownership from an account with administrator privileges. Tick the option to Replace owner on subcontainers and objects.
    Repeat with the media folder if it isn't stored inside the main iTunes folder.
    You might also want to kill any "mystery" identities that have come over from the old computer...
    tt2

  • On images that are long and narrow horizontally, iPhoto truncates them and automaticall crops off part of each end of the image.  How can I make it stop?

    On images that are long and narrow horizontally, iPhoto truncates them and automatically crops off part of each end of the image.  the thumbnail has a jagged, serrated edge at both ends.  How can I make it stop?

    Then I do not get your problem - you can import the photo - you can find the photo and you can edit and save the photo - what more do you want?
    By defination thumbnails are small images to help you find the large image - the large image is fine and you can find it fine - and you know it is only showing part of the image because of the "jagged ends"
    If you think think that iPhoto should display long thumbnails suggest to Apple - iPhoto menu ==> provide iPhoto Feedback
    as to your digital photoframe - contact them - in general gital photos frames display one and only one aspect ratio and any photo that is not in that aspect ratio will be modified to display - either cropped to the proper size for the frame or have 'White" space added to fill the frame - that function is totally controled by the Digital Photo frame and any otptions you have will be in the manual or on the support web site for the frame - to put it in old film terms - you can not put an 8x10 print in a 5x7 frame unless you cut the photo down (or a 8x15 photo in an 8x10 frame either)
    LN

  • WHY does Muse upload every page when I only change one thing. And how can I make Muse faster.

    I have a bunch of sites I do for people that are similar. Here's one: www.mattfelis.com.
    When I make a single change on one page, just a text change (the last time I deleted a freakin' period) and tell Muse to Upload it to FTP host, it uploads every single page in the site. Every one. And since there are 55 pages, that means it takes about 20 minutes with a darned fast upload speed (20MBPS upload). It isn't the uploading that kills me, it's the Exporting of pages. All of them. All 55. Why is it doing this?
    And while we are talking about speed, most of the time in working with these files I see what I call the beach ball of death on a constant basis. Just opening a page from Plan Mode or going back to Plan Mode from a page can take 20 seconds. I know, I've counted. Copy and paste between pages can take longer. I am running a 3 year old Mac Pro with 12 gigs of RAM and tons of disk space. How can I make Muse work better. More RAM? To speed it up I find that I have to quit about every 30 minutes and restart Muse to get it back to any semblance of speed. Smaller sites obviously don't do this but big ones (I have a lot of those) do.
    Any help would be greatly appreciated.

    There's a bug we've become aware of and fixed for the next major release where use of one or more objects on a master page that have different states that require output as separate background images can result in that master page and all pages where that master page is used always being considered out-of-date and in need of re-export and upload.
    Unfortunately, there's no workaround short of removing such items from your master page(s).
    If you're not already part of the Private Beta Program and are interested in working with the next version of Muse prior to its official release, the Private Beta Program is open to all subscribers who can accept the terms of the Non-disclosure Agreement. You can join via the Help menu within Muse. The Beta Program for the next major release will be started soon.

  • I recently installed CS4, and I can not make a connection to my website.  Message an FTP error occurred and cannot make a connection to host. The remote host cannot be found.

    I recently installed CS4, and I can not make a connection to my website.  Message an FTP error occurred and cannot make a connection to host. The remote host cannot be found.

    Open up your site definition (double-click on the site name in the File panel or choose Site > Manage Sites > Edit) and go to the Remote Info category. There, click Use Firewall (if it isn't already selected) - press Test to try the default firewall settings. If that doesn't work, click Firewall Settings. You'll see two relevant settings about 2/3 down - Firewall host and Firewall port. If Firewall port is 21, there probably is something blocking the port.
    On Windows XP, you may have the Windows Firewall installed and blocking. Here's how you get to it:
    To open Windows Firewall
    1.
    Click Start and then click Control Panel.
    2.
    In the control panel, click Windows Security Center.
    3.
    Click Windows Firewall.
    Once you have that open, you'll need to set Dreamweaver as an exception to blocking:
    On the Exceptions tab, click Add                     Program.
    In the list of programs, click the name of the program (Dreamweaver) that you                     want to add, and then click OK. If the name of your program is                     not in the list of programs, click Browse to locate the Dreamweaver.exe in the Program Files folder and then click OK.
    Hope this helps - Joe
    Joseph Lowery
    Author, Dreamweaver CS4 Bible

  • I forgot to answer two security questions, and I can not make purchases in app store

    I forgot to answer two security questions, and I can not make purchases in app store

    If you have a rescue email address (which is not the same thing as an alternate email address) set up on your account then the steps half-way down this page should let you reset them : http://support.apple.com/kb/HT5312
    If you don't have a rescue email address (you won't be able to add one until you can answer 2 of your questions) then you will need to contact iTunes Support / Apple to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset (and if you don't already have a rescue email address) you can then use the steps half-way down the HT5312 link above to add a rescue email address for potential future use

  • I am trying to hook my macbook pro to a projector, which has a VGA cable. I bought a VGA to HDMI adapter, but whenever I hook it up, the screen on my macbook just goes black and I can't make it do anything else or even show up on the projector.

    I am trying to hook my macbook pro to a projector, which has a VGA cable. I bought a VGA to HDMI adapter, but whenever I hook it up, the screen on my macbook just goes black and I can't make it do anything else or even show up on the projector.
    My laptop is still on; it just has a black screen that I can't get rid of without shutting down the computer by holding the power button.

    Hey there lynmrigg,
    It sounds like have an HDMI to VGA adapter connecting your MacBook Pro and your projector but the screen on your computer goes black and no image appears on the projector. I would use the troubleshooting in the following article to help resolve or isolate the issue here, named:
    Apple computers: Troubleshooting issues with video on internal or external displays
    Try unplugging the video adapter or cable and then plug it back in.
    If more than one video adapter is in use (or "daisy-chained"), troubleshoot by using only one adapter.
    Example: A mini DisplayPort to DVI adapter connected to a DVI to HDMI adapter is an unsupported configuration because there is a series of adapters in use.
    If available, try using a different display and or adapter (or use a different connector by using DVI instead of VGA, for instance).
    Reset the system
    You can reset the Mac's parameter RAM and SMC.
    Reset the resolution
    Start by resetting the Mac's parameter RAM. If the display does not come up, was previously set to an unsupported resolution, and still results in no video:
    Start up in Safe Mode.
    From the Apple () menu, choose System Preferences.
    Choose Displays from the View menu to open the preferences pane.
    Select any resolution and refresh rate that your display supports.
    Restart your computer.
    Thank you for using Apple Support Communities.
    Take care,
    Sterling

  • I have an Iphone 4s and i can't make a connection to my mac and other devices via bluetooth! Why is this a problem and how can i repair it?

    I have an Iphone 4s and i can't make a connection to my mac and other devices via bluetooth! Why is this a problem and how can i repair it?

    "I have an Iphone 4s and i can't make a connection to my mac and other devices via bluetooth! ":
    That is correct.
    "Why is this a problem and how can i repair it?"
    Becasue this has never been a feature of iphone/ipod/ipad.  There is nothing to repair.

  • When I download pictures from my camera, they turn out a nice big size in iPhoto; other pictures that have been e-mailed to me or imported from older libraries/other computers show up small.  Why is this, and how can I make them all the larger size?

    When I download pictures from my digital camera into iPhoto, they turn out a nice large size (usually almost the full screen), but when somebody e-mails me pictures and I import them into iPhoto, or when I transfer old photos from an old library into my new iPhoto library, they turn out very small--not exactly thumbnail-size, but too small to use for calendars or photo books.  I don't know much about computers, so I don't know how this happened.  Also, I can't find any discernible pattern to why this happens with some pictures and not others--ie: what I described above is usually true, but I have had e-mailed photos or old photos turn out the way I want them, which is in the larger size in iPhoto.  Why is this happening, and how can I make all the pictures the larger size?

    Some mail programs, including Apple Mail, can reduce the size of images that are attached to a message. It's happening at the sender's end, and all you can do is ask the sender for a larger image.

  • HT5631 how do I verify my apple id? I can't sign in to it in mail and I can't make a new one because it just will not process I'm trying to set up iCloud between iPad and iPhone and having ALOT of difficulty pleAse help need it done by later on today!!!!!

    how do I verify my apple id? I can't sign in to it in mail and I can't make a new one because it just will not process I'm trying to set up iCloud between iPad and iPhone and having ALOT of difficulty pleAse help need it done by later on today!!!!!

    In order to use your Apple ID to create an iCloud account, the primary email address associated with the ID must first be verified.  To do this, Apple will send a verification email to your account and you must respond to the email by clicking the Verify Now link.  Make sure you are check the spam/junk folder as well as the inbox.  If it isn't there, go to https://appleid.apple.com, click Manage your Apple ID, sign in, click on Name, ID and Email addresses on the left, then to the right click Resend under your Primary Email Address to resend the verification email.

  • TS1424 I have an ipad and an iphone on two seperate itunes account and i can not make an itunes purchase on either device.  I keep getting asked for answers to the securtity question which i never answered in the first place! How do i fix this?

    I have two seperate itunes accounts on two seperate devices and i can not make an itunes purchase on either one. When signing into the account it ask for the  answer to security questions. I have NEVER answered a security question for these accounts.  Each time it is a different set of questions. This has only happend since the original devices have been replaced/upgraded. How do I fix this?   There is money in each account and both have recieved itunes giftcards for christmas that they are unable to use!

    sailsalot wrote:
    I have a new ipad and have used the community to answer questions for myself.  Your help has been great!  I don't know how you got my sailsalot name from my Skype account but I signed in with you as "gags76" and got help with my new ipad.  I discovered I used a different Apple id and password on my ipad from my computer (imac) and changed that.  My e-mail is   Could you email me if there is something I should do at my end.  I have to use itunes to sync with my ipad so I have been going back and forth between the two.  Should I sign in with my proper Apple id on my ipad?
    Yes

  • How can I sync my ipod to the i tunes library in my computer? and how can I make sure each Cd I play automatically is saved onto the Ipod?

    How can I sync my ipod to the i tunes library in my computer? and how can I make sure each Cd I play is automatically saved onto the Ipod?
    My problem is that if I open I tunes, the Sync ipod option in the menue is grayed out, and so not available.
    This is starting to irritate me, so any help would be much appreciated.
    Thanks!

    I have the same problem. The Sync ipod option in the menue is grayed out, and so not available. HELP!

Maybe you are looking for