General XMetaL Discussion
paul_cpwr November 8, 2011 at 4:10 pm
Insertion of zero-width spacesNovember 8, 2011 at 4:10 pmParticipants 2Replies 3Last Activity 11 years, 2 months ago
What is the recommended practice for inserting a zero-width space?
I have created a macro that inserts this character via the following command (surrounding logic in the macro omitted):
This inserts the character (not a boxed entity reference), but the character doesn't appear as a “space” until you cycle the view between tags on/off. Once the zero-width spaces are visible as “space” characters, the editing of the content around them is difficult because the alignment of the characters is out of sync with the cursor position and selection highlighting.
Is there a better way to insert this character such that it appears as a character entity reference and doesn't negatively impact the ability to edit the content?
BTW, I did try to create a character entity reference node (ActiveDocument.createCharacterReference(0x200b);) and insert it that way but the API doesn't appear to allow insertion of new nodes inside a text node; you can only append the character entity to the text node. I guess I can split the current text node and insert the character entiry reference at the split, but I can't find an example of doing that (if anybody has one, that would be very helpful).
Background: XMEE 6.0.2.070 running on Windows XP.
Information Developer, Compuware CorporationDerek Read November 8, 2011 at 5:43 pm
Reply to: Insertion of zero-width spacesNovember 8, 2011 at 5:43 pm
In my opinion, the insertion of this type of character, which I will lump into a general category of “formatting characters” (my own term) is best handled automatically as you are trying to do. The two best places for this are inside a transformation script (XSLT for example) or if necessary insertion via script inside XMetaL Author.
I would lean toward the first though and question the need for the author to know that it is there. With a proper transform or a publishing system that eliminates the need for this character altogether, hopefully you don't need to insert it into your source XML.
XMetaL renders characters using the glyph from the font you have specified in the CSS for your customization using the CSS font-family setting. This particular character will not be visible to the end user while editing because most fonts render it using “zero width” (ie: no kerning, no actual width, no visible lines). So, unless you configure the product to use a font (via CSS) that contains a visible glyph for this character you can't see it.
You may also wish to read the section here called “Saving Character Entities”: http://forums.xmetal.com/index.php/topic,157.0.htmlpaul_cpwr November 9, 2011 at 2:21 pm
Reply to: Insertion of zero-width spacesNovember 9, 2011 at 2:21 pm
Thank you for the reply.
Given that a zero-width space is a valid Unicode character and we're saving our content in UTF-8, there will be no way to force XMetaL to always handle/display the zero-width spaces as a character entity reference. Truth be told, this is the way it *should* work.
In our case, authors need to know where the zero-width spaces are located since the authors are, in fact, introducing them. We use our single-source publishing system to produce both help and PDF/ODT outputs and the zero-width spaces are added to allow a long unbroken string to break at an opportune point when required by the limitations of the output format. To enable the publishing engine to do this automatically would require a very complicated heuristic to choose where to break long unbroken content of several different types (command name, paths, API names, etc.). Consequently we allow the authors to specify where breaks are appropriate, if necessary.
I guess the best way to implement this is to take a hybrid approach: I'll alter the insertion script to insert a processing instruction instead of the Unicode zero-width space character and have our publishing engine convert the PI to a zero-width space at publishing time. That way the PI placeholder is visible in the editor without comprimising ability to edit the surrounding content, and the correct character is introduced automatically in the output.
Thank you for your help in this matter.
Information Developer, Compuware CorporationDerek Read November 9, 2011 at 5:27 pm
Reply to: Insertion of zero-width spacesNovember 9, 2011 at 5:27 pm
That seems like the best approach. The only good alternatives I can think of (aside from using an element, which would require DTD modification) would be to find (or create) a font that has a visible zero-width space character.
- You must be logged in to reply to this topic.