Dhara
Dhara

Reputation: 1972

Format HTML using tidymanaged

I am using Tidymanaged to format HTML..

                using (Document doc = Document.FromFile(AppPath + "/" + DefaultFileName))
                {
                    doc.ShowWarnings = false;
                    doc.Quiet = true;
                    doc.DocType = TidyManaged.DocTypeMode.Strict;
                    doc.DropFontTags = true;
                    doc.UseLogicalEmphasis = true;
                    doc.OutputXhtml = false;
                    doc.OutputXml = false;
                    doc.MakeClean = true;
                    doc.DropEmptyParagraphs = true;
                    doc.CleanWord2000 = true;
                    doc.QuoteAmpersands = true;
                    doc.JoinStyles = false;
                    doc.JoinClasses = false;
                    doc.Markup = true;
                    doc.IndentSpaces = 4;
                    doc.IndentBlockElements = TidyManaged.AutoBool.Yes;
                    doc.CharacterEncoding = TidyManaged.EncodingType.Utf8;
                    doc.WrapSections = false;
                    doc.WrapAttributeValues = false;
                    doc.WrapScriptLiterals = false;
                    doc.CleanAndRepair();
                    parsed = doc.Save();
                }

its working perfectly but HTML doesnot come in proper format that is after 4 5 words it break to new line...It gives HTML like

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta name="generator" content=
        "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
        <link rel="stylesheet" type="text/css" href=
        "../lib/styles/default/general_app.css">
        <link rel="stylesheet" type="text/css" href=
        "../lib/styles/default/agent_app.css">
        <link rel="stylesheet" type="text/css" href=
        "../lib/styles/default/calendar.css">
        <script type="text/javascript" src=
        "../lib/scripts/usertrap.js">
</script>
        <script type="text/javascript" src=
        "../lib/scripts/popup.js">
</script>

where I want HTML is like,

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
                <head>
                    <meta name="generator" content="HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
                    <link rel="stylesheet" type="text/css" href="../lib/styles/default/general_app.css">
                    <link rel="stylesheet" type="text/css" 
   href="../lib/styles/default/agent_app.css">
                    <link rel="stylesheet" type="text/css" 
   href="../lib/styles/default/calendar.css">
                    <script type="text/javascript" src="../lib/scripts/usertrap.js">
            </script>
                    <script type="text/javascript" src="../lib/scripts/popup.js">
            </script>

Upvotes: 1

Views: 1005

Answers (1)

Duke0fAnkh
Duke0fAnkh

Reputation: 301

To prevent the lines from wrapping add the following:

doc.WrapAt = 0;

The default is 68, so will wrap at that line length. Set to zero to prevent wrapping: http://tidy.sourceforge.net/docs/quickref.html#wrap

Upvotes: 5

Related Questions