tidy php что это

HTML Tidy

Documentation Introduction

On this page you can refer to nearly everything you need to know about HTML Tidy. If you’re on macOS, Linux, or UNIX you can also use man tidy and read the purpose-built documentation for the version of Tidy that you have installed.

You can find configuration quick references in the API and Quick Reference Site.

If you’re a developer using libtidy please consult the API and Quick Reference Site here, and the libtidy Introduction page.

And if you simply want to use Tidy, then please read on.

What Tidy does

Tidy corrects and cleans up HTML content by fixing markup errors. Here are a few examples:

Mismatched end tags:

subheading

subheading

here is a para bold bold italic bold? normal?

here is a para bold bold italic bold? normal?

italic heading

italic heading

Tag in the wrong place:

Missing “/” in end tags:

List markup with missing tags:

Note Tidy will warn about the missing ul close tag, but not about the optional li close tag.

Missing quotation marks around attribute values

Tidy inserts quotation marks around all attribute values for you. It can also detect when you have forgotten the closing quotation mark, although this is something you will have to fix yourself.

Tidy has a comprehensive knowledge of the attributes defined in HTML5. That often allows you to spot where you have mis-typed an attribute.

Tags lacking a terminating >

This is something you then have to fix yourself as Tidy cannot determine where the > was meant to be inserted.

Running Tidy

Running Tidy in a Terminal (Console)

This is the syntax for invoking Tidy from the command line:

tidy [[options] filename]

Tidy defaults to reading from standard input, so if you run Tidy without specifying the filename argument, it will just sit there waiting for input to read.

Tidy defaults to writing to standard output. So you can pipe output from Tidy to other programs, as well as pipe output from other programs to Tidy. You can page through the output from Tidy by piping it to a pager, e.g.:

tidy file.html | less

To have Tidy write its output to a file instead, either use the

option, or redirect standard output to the file. For example:

Both of those run Tidy on the file index.html and write the output to the file output.html, while writing any error messages to standard error.

Tidy defaults to writing its error messages to standard error (that is, to the console where you’re running Tidy). To page through the error messages along with the output, redirect standard error to standard output, and pipe it to your pager:

tidy index.html 2>&1 | less

To have Tidy write the errors to a file instead, either use the

option, or redirect standard error to a file:

Both of those run Tidy on the file index.html and write the output to the file output.html, while writing any error messages to the file errs.txt.

Writing the error messages to a file is especially useful if the file you are checking has many errors; reading them from a file instead of the console or pager can make it easier to review them.

That runs Tidy on the file index.html, modifying it in place and writing the error messages to the file errs.txt.

Running Tidy in Scripts

If you want to run Tidy from a Perl, bash, or other scripting language you may find it of value to inspect the result returned by Tidy when it exits: 0 if everything is fine, 1 if there were warnings and 2 if there were errors. This is an example using Perl:

Источник

Tidy php что это

Простой пример, демонстрирующий базовые возможности использования Tidy.

Пример #1 Базовые возможности использования Tidy

();
?>
a html document
= ob_get_clean ();

User Contributed Notes 3 notes

If you are looking for HTML beautifier (a tool to indent HTML output produced by your script), Tidy extension might not be the right tool for the job.

First and foremost, you should not be using either Tidy or alternatives (e.g. HTML Purifier) in the production code. HTML post procession is relatively resource demanding task, esp. if the underlying implementation relies on DOM API. However, beyond performance, HTML beautification in production might hide far more serious output issues that will be hard to trace back, because output will not align with the input.

If you are indenting to use indentation (consistent, readable formatting of the output) for development purposes only then you might consider implementation that relies on regular expression. I have written, https://github.com/gajus/dindent for this purpose. The difference between earlier mentioned implementation and the latter is that regular expression based implementation does not attempt to sanitise, validate or otherwise manipulate your output beyond ensuring proper indentation.

= array( ‘indent’ => ‘auto’ ); // WILL NOT WORK
$tidy_options = array( ‘indent’ => 2 ); // equivalent of auto

If you’re using tidy to clean up your HTML but only want your string formatted and not the whole html and head tag, you can use the following configuration array:

Источник

Tidy Functions

Tidy is a binding for the Tidy HTML clean and repair utility which allows you to not only clean and otherwise manipulate HTML documents, but also traverse the document tree.

