Line break with LabelWords

If you put the link on a line of its own then it inserts it.

If you put the link inside angled brackets then it keeps the link as the link address - otherwise it turns the link into the title.

Okay - will see if we can fix this up. And, thanks for the nice message! It is our pleasure. Thanks for using ZIM.

1 Like

labelletters

Should the sixth one look like this?

The sixth should look like this:

Hm... I don't understand. This is what makes sense to me. Can you tell me where my thinking is going wrong - perhaps in a similar diagram? Thanks - sorry.

We have the original text at the top and we have dimensions that would go from the right side to the red line. It does not fit so we break on the first triangle.

Then the second line is too long so we break at the second triangle.

This gives us the final three lines.

The original sentence should be like this:
image

Not like this:
image

Ah okay. So my thoughts on how it should split are correct - I just have the initial text wrong.

Why is the label text in the code like this:

Does it get mixed up when tags are added? What would the label text look like without the tags?

I would also need to know two more things:

  1. what happens if there is another set of tags outside the first set?
  2. what happens if there is another set of tags inside the first set (nested)?

@abstract
Comments in the code body
https://zimjs.com/beam/labellettersrtlflow/show
Thanks!

** Note, what happens when using backgroundColor

Okay - it looks like to go from #2 with the tag to the correct order that we would reverse all the letters of #2 to get a proper rtl version. Will try and look tonight but teaching all day and going out dancing later... but there might be time. Thanks again for your patience and help.

1 Like

Okay - working through this now. It seems that we have some code to handle rtl inside the tag parsing. When this code is commented out then all we would need to do is reverse the letter order to get the correct rtl order #2 in your beam example. The result would be like #3 if we comment out the code below.

I am not sure really, what that code is doing, though. Do you think that you guys might have worked on that code at some time and there was a reason for it?

// var example = "LabelLetters()<br><br><font group=heading backgroundColor=yellow rollBackgroundColor=green><a href=https://zimjs.com target=_blank>Example</a></font>: <b>strong</b> <i>emphasis</i> <u>underline</u><br><font color=red size=50 family=verdana><strong>big</strong> red verdana</font><br>the next line"
// "LabelLetters()Example: strong emphasis underlinebig red verdanathe next line"
// "01234567890123456789012345678901234567890123456789012345678901234567890120123456789012"
// "0         1         2         3         4         5         6         7"
// html = "!Roger הגיע בשבילך משהו בדואר Dan אני לומד עברית";
// html = "הגיע בשבילך משהו בדואר.";
			
function insert(data) {	
	return data.split("").reverse().join("")
}
if (rtl) {
	count = -1;				
	html = html.replace(/[\u0591-\u07FF]+/ig, insert);	
	
	// and there may be tags or LTR characters next to RTL without a space:
	html = html.replace(/([^\u0591-\u07FF ])([\u0591-\u07FF])/ig, "$1-!!-$2"); // note the not space
	html = html.replace(/([\u0591-\u07FF])([^\u0591-\u07FF ])/ig, "$1-!!-$2"); // note the not space				
	html = html.replace(/([^\u0591-\u07FF]) ([\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
	html = html.replace(/([\u0591-\u07FF]) ([^\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
	
	var sp = html.split(/-!!-/g);
	zim.loop(sp, function(ssp, i){
		if (ssp.match(/[\u0591-\u07FF]/i)) {
			sp[i] = ssp.split(" ").reverse().join(" ");
		}
	});
	html = sp.join("");	
}

We will try a version and send you a test page. Just working on it now.

Okay - you said this was the right text:

and here is the text with a tag:

and here is the text with the tag and a labelWidth

image

This is with commenting that code out and reversing the letter order before doing the line splitting. We also had to redo part of the splitting to go from right to left with RTL. You can test it more with the following ZIM file: https://zimjs.org/cdn/017/zim_doc_rtl.js

Let us know how it goes - did not try nested tags, etc.