-
Notifications
You must be signed in to change notification settings - Fork 434
Description
Hi guys,
I'm having a problem with tidy in that it keeps showing me the warning inserting missing 'title' element on php-only files. There is no way for me to ignore this warning and it's bugging the living hell out of me. I'm using tidy along with two plugins for Sublime Text 3 and getting this warning both using tidy directly from the command line as well as in the console output of Sublime.
This is my environment.
Hardware
MacBook Pro (13-inch mid-2012)
macOS High Sierra - 10.13.3
2.5 GHz Intel Core i5
10 GB 1600 MHz DDR3
Intel HD Graphics 4000 1536 MB
Software
Package Manager Homebrew 1.6.2
Package Source Homebrew/homebrew-core (git revision c010d8; last commit 2018-04-28)
tidy Version HTML Tidy for Apple macOS version 5.6.0
Editor Sublime Version 3.0, Build 3143
Editor Plugin SublimeLinter 4.4.0
Editor Plugin SublimeLinter-html-tidy 2.0.0
I installed tidy directly via homebrew:
$ brew install tidy-html5
$ which tidy
/usr/local/bin/tidy
$ ls -lh /usr/local/bin/tidy
lrwxr-xr-x 1 macbookpro admin 35B 23 Apr 16:05 /usr/local/bin/tidy -> ../Cellar/tidy-html5/5.6.0/bin/tidy
$ ls -lh /usr/local/Cellar/tidy-html5/5.6.0/bin/tidy
-r-xr-xr-x 1 macbookpro admin 731K 25 Nov 15:54 /usr/local/Cellar/tidy-html5/5.6.0/bin/tidySettings
This is my configuration file for SublimeLinter in Sublime text editor:
// SublimeLinter Settings - User
{
"lint_mode": "save",
"no_column_highlights_line": true,
"paths": {
"osx":
[
"/usr/local/bin/"
]
},
"show_panel_on_save": "view",
"linters":
{
"htmltidy":
{
"@disable": false,
"args":
[
"--show-warnings",
"true"
],
"excludes": [],
"ignore_match": [
"missing <!DOCTYPE> declaration",
"inserting missing 'title' element"
],
},
"php":
{
"@disable": false,
"ignore_match": [
"missing <!DOCTYPE> declaration",
"inserting missing 'title' element"
],
},
"phpcs":
{
"@disable": false,
"excludes": [],
"ignore_match": [
"missing <!DOCTYPE> declaration",
"inserting missing 'title' element"
],
},
"json":
{
"@disable": false,
},
},
}I am using SublimeLinter-html-tidy as the plugin that ties tidy in to the Sublime user space so that I can lint html documents. In the above SublimeLinter settings I am using ignore_match to exclude the inserting missing 'title' element warning from appearing in the htmltidy, php and phpcs linter plugins.
SublimeLinter-html-tidy or rather tidy itself, is not respecting this setting and continues to output the warning. I don't need tidy to do this for me, I have phpcs installed to deal with linting of php files.
But, as this is a bug report about tidy and not Sublime or its plugins, the following is my
$ tidy -show-config Configuration File Settings output from the terminal:
Configuration File Settings:
Name Type Current Value
=========================== ========= ========================================
accessibility-check Enum 0 (Tidy Classic)
add-meta-charset Boolean no
add-xml-decl Boolean no
add-xml-space Boolean no
alt-text String
anchor-as-name Boolean yes
ascii-chars Boolean no
assume-xml-procins Boolean no
bare Boolean no
break-before-br Boolean no
char-encoding Encoding utf8
clean Boolean no
coerce-endtags Boolean yes
css-prefix String c
custom-tags Enum no
decorate-inferred-ul Boolean no
doctype String auto
drop-empty-elements Boolean yes
drop-empty-paras Boolean yes
drop-proprietary-attributes Boolean no
enclose-block-text Boolean no
enclose-text Boolean no
error-file String
escape-cdata Boolean no
escape-scripts Boolean yes
fix-backslash Boolean yes
fix-bad-comments Enum auto
fix-style-tags Boolean yes
fix-uri Boolean yes
force-output Boolean no
gdoc Boolean no
gnu-emacs Boolean no
hide-comments Boolean no
indent Enum no
indent-attributes Boolean no
indent-cdata Boolean no
indent-spaces Integer 2
indent-with-tabs Boolean no
input-encoding Encoding utf8
input-xml Boolean no
join-classes Boolean no
join-styles Boolean yes
keep-tabs Boolean no
keep-time Boolean no
literal-attributes Boolean no
logical-emphasis Boolean no
lower-literals Boolean yes
markup Boolean yes
merge-divs Enum auto
merge-emphasis Boolean yes
merge-spans Enum auto
mute String
mute-id Boolean no
ncr Boolean yes
new-blocklevel-tags Tag Names
new-empty-tags Tag Names
new-inline-tags Tag Names
new-pre-tags Tag Names
newline Enum LF
numeric-entities Boolean no
omit-optional-tags Boolean no
output-bom Enum auto
output-encoding Encoding utf8
output-file String
output-html Boolean no
output-xhtml Boolean no
output-xml Boolean no
preserve-entities Boolean no
priority-attributes Attribute
punctuation-wrap Boolean no
quiet Boolean no
quote-ampersand Boolean yes
quote-marks Boolean no
quote-nbsp Boolean yes
repeated-attributes Enum keep-last
replace-color Boolean no
show-body-only Enum no
show-errors Integer 6
show-info Boolean yes
show-meta-change Boolean no
show-warnings Boolean yes
skip-nested Boolean yes
sort-attributes Enum none
strict-tags-attributes Boolean no
tab-size Integer 8
tidy-mark Boolean yes
uppercase-attributes Enum no
uppercase-tags Boolean no
vertical-space Enum no
warn-proprietary-attributes Boolean yes
word-2000 Boolean no
wrap Integer 68
wrap-asp Boolean yes
wrap-attributes Boolean no
wrap-jste Boolean yes
wrap-php Boolean yes
wrap-script-literals Boolean no
wrap-sections Boolean yes
write-back Boolean no
PHP Sample
For your reference, here is my full php file so that you can see there is no hint of html in it. I am including the full file (instead of a sample) because when you see the outputs later on in this ticket you will notice the references to html5 and the missing title element but I'm very confused how the file below can create this perception that the content is html5 content.
<?php
/**
* Adminer Custom (https://github.com/pematon/adminer-custom)
* Copyright (c) 2014-2018 Pematon, s.r.o. (http://www.pematon.com/)
*
* Licensed under The MIT License For full copyright and license information,
* please see the LICENSE. Redistributions of files must retain the above
* copyright notice.
*
* @category Index
* @package AdminerCustom
* @author Peter Knut <peter@pematon.com>
* @author Justin Hartman <justin@hartman.me>
* @copyright 2014-2018 Pematon, s.r.o. (http://www.pematon.com/)
* @license https://opensource.org/licenses/MIT MIT License
* @version 1.3.0
* @link https://github.com/pematon/adminer-custom
*/
/**
* Adminer Custom (https://github.com/pematon/adminer-custom)
*
* @category Index
* @package AdminerCustom
* @author Peter Knut <peter@pematon.com>
* @author Justin Hartman <justin@hartman.me>
* @copyright 2014-2018 Pematon, s.r.o. (http://www.pematon.com/)
* @license https://opensource.org/licenses/MIT MIT License
* @version 1.3.0
* @link https://github.com/pematon/adminer-custom
*/
/**
* Adminer Object Method
*
* This function configures the Adminer app by loading and configuring
* the site's plugins.
*
* @return array AdminerPlugin() returns an array of objects which
* contains the plugins and settings from the loaded
* plugin configuration files.
*/
function adminObject()
{
// Required to run any plugin.
include_once __DIR__ . '/plugins/plugin.php';
// Plugins auto-loader.
foreach (glob("plugins/*.php") as $filename) {
include_once __DIR__ . '/'.$filename;
}
// Specify enabled plugins here.
$plugins = [
new AdminerDatabaseHide(["mysql", "information_schema", "performance_schema"]),
new AdminerLoginServers(
[
filter_input(INPUT_SERVER, 'HTTP_HOST') => filter_input(INPUT_SERVER, 'SERVER_NAME')
]
),
new AdminerSimpleMenu(),
new AdminerCollations(),
new AdminerJsonPreview(),
// AdminerTheme has to be the last one.
new AdminerTheme(),
];
return new AdminerPlugin($plugins);
/**
* Whether to use Adminer or the Editor file.
*
* @var boolean editorSwitch() true or false.
*/
$editor = false;
return editorSwitch($editor);
}//end admin_object()
/**
* Include original Adminer or Adminer Editor.
*
* You can use one of the two files below depending on your use case. Simply set
* editor variable to true to use Adminer Editor instead of the original Adminer.
*
* NB: It is important to note the Adminer Editor does not inherit the styles
* that Adminer does. This is because plugins do not work for Adminer Editor so
* you are using the default Adminer Editor with no additional styles or
* functionality other than what is provided by the original Editor file.
*
* @author Justin Hartman <justin@hartman.me>
* @since 1.3.0
* @param boolean $editor If defined as `true` the function will use the Adminer
* Editor script instead of the Adminer script (default).
*
* @return include Includes one of two files in `adminer.php` or `editor.php`.
*/
function editorSwitch($editor)
{
if ($editor === false) {
$editorFile = '/adminer.php';//Adminer
} elseif ($editor === true) {
$editorFile = '/editor.php';//Adminer Editor
}
include __DIR__ . $editorFile;
}//end editorSwitch()Errors when running tidy
I created the abovephp only file with zero html in it so there is no possible way I can add a title element. There is clearly a bug here in that it cannot determine that nor can it ignore the overide setting.
SublimeLinter output
Here is the warning I am receiving when linting my php file:
Terminal output running tidy directly
This is what happens when I run $ tidy original-index.php -o index.md against my original-index.php file:
line 106 column 1 - Warning: inserting missing 'title' element
Info: Document content looks like HTML5
Tidy found 1 warning and 0 errors!
<!DOCTYPE html>
<html>
<head>
<meta name="generator" content=
"HTML Tidy for HTML5 for Apple macOS version 5.6.0">
<title></title>
</head>
<body>
</body>
</html>
What confuses me a lot is that tidy is giving me an information notice that Document content looks like HTML5 and this makes me wonder how this is related to the inserting missing 'title' element that tidy keeps warning me about. There should be no reason for it to pick up the doc content as html5. Nothing, and I mean nothing, even remotely looks like html5 in the PHP file.
Setting --show-warnings flag to false
If I try and change the --show-warnings flag to false in both tidy command line and in the SublimeLinter settings file I still get the warning output. It doesn't respect the --show-warnings flag either.
$ tidy original-index.php -o index.md --show-warnings false
line 106 column 1 - Warning: inserting missing 'title' element
Info: Document content looks like HTML5
Tidy found 1 warning and 0 errors!
<!DOCTYPE html>
<html>
<head>
<meta name="generator" content=
"HTML Tidy for HTML5 for Apple macOS version 5.6.0">
<title></title>
</head>
<body>
</body>
</html>"html-tidy":
{
"@disable": false,
"args":
[
"--show-warnings",
"false"
],
"excludes": [],
"ignore_match": [
"missing <!DOCTYPE> declaration",
"inserting missing 'title' element"
],
},So, is this a bug that needs fixing or is this me missing something completely?