Замечание: Tidy 1.0 is just for PHP 4.3.x, while Tidy 2.0 is just for PHP 5.

You can always download the tar.gz package and install tidy by hand:

Пример 1. tidy install by hand in PHP 4.3.x

Таблица 1. Tidy Configuration Options

Name Default Changeable Changelog
tidy.default_config «» PHP_INI_SYSTEM Available since PHP 5.0.0.
tidy.clean_output «0» PHP_INI_PERDIR Available since PHP 5.0.0.

Краткое разъяснение конфигурационных директив.

Default path for tidy config file.

Turns on/off the output repairing by Tidy.

Do not turn on tidy.clean_output if you are generating non-html content such as dynamic images.

Данное расширение не определяет никакие типы ресурсов.

Замечание: The properties marked with * are just available since PHP 5.1.0.

Перечисленные ниже константы определены данным расширением и могут быть доступны только в том случае, если PHP был собран с поддержкой этого расширения или же в том случае, если данное расширение подгружается во время выполнения.

Each TIDY_TAG_XXX represents a HTML tag. For example, TIDY_TAG_A represents a link tag. Each TIDY_ATTR_XXX represents a HTML atribute. For example TIDY_ATTR_HREF would represent the href atribute in the previous example.

The following constants are defined:

Таблица 2. tidy tag constants

constant
TIDY_TAG_UNKNOWN
TIDY_TAG_A
TIDY_TAG_ABBR
TIDY_TAG_ACRONYM
TIDY_TAG_ALIGN
TIDY_TAG_APPLET
TIDY_TAG_AREA
TIDY_TAG_B
TIDY_TAG_BASE
TIDY_TAG_BASEFONT
TIDY_TAG_BDO
TIDY_TAG_BGSOUND
TIDY_TAG_BIG
TIDY_TAG_BLINK
TIDY_TAG_BLOCKQUOTE
TIDY_TAG_BODY
TIDY_TAG_BR
TIDY_TAG_BUTTON
TIDY_TAG_CAPTION
TIDY_TAG_CENTER
TIDY_TAG_CITE
TIDY_TAG_CODE
TIDY_TAG_COL
TIDY_TAG_COLGROUP
TIDY_TAG_COMMENT
TIDY_TAG_DD
TIDY_TAG_DEL
TIDY_TAG_DFN
TIDY_TAG_DIR
TIDY_TAG_DIV
TIDY_TAG_DL
TIDY_TAG_DT
TIDY_TAG_EM
TIDY_TAG_EMBED
TIDY_TAG_FIELDSET
TIDY_TAG_FONT
TIDY_TAG_FORM
TIDY_TAG_FRAME
TIDY_TAG_FRAMESET
TIDY_TAG_H1
TIDY_TAG_H2
TIDY_TAG_H3
TIDY_TAG_H4
TIDY_TAG_H5
TIDY_TAG_H6
TIDY_TAG_HEAD
TIDY_TAG_HR
TIDY_TAG_HTML
TIDY_TAG_I
TIDY_TAG_IFRAME
TIDY_TAG_ILAYER
TIDY_TAG_IMG
TIDY_TAG_INPUT
TIDY_TAG_INS
TIDY_TAG_ISINDEX
TIDY_TAG_KBD
TIDY_TAG_KEYGEN
TIDY_TAG_LABEL
TIDY_TAG_LAYER
TIDY_TAG_LEGEND
TIDY_TAG_LI
TIDY_TAG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DY_ATTR_START
TIDY_ATTR_STYLE
TIDY_ATTR_SUMMARY
TIDY_ATTR_TABINDEX
TIDY_ATTR_TARGET
TIDY_ATTR_TEXT
TIDY_ATTR_TITLE
TIDY_ATTR_TOPMARGIN
TIDY_ATTR_TYPE
TIDY_ATTR_USEMAP
TIDY_ATTR_VALIGN
TIDY_ATTR_VALUE
TIDY_ATTR_VALUETYPE
TIDY_ATTR_VERSION
TIDY_ATTR_VLINK
TIDY_ATTR_VSPACE
TIDY_ATTR_WIDTH
TIDY_ATTR_WRAP
TIDY_ATTR_XML_LANG
TIDY_ATTR_XML_SPACE
TIDY_ATTR_XMLNS

