WPCubed Product Support

1st header line not kept if html is used as input&output

I am trying out if I can use WpTools 6 as simple wysiwyg html editor.
Look at the following sample input file:

<h1>Title 1 header</h1><p>This the first paragraph.</p><ul><li>Unordered list item 1</li><li>Unordered list item 2</li><li>Unordered list item 3</li><li>Unordered list item 4</li></ul><h2>Title 2 header</h2><p>Paragraph in title 2 </p><ol><li>Ordered list item 1</li><li>Ordered list item 2</li><li>Ordered list item 3</li></ol><a href='http://www.sitestepper.com' rel='external'>Website of Sitestepper</a>

Loaded into WpTools with the line:

wprt.LoadFromString( EasyEdit.EditSource.Strings.Text, 'HTML' );

and back with the line:

EasyEdit.Lines.Text := wprt.AsANSIString('HTML-OnlyHTMLBody,DontWriteFontParams,ignorefonts,nostyles,nocharstyles,nonumstyles');

Produces the following html-code:

<html>
<head></head><body style="margin-left:1.31in;margin-right:1.31in;margin-top:1.00in;margin-bottom:1.00in">
<div style="font-size:24.00pt;font-weight:bold;margin:0.05in 0.00in 0.00in 0.00in;">Title 1 header</div>
<p style="font-size:9.00pt;margin:0.00in 0.00in 0.10in 0.00in;">This the first paragraph (modified).</p>
<ul style="list-style-type:bullet;"><li>Unordered list item 1</li>
<li>Unordered list item 2</li>
<li>Unordered list item 3</li>
<li>Unordered list item 4</li>
</ul><h2 style="font-size:18.00pt;font-weight:bold;margin:0.05in 0.00in;">Title 2 header</h2>
<p style="font-size:9.00pt;margin:0.00in 0.00in 0.10in 0.00in;">Paragraph in title 2</p>
<ol type="1"><li>Ordered list item 1</li>
<li>Ordered list item 2</li>
<li>Ordered list item 3</li>
</ol><div><a href="http://www.sitestepper.com">Website of Sitestepper</a> </div>
</body></html>

Not too bad, but:

The <h1> which is removed is clearly a bug, no ?
Is there a way to make sure no font and margin style parameters are added by WpTools.

#1 ♥ 0
5.1k Views 2 links 2 users read 4 min

Update: I found out myself how to delete the font-size and margin properties:

var par : TParagraph;
begin
            par := wprt.FirstPar;
            while par<>nil do
            begin
               par.ADel(WPAT_CharFontSize);
               par.ADel(WPAT_CharStyleON);
               par.ADel(WPAT_IndentLeft);
               par.ADel(WPAT_IndentRight);
               par.ADel(WPAT_SpaceBefore);
               par.ADel(WPAT_SpaceAfter);
               par.ADel(WPAT_NumberSTYLE);
               //par.ADelAllCharAttrDefinedIn();
               //par.IsNewPage := false;
               par := par.NextPar;
            end;

I found no explanation on "ADelAllCharAttrDefinedIn();"

Any more ideas or suggestions for better code would be appreciated ?

#2 ♥ 0

Just to keep my tests a bit documented.

If I use

par.ADel(WPAT_NumberSTYLE);

The <ul>..</ul> and <ol>..</ol> lines are deleted (which is incorrect html syntax), of course.

Anyway: I hope that Julien still can give a solution to the disappearing <h1> line ...

And if anyone else is trying to use WpTools 6 as an html editor, please let me know. Maybe we can help each other ...

#3 ♥ 0
support

Hi,

ADelAllCharAttrDefinedIn is used to remove the attributes which are redundant. Internalle it reoves the overriding character attributes. This function is necessary for support of paragraph styles.

<h1> ... are currently not used, just the class=.... IF an only if a paragraph style is used for a paragraph.

When YOu delete the paragraph attributes, You could also use AClear.

Julian

#4 ♥ 0
This category is archived. No new posts are possible.