issue-#113 XhtmlExporter bug with StdLinks.Target

Post Reply
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by Josef Templ »

In BeginPara it would be simple to also support the "lead" attribute of text rulers.
It would look like:

Code: Select all

			IF e.currentRuler.style.attr.lead > 0 THEN
				Strings.IntToString(e.currentRuler.style.attr.lead DIV Fonts.point, str);
				IF attr[0] # 0X THEN attr := attr + " " END;
				attr := attr + "margin-top: " + str$ + "pt;"
			END;
Unfortunately the line spacing is not so simple.

The handling of non-breaking-spaces also has/had a bug.
It outputs a normal (breaking) space unless it is not the first space in a sequence of spaces.
A correct form IMHO would be:

Code: Select all

				IF ch = " " THEN
					IF e.afterSpace THEN e.wr.Data(" ") ELSE e.wr.Data(" "); e.afterSpace := TRUE END
				ELSIF (ch = TextModels.nbspace) OR (ch = TextModels.digitspace) THEN
					e.wr.Data(" "); e.afterSpace := FALSE
- Josef
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by Ivan Denisov »

Added this changes. Agree that such spaces parsing is more correct.
http://blackboxframework.org/unstable/i ... b1.538.zip
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by Zinn »

Another change may be to use the default font instead of Arial in MODULE XhtmlExporter

Code: Select all

	VAR
		defaultTypeface: Fonts.Typeface;
		defaultSize: INTEGER;
...
	BEGIN
		defaultTypeface := Fonts.dir.Default().typeface;
		defaultSize := Fonts.dir.Default().size;
- Helmut
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by Ivan Denisov »

Zinn wrote:Another change may be to use the default font instead of Arial in MODULE XhtmlExporter
It is a problem to get default typeface name.

Fonts.dir.Default().typeface is "*";

I anybody find how to get default typeface it will be very useful.
luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by luowy »

Ivan Denisov wrote:Fonts.dir.Default().typeface is "*";
cast and use HostFonts.Font.alias;

Code: Select all

MODULE ObxFonts;
	IMPORT Fonts, HostFonts, Log := StdLog;
	
	
	PROCEDURE Do* ();
		VAR typeface: Fonts.Typeface;
	BEGIN
		typeface := Fonts.dir.Default()(HostFonts.Font).alias;
		Log.String(typeface); Log.Ln;
	END Do;


END ObxFonts.
luowy
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by Zinn »

Another point is that I don't like two or more <br/> in series. It is better to use </p> and <p> instead.
- Helmut
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by Josef Templ »

Zinn wrote:Another point is that I don't like two or more <br/> in series. It is better to use </p> and <p> instead.
- Helmut
And why?
If the BB text has multiple new lines in series why should that be translated into something different?

- Josef
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by Josef Templ »

@Ivan: There is a bug in SetAttr.
I tried to read it but it is pretty hard to read. Then I made some experiments
and found a bug with the nesting of bold and italics.

aaabbbccc

Code: Select all

<p><b><i>aaa</b>bbb<b>ccc</i></b></p>
It can be seen that some tags are overlapping instead of nested.

My conclusion is that SetAttr needs to be polished.
It dropped some important comments and inserted empty lines instead. A bad deal.
It uses e.wr.Data for start and end tags but should use StartTag and EndTag instead.
The complex logic conditions need to be reformatted in order to make the nesting visible.
Fixing the bug should not add to the complexity but reduce it.

- Josef
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by Zinn »

Josef Templ wrote:
Zinn wrote:Another point is that I don't like two or more <br/> in series. It is better to use </p> and <p> instead.
- Helmut
And why?
If the BB text has multiple new lines in series why should that be translated into something different?

- Josef
It is a question about text formatting. Multiple spaces and new lines are ignored in Html.
In Html text formatting are not done with spaces and new lines. Text formatting are done with paragraph, list, tables and CSS.

Normally text are grouped in paragraph which allow to have line breaks but it is not grouped with line breaks. Line breaks should be used rarely.

The sample 1 2 3 What is Blackbox is translated wrong. A better translation uses list <li>, but I can accept line breaks here.
The original translation with paragraph is much better, even the result of the formatting looks wrong.