Таблица 4. tidy nodetype constants

constant description
TIDY_NODETYPE_ROOT root node
TIDY_NODETYPE_DOCTYPE doctype
TIDY_NODETYPE_COMMENT HTML comment
TIDY_NODETYPE_PROCINS Processing Instruction
TIDY_NODETYPE_TEXT Text
TIDY_NODETYPE_START start tag
TIDY_NODETYPE_END end tag
TIDY_NODETYPE_STARTEND empty tag
TIDY_NODETYPE_CDATA CDATA
TIDY_NODETYPE_SECTION XML section
TIDY_NODETYPE_ASP ASP code
TIDY_NODETYPE_JSTE JSTE code
TIDY_NODETYPE_PHP PHP code
TIDY_NODETYPE_XMLDECL XML declaration

This simple example shows basic Tidy usage.

Пример 2. Basic Tidy usage

();
?>
a html document
= ob_get_clean ();

Источник

What is Tidy?

Tidy is a console application for macOS, Linux, Windows, UNIX, and more. It corrects and cleans up HTML and XML documents by fixing markup errors and upgrading legacy code to modern standards.

libtidy is a C static and dynamic library that developers can integrate into their applications in order to bring all of Tidy’s power to your favorite tools. libtidy is used today in desktop applications, web servers, and more.

Documentation

For everything you need to know about running Tidy head over to our documentation page.

There you will discover how to build the tidy console application for your operating system (if necessary), how to use it, and discover examples of all of the great things that Tidy can do.

Are you a developer? Are you looking for libtidy information? Then feel free to get started with the developer documentation.

Both users and developers of Tidy will find useful Quick Reference and API Reference documentation at our API and Quick Reference site.

History

History

HTML Tidy was created by the W3C’s own Dave Raggett back in the dawn of the Internet age. His original Internet page is still available and gives a sense of the early history: Clean up your Web pages with HTML TIDY.

Satisfied with his work, Dave passed the torch to a dedicated group of maintainers at tidy.sourceforge.net where the important tasks of turning Tidy into a C library and keeping up with developing standards was performed.

W3C members took a renewed interest in Tidy in 2011 and forked the project to github (now redirects to new maintainers), where it featured compatibility with HTML5 via a key contribution from one of the SourceForge key members.

In 2015 a group of concerned developers, users, and software integrators formed HTACG with the goal of revitalizing Tidy, which had fallen into a non-maintained state. As a W3C Community Group, HTACG was deemed worthy by the W3C, and W3C passed ownership of their project to HTACG, where it is currently being developed and prepped for a new, stable, and modern release.

HTACG is also working diligently with the SourceForge maintainers in an effort to harmonize HTML Tidy into a single, stable, solid release once again.

Acknowledgements

HTACG and the rest of the HTML Tidy team want to extend a sincere and heartfelt “thank you” to everyone who made Tidy possible.

Are we missing someone? Issue a pull request against the gh-pages branch of this repository. You will want to edit this file.

Dave Raggett also maintains a long list of acknowledgements at his page.

Get Tidy

Get Tidy

You may already have Tidy on your computer! Many operating systems ship with the tidy command pre-installed. Chances are good, though, that what you have is so outdated that it doesn’t even recognize HTML5.

Grab a binary

HTACG makes available binaries for several platforms available right here. If there isn’t one for your particular operating system then let us know. In the meantime there are a few more options.

Build from source

Building Tidy from source is easier than ever thanks to the efforts of our developers in adopting CMake. Tidy’s source code is available on its github repository.

Install from a package manager

macOS

Windows

Linux

Software using HTML Tidy

mod_tidy is a libtidy based DSO module for Apache 2.0 that parses, cleans up, and pretty-prints the web server (X)HTML output. Read more…

node-libtidy provides server-side JavaScript bindings for libtidy. It aims to provide not only a high-level interface to a complete tidy run, but also offers methods which closely model the libtidy interface.

Notepad++ is a powerful editor, and several people offer a plugin that uses libtidy to do cleaning, indenting, etc. Some version incompatibilites have been noted.

Balthisar Tidy is a free, full fledged text editor for macOS that encourages you to tidy your documents live, during editing.

There are also applications that use the tidy console executable externally to add html cleaning.

Note that items appearing here aren’t endorsements by HTACG or the HTML Tidy Project team, but we do exercise some editorial discretion about what appears here.

