[js/cs4] diff'ing texts

I would like to use Extendscript to compare two texts (e.g. from two text frames) and display the differences to the user in a sensible format. I don't care about the text formatting, whitespace and such changes.
My current approach is to:
1) Fetch the contents from the two text frames.
2) Compare the contents using a javascript I found on the Internet ("jsdiff.js")
3) Save the result into a local html work file along with a wee bit of html decoration.
4) Open the file using the execute method, thus displaying the result in a web browser.
It works decently, but I would still prefer a more elegant and integrated approach. Could be that someone in this forum has a better approach...
For instance, is there any of the inDesign UI or ScriptUI widgets that will render html properly (I couldn't spot it)?
Another approach would have been to generate pdfs with the texts and use BridgeTalk to open them in Acrobats "Compare documents" window. However, you seem to have very limited control over this function.
Any suggestions would be appreciated.
Thanks,
- Peder

Hi Oscar et al.
I got to look at it now, so, I'll fill you in...
Firstly, what I actually want to solve is the following problem:
A plain text that originates from a database gets inserted somewhere in a Story. After that, two types of changes to the text may occur: The designer may update the placed text (layout changes, formatting, but also actual text changes), or the original plain text may get updated in the database.
So, I want to allow the designer to compare the placed text with the current database value, and to be able to manually "merge" changes without loosing layout changes, formatting, white-spaces, etc.
The solution I have implemented (based on Jongware's proposal) is as follows:
1) The main script function is called with an inDesign text range (the placed text version) and a string (the DB text version).
2) The entire inDesign text range is highlighted with a yellow condtion, signalling that it is now in diff mode.
3) All diffs added locally (or removed from the db value) gets highlighted with a green condition.
4) All diffs removed locally (or added to the db value) gets highlighted with a red condition.
5) Whenever the designer right-clicks somewhere in the inDesign text range (yellow condition), two menu-items are added to the popup-menu:
   5.1) "End diff mode": Will remove the yellow and green condition mark-up and purge text marked with red condition.
   5.2) "Revert diffs": Will remove the yellow and red condition mark-up and purge text marked with green condition.
In between starting the diff mode and ending it using one of the two menu calls, the designer can update the marked-up text, and e.g preserve a red change by removing the red condition.
Overall, the solutions seems to work fine (being still at the development stage). I have a few reservations, though:
1) To use the diff alogrithm, I pretty much rely on Text.words being analogous to Text.contents.split(/\s+/). I'm not sure that this is a universal truth.
2) I'm not overly impressed with the speed of some of the operations (e.g. removing conditions from a text range). But alas, that may have more to do with me being pretty new to inDesign scripting...
3) The script needs to run in the "session" target engine, because I update the text popup menu. It seems to be the case that you then have to run the script from within inDesign rather than from the ExtendScript Toolkit. (Anyone?)
Anyway, if you are interested in the gory details, I can post the test script.
Best regards,
- Peder