It is like the same situation as if you write a letter with the typewriter. There you have a line break at each line.
Now you change from typewriter to word and write the same letter. It is wrong to have a line break at the end of each line.

- Helmut
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#113 XhtmlExporter bug with StdLinks.Target

Post by Josef Templ »

Here is a corrected and (IMHO) polished version of SetAttr.
It solves the nesting bug.
It uses StartTag/EndTag.
It also adds support for strikeout.
By the way, was there a special reason for changing <em> to <i> and <strong> to <b>?

- Josef

Code: Select all

	PROCEDURE SetAttr (e: Exporter; newAttr: TextModels.Attributes);
	(* nesting: <p> <span> <b> <i> text </i> </b> </span> </p> *)
		CONST bold = (Fonts.normal + Fonts.bold) DIV 2;
		VAR s, tmp: ARRAY 256 OF CHAR;
	BEGIN
		ASSERT(e # NIL, 100);
		IF e.inPara & (e.attr # newAttr) & ((e.attr = NIL) OR (newAttr = NIL) OR ~e.attr.Equals(newAttr)) THEN
			IF e.attr # NIL THEN (* close all special attributes *)
				IF Fonts.italic IN e.attr.font.style THEN e.wr.EndTag(*i*) END;
				IF e.attr.font.weight >= bold THEN e.wr.EndTag(*b*) END;
			END;
			IF (newAttr = NIL) OR (e.attr = NIL)
			OR (e.attr.font.typeface # newAttr.font.typeface)
			OR (e.attr.font.size # newAttr.font.size)
			OR (e.attr.color # newAttr.color)
			OR (Fonts.underline IN newAttr.font.style / e.attr.font.style)
			OR (Fonts.strikeout IN newAttr.font.style / e.attr.font.style) THEN (* close span *)
				IF e.inSpan THEN e.wr.EndTag(*span*); e.inSpan := FALSE END
			END;
			IF (newAttr # NIL) & (~e.inSpan) THEN (* open span *)
				s := "";
				IF (newAttr.font.typeface # defaultTypeface) & (newAttr.font.typeface # Fonts.default) THEN
					s := "font-family: " + newAttr.font.typeface$ + ";"
				END;
				IF newAttr.color # Ports.defaultColor THEN
					IF s[0] # 0X THEN s := s + " " END;
					ColorToString(newAttr.color, tmp);
					s := s + "color: " + tmp + ";"
				END;
				IF newAttr.font.size # defaultSize THEN
					IF s[0] # 0X THEN s := s + " " END;
					Strings.IntToString(newAttr.font.size DIV Fonts.point, tmp);
					s := s + "font-size: " + tmp + "pt;"
				END;
				IF Fonts.underline IN newAttr.font.style THEN
					IF s[0] # 0X THEN s := s + " " END;
					IF Fonts.strikeout IN newAttr.font.style THEN s := s + "text-decoration: underline line-through;"
					ELSE s := s + "text-decoration: underline"
					END
				ELSIF Fonts.strikeout IN newAttr.font.style THEN
					IF s[0] # 0X THEN s := s + " " END;
					s := s + "text-decoration: line-through;"
				END;
				IF s[0] # 0X THEN
					e.wr.StartTag("span", XhtmlWriters.preserve); e.wr.Attr("style", s);
					e.inSpan := TRUE
				END
			END;
			IF newAttr # NIL THEN (* open all special attributes *)
				IF newAttr.font.weight >= bold THEN e.wr.StartTag("b", XhtmlWriters.preserve) END;
				IF Fonts.italic IN newAttr.font.style THEN e.wr.StartTag("i", XhtmlWriters.preserve) END
			END;
			e.attr := newAttr
		END
	END SetAttr;
StdCoder.Decode ..,, ..fq....3Qw7uP5PRPPNR9Rbf9b8R79FTvMf1GomCrlAy2xhX,Cb2x
hXhC6FU1xhiZiVBhihgmRiioedhgrZcZRiXFfaqmSrtuGfa4700zdGrr8rmCLLCJuyKtYcZRiX
7.2.s,6AP.0k,5TWyql.bnayKmKKqGomC5XzET1.PuP.MHT9N9ntumaU2,CJuyKtQC98P9PP7O
NbXmb.2.ojAk2Evm.,6.cUG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