How can I report bugs or make feature requests?

If you have a github account (easy and free) we encourage you to make bug reports and feature requests in our issues tracker.

How can I contribute to Tidy’s development?

We welcome code, website, and documentation contributions, and you are invited to join our open community. You can make pull requests for changes you make in our github repo.

Website © 2015-2021 by HTACG — The HTACG and HTML Tidy logos incorporate the HTML5 logo by W3C

Источник

Clean up your Web pages
with HTML TIDY

Introduction to TIDY

When editing HTML it’s easy to make mistakes. Wouldn’t it be nice if there was a simple way to fix these mistakes automatically and tidy up sloppy editing into nicely layed out markup? Well now there is! Dave Raggett’s HTML TIDY is a free utility for doing just that. It also works great on the atrociously hard to read markup generated by specialized HTML editors and conversion tools, and can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities.

Tidy is able to fix up a wide range of problems and to bring to your attention things that you need to work on yourself. Each item found is listed with the line number and column so that you can see where the problem lies in your markup. Tidy won’t generate a cleaned up version when there are problems that it can’t be sure of how to handle. These are logged as «errors» rather than «warnings».

Dave Raggett has now passed the baton for maintaining Tidy to a group of volunteers working together as part of the open source community at Source Forge. The source code continues to be available under an open source license, and you are encouraged to pass on bug reports and enhancement requests at http://tidy.sourceforge.net.

More recently, Tidy has been extended to support HTML5 and to clean up HTML exported from Google Docs. The source code is available on github, see tidy-html5.

If you find HTML Tidy useful and you would like to say thanks, then please send me a (paper) postcard or other souvenir from the area in which you live along with a few words on what you are using Tidy for. It will be fun to map out where Tidy users are to be found! My postal address is given at the end of this file.

Tidy can now perform wonders on HTML saved from Microsoft Word 2000! Word bulks out HTML files with stuff for round-tripping presentation between HTML and Word. If you are more concerned about using HTML on the Web, check out Tidy’s «Word-2000» config option! Of course Tidy does a good job on Word’97 files as well!

«One thing I love about the UNIX philosophy is the idea that each program should do one job and do it really well. There are zillions of small tools for UNIX-type OSes that make life much easier and are hugely useful, but they don’t necessarily get written about. They certainly don’t receive the same kind of coverage that Apache and Sendmail receive. One of my favorites, HTML Tidy, is a tool for HTML/Web development that I think will interest a lot of folks. HTML Tidy cleans up HTML produced by WYSIWYG editors and such.»

Tidy is available as a downloadable binary, as source code (ANSI C), or as an online service at W3C, Info Network, HTML Help’s site Valet and other sites.

Tutorials for HTML and CSS

If you are just starting off and would like to know more about how to author Web pages, you may find my guide to HTML and CSS helpful. Please send me feedback on this, and I will do my best to further improve it.

A new relative to Tidy, HTML Slidy is my open source presentation tool for slides written in XHTML. It provides an accessible alternative to traditional presentation tools like Microsoft PowerPoint. Best of all, there is no software to install, it just works from the Web!

Examples of TIDY at work

Tidy corrects the markup in a way that matches where possible the observed rendering in popular browsers from Netscape and Microsoft. Here are just a few examples of how TIDY perfects your HTML for you:

In Netscape and Internet Explorer this causes everything following the heading to be in the heading font size, not the desired effect at all!

Tidy maps the example to

Tidy inserts quote marks around all attribute values for you. It can also detect when you have forgotten the closing quote mark, although this is something you will have to fix yourself.

Tidy has a comprehensive knowledge of the attributes defined in the HTML 4.0 recommendation from W3C. This often allows you to spot where you have mistyped an attribute or value.

Tidy will even work out which version of HTML you are using and insert the appropriate DOCTYPE element, as per the W3C recommendations.

This is something you then have to fix yourself as Tidy is unsure of where the > should be inserted.

Layout style

You can choose which style you want Tidy to use when it generates the cleaned up markup: for instance whether you like elements to indent their contents or not. Several people have asked if Tidy could preserve the original layout. I am sorry to say that this would be very hard to support due to the way Tidy is implemented. Tidy starts by building a clean parse tree from the source file. The parse tree doesn’t contain any information about the original layout. Tidy then pretty prints the parse tree using the current layout options. Trying to preserve the original layout would interact badly with the repair operations needed to build a clean parse tree and considerably complicate the code.