Similar Messages

  • Using DW CS4 to insert text

    Hi when I am using CS4 to insert text i want to put some spaces between a couple of words on the same line.
    i.e.      
    please call      this    number        etc  etc
    how do i do that?
    Many thanks
    Mark

    Hi I know this may be a basic question, but I have not used <span> before.
    How do I set the distance of the span??
    this is what I have
    telephone<span>mobile<span>email   
    do I now need to style the spans?
    Many thanks

  • CS4 Problem getting text from Illustrator over to Photoshop.

    What a mess and why is  this so difficult. I finally figured out how to create my text on a curve and leave the letters going straight up and down. So I am trying to paste or drag and drop over to my bottle in Photoshop but what happens is that the text is in a clear area But then it creates a white box around that so I can't see my bottle. I have a lot of bottles I need to change the names on and no time to reshoot and knock them all out. Help please!!! I am going to try and attach images again but when I tried in  the Illustrator forum... the load button was greyed out.
    Now on top of it, I am trying to create an image to attach... and it's doing even more crazy stuff. I created an image with the full bottle on L and what is supposed to be the full bottle on the R = only instead for some reason.... my text is coming over from Illustrator with an additional white box blocking most my bottle... then on top of it.... I tried to just type in what was going on and then if I rasterize the text OR I just try to save.... it created a new black box blocking the bottom 1/2... now what do I do??? This is really a mess!!!!

    OK. The bottle on the L is what the bottle is supposed to look like.... minus the black box on the bottom. The L bottle is placed there in photoshop just to show what it is supposed to look like. Then the other layer had the bottle on the R or what is supposed to be the full bottle that I am trying to get my Eyelash Recovery text onto that one on that layer.
    The bottle on the R is the problem. The white box is the entire area around the small area of the bottle being shown. Yes, trying to bring just the text Eyelash Recovery over from Illustrator = it created the white box all by itself. (Create Outlines did not help at all)
    Note. I created the words Eyelash Recovery in text on a circle in Illustrator and then tried to drag and drop AND I tried to copy/paste into Illustrato = both ways. Both failed and created everything that is white around the R bottle that only shows the small area of the bottle. Anything around the small window of the bottle = which is actually a transparent area around the text Eyelash Recovery that allows the bottle on the L to show thru. So it came over as a small area of transparent window with the text in it (not centered as you can see) AND a white box around that window that I could not get rid of.
    But then, for some reason, it then also wanted to created the black blox on bottom out of the clear blue = where that came from I do not know.
    So I created the text Eyelash Recovery in Illustrator on the oval and placed it in position on the oval using the text on path tool. I then used the type > skew to get the text to bet straight up and down instead of curving into the oval. Then I tried 2 ways. 1 was to copy/paste into Photoshop on top of the bottle and the other was to drag and drop. It wanted to place it as pixels. So I allowed it to paste as pixels. And I allowed it to apply. In the layers palette however, it showed as a vector smart object = ???
    Then I tried to rasterize that layer which now said it wanted to rasterize the smart object (which I did not 1. place OR 2. drag and drop as a smart object).
    For some reason, instead of only coming over as the Eyelash Recovery text, it came over with just a small transparent window (which you can see on the L side above AND it created the rest as a white box around that that obliterated the rest of the image. Yes, I could move the Eyelash Recovery text and the transparent window around to show diff. parts of the bottle but only this amount as seen above. But I could not get rid of the white around the transparent window to see the bottle below in full and to place my Eyelash Recovery text.
    Then on top of it... for some reason, when I rasterized that layer, it created the black box you see on the bottom of the image above and there was no way to get rid of either the white area OR the black box area at bottom
    A mess?? Yes.

  • How in Flash CS4 to change text words of .fla file from a website template?

    I have a website template in which I am trying to change the header text words and menu text words to customize the template. How do I do this in Flash CS4? Thanks!

    There are any number of ways these text elements might have been designed into the file.  So you pretty much have to search for things.  If you do not see the text that you want to change when you open the fla file, then you may need to either make some layers visible that are not (eyeball icon next to layer name) or you may need to look into the actionscript code to see if the text is being dynamically written when the file opens.  If you happened to receive any .as, .txt, or .xml files with the template, the text elements may also be defined in those files.
    Just so you know, and this is just an observation, it appears from experience in these forums that template designers tend to make templates so that you are more likely to hire them to update things than to be able to solve it yourself.

  • Illustrator CS4 to PDF, text characters lost?!

    This sounds weird to me even as i type it. but i have converted a cs4 illustrator doc to a pdf and it is missing a character in one of the words. Lost during conversion??
    is this some sort of fluke??
    Heather

    ok, i see i may be using the wrong language. the font is Minion Pro, and i did "save as" a pdf from illy CS4 and i just find it odd that this one h is missing.
    it is from the outlined file which i find odd as well. this hasnt happened b4 which is why it worries me.
    Embedding fonts? is this something i have to do when saving the pdf? i feel really dumb right now b-cuz this has never happened.
    oh, and i attached the file, if you look in the first column of text fourth line down it reads 'ealthcare' instead of 'healthcare' which it reads in the .ai doc.
    thank you everyone who is trying to help me! i really appreciate it!!!!

  • CS4, Cannot write text

    I cannot write text on certain jpg images.  Any help is appreciated.
    CS4-64bit, CS4-32bit, and Elements behaves same.  I tried on
    Windows-7(64bit) and Windows-XP, but the symptom is same.
    After opening the captioned jpg image, I click "Text Tool", then draw
    rectangle frame by mouse.  The right side pane tells that layer-1 is
    created.
    At this point, there is no cursor(caret)  in the text box. Hitting keyboard
    does not bring any letters in it. I have set colors and letter size as
    visible.
    After cliking "move tool", the layer1 indicator shows the text I typed.
    But I see no text in the text box on the picture.
    Versions of CS4 is 11.0.1 and Elements is 6.0 of Japanese.
    The jpg file was created by my friend using a scanner. The picture
    is displayed normally on those applications as well as other image
    editing softwares.
    FastStoen (an image editor) and other softwares can write text
    on the picture.  Several pictures he made behaves same, on the
    other hand, pictures I created on my machine have no problems.
    Do I miss any setting?
    Thanks in advance.
    Tak
    (attached is the captioned file, but blurred extreamly respecting copyright.)

    Thanks John,
    The information follow:
    Mode: RGB Color, 8bit/channel
    Resolution: 5782x3946 pix, 36.12x25.06mm, 4000pix/inch
    Format: jpg
    Other information that I found:
      Made by Nikon Coolscan V ED, software is Nikon Scan version 4.0.0 W
    rgds
    Tak

  • [CS4] !!text Hebrew with problem unexpected

    This is driving me !sreknob
    I have a couple of Hebrew phrases in an otherwise English text, so I assigned the World Ready Composer to the styles in question using Peter Kahrel's "Arabic" set of scripts, and created a 'Hebrew' character style. No problem: the Hebrew text comes out perfect. What's Not So Nice is that some other text also follows an RTL direction!
    In the above screenshot, you can see the volume number and page range "2:663-676" appear correctly in the Story Editor below. The Story Editor does not know anything about Hebrew, so it reverses the Hebrew text. That's not a problem, because the World Ready Composer fixes that in the formatted text (above).
    But what is going on with the numbers!? No amount of copying & pasting seems to fix this. The paragraph direction is set to Left To Right; the Hebrew text has a character style that only applies another font.
    [Edit] Oh, and of course the square bracket at the right of the numbers isn't corerct either. ]It seems more than a bit [random to me.]

    A-ha! I was right, it's an automatic system going wild. Thanks for confirming it!
    > Sometimes it's easiest just to retype the whole thing....
    I must have used at least half a dozen different methods in the past. Fortunately, each one more advanced than the previous! Let me think, I have:
    * printed from Word to PDF and painstakingly imported/placed/scaled each separate phrase. Pro: anyone can do this. Con: Loads of extra work. Loads of fun with line-spanning text, and the occasional last minute correction. Cannot adjust font.
    * copied from PDF into Illustrator, saved as .ai, the rest as above. Pro: you can tinker with the text (a bit). Con: even more work.
    * reversed the characters in ID. Pro: fast, efficient, can use fonts. Con: it qorked nicely in CS3 and older, but CS4 tries to override accent placing and ligatures, which is troublesome for Hebrew. Also, Arabic needs to have Each Bloody Separate Character checked for correct initial/medial/final form. Another con: line-wrapping needs to be done manually. Only just feasible with short phrases; longer stories -- think of a full paragraph -- needs to be broken manually into lines, because otherwise right-to-left text also appears bottom-to-top.
    * cut phrases out of running text, pasted into separate text box, so I could finally use proper RTL character and paragraph formatting. Text boxes were then re-inserted into the text on the original position. Pro: finally! Automatic ligatures, wonky text cursor, real fonts -- the Real Thing. Con: still no good solution for line-wrapping text. Also, the text boxes themselves caused spacing problems.
    With all said and done, the following worked out nicely at the end:
    1. Add WRC to the correct styles. (I am *neurotic* about getting my style inheritance right. Since in this article both Hebrew and Arabic text appeared in different situations, I could set the WRC to only one style, and the rest also got it from there.)
    2.  Select all text and blindly set its character direction to Left-to-Right.
    3. Search for continuous spans of Hebrew and Arabic (which may include spaces and the occasional punctuation) and apply the right character set for the script to this. At this point I could either include or exclude spaces, periods at end, etc. by manually verifying if the GREP search matched the correct phrase.
    At a couple of positions I encountered the "Operator Error", where a single space was *not* included inside a long RTL phrase -- but only because in a case like this I do not trust my senses nor InDesign, and verify Each Seperate Phrase against the original copy ...

  • CS4 editable master text frames in CS5 no longer editable

    Hi,
    Problem: Text frames on CS4 document pages (from locked text frames on masterpage) are no longer editable on CS5 document pages.
    CS4 situation:
    Masterpages contain text frames which are locked to prevent users from inadvertently moving them when working on document pages.
    On document pages, the text frames can be edited, i.e. text entered, but are position-locked.
    CS5 problem:
    When you now open the same document, the text frames on the document pages are totally locked, the positioning as well as the content. This means they are no longer editable! The only way I have found to make them editable once again is to unlock the text frames. But unlocking also removes the position lock.
    What do I have to do to get things working in CS5 like they were in CS4? Any quick solution or is this simply no longer possible?
    Confounded by InDesign once again...

    Yes, it works just like in CS4! Wunderbar!
    As I just had some trouble finding the where to change this setting,
    for anyone working with the German version of InDesign CS5:
    Menü: Bearbeiten > Voreinstellungen > Allgemein
    then under "Objektbearbeitung", remove the checkmark from "Auswahl von gesperrten Objekten verhindern"
    Thanks!

  • CS4 Breaking linked text links

    Hi,
    In CS3 and before, simply double clicking on an out port of a text frame would break a link and remove the text from the downstream text frame. Same with the in port of the second text frame.
    But in CS4 doing this does remove the text, for a moment, and then it suddenly reappears.
    I have used all the usual modifier keys to no avail. Bug? Or is this a new feature designed to totally frustrate me?
    Thanks
    John

    Thanks.
    Must be something in my configuration, but no idea what.
    Just in case these are the steps I used:
    1 On master pages create 2 frames and establish a thread by clicking on out port and then on frame.
    2 On regular pages flow in text.
    3 Double click on first frames out port.
    This gives me a loaded cursor (unexpected) and the text disappears from frame two (expected)
    4 within a second the text reappears and the cursor stays loaded.
    5 The text in the second frame works as threaded text should flowing correctly when frame sizes are adjusted in the first frame.
    6 When Show Text Threads is selected the thread image is no longer there after the double click.
    THanks again.
    John

  • ID CS4 not placing text doc of 50 pages past page 1.

    I have not used ID in years. Now have CS4 and CS5 on desktop. I am trying to do a 50 page brochure
    so did page setup, half letter page, vertical. Then tried to place a PDF and same doc in Word 2007.
    Nothing shows up with Word Doc and only page 1 of PDF comes into ID doc. Am I missing something
    very basic here? thanks

    You seem to be missing a lot of the basics and without knowing what you hope to accomplish it’s hard to help.
    Hold the shift key down when clicking to place the Word file.
    Good book is Sandee Cohen’s Visual Quick Start Guide: http://amzn.to/tZuymQ
    Also, check out Lynda.com. This link will give you a free seven day trial:  http://bit.ly/fcGpiI
    Bob

  • Illustrator CS4 crashing on text size

    Hi all,
    below a sample of my script
    #target illustrator
    var doc=app.documents[0];
    doc.textFrames.getByName("FUERZA1").textRange.characterAttributes.size=15;
    redraw();
    info: there is only one opened doc and actived.. so documents[0]..
    and below my tree of layers
    Curiously, when i execute in the ExTK console:
    doc.textFrames.getByName("FUERZA1").textRange.characterAttributes.size=15;
    text size well changed, but when i execute the script (by play with ExTK or Illustrator) illustrator crashing
    If anyone have an idea for why, please advise me
    thanks in advance
    art.chrome

    Seems to be a bug. Workaround : split the command into parts
    d=doc.textFrames.getByName("FUERZA1").textRange;
    d.characterAttributes.size=15;

  • Luminosity and saturation blending modes in FW CS4 differ from their equivalents in PSE 7

    Example:
    Upper bitmap is filled with RGB(232,168,89) color and the lower with RGB(61,114,158) .
    Blending results are as follow:
    Luminosity in FW CS4: RGB(67,121,175)
    Luminosity in PSE 7: RGB(137,190,234)
    Saturation in FW CS4: RGB(60,109,158)
    Saturation in PSE 7: RGB(41,119,184)
    I think PSE uses chroma as saturation and luma Y' 601 with gamma compression (2.2 or 1.8) as luminosity.
    So it's compatible with PS. And what about FW. Does somebody know how FW works. I was experimenting with
    HLS and HSV and wasn't able to find it out. Maybe FW's modes are better in some web cases, I don't know.

    What happens to your blended colors in PSE if you turn off the color profiles?
    Fireworks is intended to produce graphics for display in Web applications, which have only recently begun to support color profiles. Even then, you don't want to use them on your page graphics (like nav buttons), because the profiles won't apply to HTML/CSS colors and you'll get mismatches.
    PS is primarily intended for photographs and for printing, and so the standard workflow in PS (and I suspect also PSE) is to apply at least a default color profile. One use of color profiles is to correct the colors for printers, but profiles will also change the colors in images.
    Have a read:
    http://www.viget.com/inspire/save-for-web-simply
    http://www.rumblingskies.com/blog/?p=46

  • CS4 displaying images/text really low res

    Not sure what happened but my vector images are coming out really low res...
    i have an 09 macbook pro, just upgraded to osx mountain lion, running CS4
    [URL=http://s324.photobucket.com/user/niudude/media/ScreenShot2013-09-12at62000PM_zpsa8fee4c0.p ng.html][IMG]http://i324.photobucket.com/albums/k359/niudude/ScreenShot2013-09-12at62000PM_zpsa8fee4c0. png[/IMG][/URL]
    any idea?

    Turn on anti-aliasing in the preferences.

  • Cs4 design premium text

    I have recently purchased cs4 design premium.  I have completed a brochure using the blank brochure template.  When I saved the ai file and reopened I received the "font problem" that the myriadpro-regular font is not found on the system.  I have read that using a font which is not universal can be a problem when printing from other locations and importing to other programs so I changed all the font to be "openType".  After saving this I still receive the same "problem".  I have checked my windows font list and the myriadpro-regular is actually listed.  I then went to the blank brochure template supplied with cs4 and discovered the template gets the same "problem".  What is wrong with this?  Any help would be greatly appreciated.

    I have read this and I understand the open type font.  I don't understand why when I open the blank brochure template from Adobe it gives me the error message:
    MyriadPro-Regular:
         Font not found on the system; missing font has been substituted.
    Since I was not able to get support from Adobe I changed all the font I could find on the brochure to a standard Open Type font found in my "font" directory even though I knew the MyriadPro-Regular was also on the system.  I even searched for a way to ask Illustrator to search the document for the "rogue" font to no avail.  No matter what I do I receive this message every time I open one of my brochures.  I am able to print the brochure but I am afraid this might be a problem later on.  Is the Illustrator font file elsewhere?  Did it not load when the software loaded?  Is there a file path missing?  I have found nothing in the help to tell me where Illustrator looks for the for the font.  I thought at first I had done something wrong, being new to Illustrator.  Then I opened the template again and received the same error when I had done nothing but open the template.
    I really appreciate your answering my query but I still don't know what is wrong and how to fix it.  From the way I understood the places you referenced, this is what I would do if the fonts were missing from the system.  If this is not correct please let me know.
    Thanks again for your response
    mg

  • Text appearing as Bold and Italic in CS4

    Hi Guys
    Whenever I create a new document and type into it the text is automatically 'bold' and 'italics', I have saved the page and opened on another computer running CS4 and the text is fine (not bold or italic). I have created a page on another computer and opened it on the troublesome one and again it is bold and italic ((
    I cannot see anything in the preferences that may cause it, I have also discarded the configuration folder which contains the preferences for the program - no good either (( So as a last resort I have re-installed Dreamweaver and it is still playing up. I guess I can re-installs the complete CS4 suite but rather not as it is going to take a while and also may not fix the problem.
    Any ideas anybody??

    I have just copied the code from the page as below and as you can see there is no bold or italic applied:-
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    hello
    </body>
    </html>

Maybe you are looking for

  • Problem with SQL Server data on webpage

    Hello, we recently 'upsized' from Access to MS SQL Server 2005. I'm trying to port over my webpages but have run into a very bizarr behavior, some data from some fields in my table appear on my web pages and some do not. In fact, depending on where I

  • Menubar Sampe Issue on IE6

    Thanks for great framework, Spry Team! I noticed some issue on menu bar sample. Following sample works ok with FF, IE7 bt not for IE6. Problem is alignment of sub level list is not inherited from top level. Hope this will be fixed in next release...

  • Handhelds disconnects randomly

    Hi, We have a 4404 WLC. Handhelds are disconnecting randomly. I am getting : /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:9

  • Package doesnot exists????

    Hi all, My Jdev version is 11.1.2.3.0. The application was working very fine. later i created AppModuleImpl.java and added one method to AppModuleImpl.java. After adding one method in AppModuleImpl.java getting error after running page package doesno

  • X-Fi XtremeGamer compatable with X-Fi I/O Drive Upgrade K

    Could i hook up this dri've upgrade kit to an x-fi xtremegamer sound card?