Skip to main content
Known Participant
June 22, 2026
Question

An issue with soft returns embedding before paragraph tags in Structured framemaker 22

  • June 22, 2026
  • 12 replies
  • 60 views

When importing xml into Structured FrameMaker 22, a soft return is embedded before the paragraph tag, pushing heading to the next line.

 

It should look like this:

 

In the xml xml:space="preserve" has been added because a tag is included in the xml:

<mainhead xml:space="preserve">Average annual total returns (%) <emphasis role="submainhead">(See important legal information)</emphasis></mainhead>

If I remove xml:space="preserve" , it eliminates the soft return but it does not recognize the tag, so the tag is not applied.

Microsoft CoPilot created  a script to remove these soft returns, but it is not working when I run it.

Any help resolving this will be appreciated.

Here is the script:
 

#target framemaker

function removeSoftReturnsInMainhead() {
    var doc = app.ActiveDoc;
    if (!doc.ObjectValid()) {
        alert("No active document.");
        return;
    }

    var pgf = doc.FirstPgfInDoc;
    var count = 0;

    while (pgf.ObjectValid()) {

        if (pgf.Element.ObjectValid() && pgf.Element.GI === "mainhead") {

            var tr = new TextRange();
            tr.beg.obj = pgf;
            tr.beg.offset = 0;
            tr.end.obj = pgf;
            tr.end.offset = Constants.FV_OBJ_END_OFFSET;

            var text = doc.GetText(tr);

            if (text && text.indexOf("\r") !== -1) {

                // Clean up soft returns
                var cleaned = text

                    .replace(/\r|\n/g, " ")
                    .replace(/\s+/g, " ");

                doc.SetText(tr, cleaned);
                count++;
            }
        }

        pgf = pgf.NextPgfInDoc;
    }

    alert("Done. Updated paragraphs: " + count);
}

removeSoftReturnsInMainhead();



 

    12 replies

    frameexpert
    Community Expert
    Community Expert
    June 22, 2026

    You can try this flag in the maker.ini. I suggest adding it to the maker.ini file in your user area.

    [Preferences]
    RemoveExtraWhiteSpacesOnXMLImport=On
     

    Here is the user maker.ini location:

    C:\Users\<UserName>\AppData\Roaming\Adobe\FrameMaker\<VersionNumber>

    where <UserName> is your Windows login name and <VersionNumber> is your FrameMaker version. Any key/values in the user maker.ini override those in the Program Files maker.ini file.

    If you still have problems, please contact me off-list and we can meet. It will be easier to troubleshoot via zoom or teams. I can tell you why your script isn’t working too. rick at frameexpert dot com

    www.frameexpert.com
    Known Participant
    June 22, 2026

    Thanks. I will try these suggestions and follow up with you, if necessary. Thanks

    Known Participant
    June 22, 2026

    I’ve tried to resolve it via the import process, and have not come up with a successful solution

    Jeff_Coatsworth
    Community Expert
    Community Expert
    June 22, 2026

    Maybe describe your process? It appears from a quick Google that you need to choose a Structured Application that will understand your XML and translate it into FM.

    Known Participant
    June 22, 2026

    Yes. The translation is working. The xml is importing into FrameMaker and is producing a valid, formatted FrameMaker file.

    Jeff_Coatsworth
    Community Expert
    Community Expert
    June 22, 2026

    That’s kind of along the lines I was thinking - instead of repairing the post-import results, why not concentrate on the import process itself? Not being a Structured FM user either, I have no idea of how it’s supposed to work, but I would imagine that your structured tags in FM would match the tags in the XML content coming in.

    Community Expert
    June 22, 2026

    Hi,

    I am not an ExtendScript expert. However, I would assume that the GetText line is not correct. The flags which define the object types are missing.

    And I would try to find out, why there are manual line breaks. I do not work with Structured FrameMaker. Therefore I cannot help with your preserve attribute.

    Best regards, Winfried