Some browsers can screw up the right alignment of text depending on how you layout headings. As an example, consider:

Both of these should be rendered the same. Sadly a common browser bug fails to trim trailing whitespace and misaligns the first heading. HTML Tidy will protect you from this bug, except when you set the indent option to «yes».

Setting the indent option to yes can also cause problems with table layout for some browsers:

will look slightly different from:

You can avoid such quirks by using indent: no or indent: auto in the config file.

Internationalization issues

Tidy offers you a choice of character encodings: US ASCII, ISO Latin-1, UTF-8 and the ISO 2022 family of 7 bit encodings. The full set of HTML 4.0 entities are defined. Cleaned up output uses HTML entity names for characters when appropriate. Otherwise characters outside the normal range are output as numeric character entities. Tidy defaults to assuming you want the output to be in US ASCII. Tidy doesn’t yet recognize the use of the HTML meta element for specifying the character encoding.

Accessibility

Tidy offers advice on accessibility problems for people using non-graphical browsers. The most common thing you will see is the suggestion you add a summary attribute to table elements. The idea is to provide a summary of the table’s role and structure suitable for use with aural browsers.

Cleaning up presentational markup

Many tools generate HTML with an excess of FONT, NOBR and CENTER tags. Tidy’s -clean option will replace them by style properties and rules using CSS. This makes the markup easier to read and maintain as well as reducing the file size! Tidy is expected to get smarter at this in the future.

Some pages rely on the presentation effects of isolated

tags.Tidy deletes empty paragraph and heading elements etc. The use of empty paragraph elements is not recommended for adding vertical whitespace. Instead use style sheets, or the
element. Tidy won’t discard paragraphs only containing a nonbreaking space

Teaching Tidy about new tags!

You can teach Tidy about new tags by declaring them in the configuration file, the syntax is:

The same tag can be defined as empty and as inline or as empty and as block.

These declarations can be combined to define an a new empty inline or empty block element, but you are not advised to declare tags as being both inline and block!

Note that the new tags can only appear where Tidy expects inline or block-level tags respectively. This means you can’t (yet) place new tags within the document head or other contexts with restricted content models. So far the most popular use of this feature is to allow Tidy to be applied to Cold Fusion files.

Limited support for ASP, JSTE and PHP

Tidy will cope with ASP, JSTE and PHP pseudo elements within element content and as replacements for attributes, for example:

Note that Tidy doesn’t understand the scripting language used within pseudo elements and attributes, and can easily get confused. Tidy may report missing attributes when these are hidden within preprocessor code. Tidy can also get things wrong if the code includes quote marks, e.g. if the example above is changed to:

Tidy will now see the quote mark preceding ID as ending the attribute value, and proceed to complain about what follows. Note you can choose whether to allow line wrapping on spaces within pseudo elements or not using the wrap-asp option. If you used ASP, JSTE or PHP to create a start tag, but placed the end tag explicitly in the markup, Tidy won’t be able to match them up, and will delete the end tag for you. So in this case you are advise to make the start tag explicit and to use ASP, JSTE or PHP for just the attributes, e.g.

Tidy allows you to control whether line wrapping is enabled for ASP, JSTE and PHP instructions, see the wrap-asp, wrap-jste and wrap-php config options, respectively.

I regret that Tidy does not support Tango preprocessing instructions which look like:

Tidy supports another preprocessing syntax called «Tango», but only for attribute values. Adding support for pseudo elements written in Tango looks as if it would be quite tough, so I would like to gauge the level of interest before committing to this work.

Limited support for XML

XML processors compliant with W3C’s XML 1.0 recommendation are very picky about which files they will accept. Tidy can help you to fix errors that cause your XML files to be rejected. Tidy doesn’t yet recognize all XML features though, e.g. it doesn’t understand CDATA sections or DTD subsets.

Indenting text for a better layout

Indenting the content of elements makes the markup easier to read. Tidy can do this for all elements or just for those where it’s needed. The auto-indent mode has been used below to avoid indenting the content of title, p and li elements:

Источник

Читайте также:  Что такое нравственная чистота
Информ портал о технике и не только