Skip to main content
Participant
April 7, 2011
Question

breakOpportunity across successive spanElements

  • April 7, 2011
  • 1 reply
  • 491 views

I'm working on an editing application. I have a couple of questions about how breakOpportunity property is applied to spanElements.

Say I have entered some text like this:

"Which of the diagrams below shows a sketch of  y = –3 – f(x)?"

And the "y", "f" and "x" in the equation are italicized. So if I export the flow to XML, the relevant paragraphElement looks like this:

  <p>

      <span>Which of the diagrams below shows a sketch of  </span>

      <span fontStyle="italic">y</span>

      <span> = –3 – </span>

      <span fontStyle ="italic">f</span>

      <span> (</span>

      <span fontStyle ="italic">x</span>

      <span>)?</span>

    </p>

I want to avoid the equation from breaking over a line, so I apply breakOpportunity="none" to the equation part. The resulting exported flow looks like this:

<p>

      <span>Which of the diagrams below shows a sketch of  </span>

      <span fontStyle="italic" breakOpportunity="none">y</span>

      <span breakOpportunity="none"> = –3 – </span>

      <span fontStyle ="italic" breakOpportunity="none">f</span>

      <span breakOpportunity="none"> (</span>

      <span fontStyle ="italic" breakOpportunity="none">x</span>

      <span breakOpportunity="none">)?</span>

    </p>

The TLF seems to treat the successive "breakOpportunity" settings as a single group and doesn't break the equation. (It's a little hard to test, but by typing or deleting one character at a time before the equation, it never breaks.)

First question: could someone confirm that this is how it works?

It seems a little illogical to me, as the above XML suggests breaks should perhaps be allowed between the spans. For example, when used with Apache FOP for pdf generation, a simple template matching of attributes will allow breaking of the text between the spans.

What I really want to export is something like this:

<p>

      <span>Which of the diagrams below shows a sketch of  </span>

     <span breakOpportunity="none">

        <span fontStyle="italic" >y</span>

        <span> = –3 – </span>

        <span fontStyle ="italic">f</span>

        <span> (</span>

        <span fontStyle ="italic">x</span>

        <span >)?</span>

     </span>

    </p>

But I don't see how to do this 'easily' with the available tools. I thought the new SubParagraphGroupElement might be of some help here, but I don't see how to attach one around some existing span elements in an editing environment. Is this possible or practical?

Any help appreciated.

This topic has been closed for replies.

1 reply

Adobe Employee
April 8, 2011

From the TLF specification, breakOpportunity is an attribute applied only to leafElement, like <span>.

If it's *none*, it can only make sure one word in the span won't break.

In your scenario, * = –3 – * will be treated as 4 words.*=-3-*(without space) will be treated as one word.

I think what you want is that the expression *y = –3 – f(x)?* won't wrap. You must use another attribute named LineBreak, which is applied only to <textflow> <div> <li> (But I try <div>, it doesn't work. Maybe it's a bug.).

You can make the container's width very short to have a try and see the result.

What's more, <g> is SubParagraphGroupElement. No specific attribute for it in the specification now.

Participant
April 10, 2011

Thanks for the comment.

I don't think lineBreak is what I need. I want the text in the field to wrap, just not within the math statement.

Actually, I now realize the behavior of not wrapping across successive spans that have breakOpportunity set to "none" makes sense. The TLF break opportunity is character based, i.e. a character that acts as a break opportunity needs to be found. Typically this is a space character. But as no character in the successive spans meets the requirement, no break occurs. This is the behavior I need, so I'm happy in that respect.

But it's a little different from other environments where the equivalent is a "keep-together" property (e.g. in XSL-FO). Here, text may break between successive spans that have have the keep-together property set.