Commit graph

461 commits

Author SHA1 Message Date
Geoff McLane ec03beb361 Issue #552 - remove no 'case default:' warning in most gcc versions
Seems too small for a version bump. Closes #552
2017-05-19 18:38:01 +02:00
Geoff McLane 21f008501a Issue #456 - Oops, also out of 'lexer.h' 2017-05-15 16:51:34 +02:00
Geoff McLane a7a4cd6a16 Issue #456 - avoid head work if showing body only 2017-05-15 16:42:49 +02:00
Geoff McLane f310f1d5de Issue #456 - Move new TidyMetaCharset to clean 2017-05-15 16:39:53 +02:00
Geoff McLane 6ebd12be67 Issue #456 - More work on this option 2017-05-14 19:08:29 +02:00
Jim Derry 9b2cd06711 Merge branch 'next' into issue-365 2017-05-13 22:27:14 -04:00
Jim Derry 66d0825e58 Merge pull request #557 from htacg/update_langs
Update languages against current English.
2017-05-13 22:24:43 -04:00
Jim Derry 5791c55081 Update languages against current English. 2017-05-13 21:07:02 -04:00
Jim Derry 0f1e625324 Address #378
Addresses issue #378 by NOT emitting warnings if `fix-uri` is `no`, for HTML5
documents. This preserves existing behavior for legacy document types.
2017-05-13 20:46:48 -04:00
Jim Derry d18b21b94c Merge branch 'next' into issue-365 2017-05-13 19:55:19 -04:00
Jim Derry b6bf48c24a Merge pull request #553 from htacg/new_picklists
New picklists and parsers
2017-05-13 19:50:20 -04:00
Jim Derry a399725a1e Fixed ParseAutoBool error. 2017-05-13 11:39:13 -04:00
Geoff McLane 8843199370 Issue #456 - Merge branch 'meta-charset' of tidy-html5-marco.
This pulls the work done by @marcoscaceres WIP #458 into the issue-456
branch, to complete the new add-meta-charset option.
2017-05-13 16:02:26 +02:00
Jim Derry 982504eee0 Case insensitive compare is safe here, and prevents erroneous propriertary attribute errors. 2017-05-12 08:28:11 -04:00
Jim Derry e7c28636b9 Fixed cause of assertions -- funny, these don't pop up in XCode. 2017-05-12 07:30:20 -04:00
Jim Derry 29766afcfd Initial take on issue 365. This is based off of the simplification of the
parser and picklist system. Console application needs to be updated to fix
the description, as it shows autobool, and for some reason on the current
system I'm not getting assertion failures.
2017-05-11 18:12:56 -04:00
Jim Derry 7112fba553 Merge pull request #549 from htacg/issue_391
Address #391. Tested on macOS and Win10.
2017-05-11 15:24:44 -04:00
Jim Derry aeb9a24fab Refactor Picklists and Option Parsers
This PR refactors how picklists and option parsers are implemented in LibTidy,
making is vastly easier to implement new picklists in the future, as well as
modify some of the existing picklists such that they have more logical names.

Picklist arrays are now arrays of structures that include the possible strings
capable of setting a particular option value, and a new parser has been written
to work with these structures.

In addition, several of the existing parsers were removed, as they are now
redundant, and a couple of the remaining parsers were refactored to take
advantage of the new parser.

In effect, this means that:

- New parsers don't have to be written in the majority of cases where new
  options are added that exceed yes/no/auto.
- Some of the existing options can have more meaningful names than yes/no/auto,
  in a backward compatible way. For example, vertical-spacing "auto" currently
  in no way reflects "auto" when used.
2017-05-11 14:40:21 -04:00
Geoff McLane f7e7554c95 Close the file before the _WIN32 switch 2017-05-09 19:24:20 +02:00
Jim Derry acaab679c5 Merge pull request #547 from htacg/issue_352
Attempt to address issue #352.
2017-05-08 17:36:52 -04:00
Geoff McLane 77420b94d0 Fix for 'isalnum' in Windows
According to the MSN documentation 'isalnum(c)' is only valid when c equals
EOF, or is in the range 0 to 255 inclusive. It states the behavior is
undefined outside this range, and in Debug mode triggers an assert dialog.
2017-05-08 18:42:33 +02:00
Jim Derry ce105dcf09 Address #391. Tested on macOS and Win10.
- Add a check upon opening a file for validity of the file.
- Add a new message to indicate that the path is not a file.
2017-05-07 17:04:53 -04:00
Jim Derry fd77312175 Attempt to address issue #352. This patch correctly address the specific issues
in #352, but I'm worried that there's some over-reach here.

Currently only implemented as a warning, with no switch to turn it off, which
maintains current behavior other than the warning.

In general, we're treating any string as a complete URL, rather than breaking
URL's into component parts. Thus the `IsURLCodePoint()` check includes a few
other generic characters that strictly speaking aren't valid codepoints, but
are valid as escape characters and delimiters.

When addressing #338, I ran into a similar situation in not having a built-in
method to separate path components (although a simple generalized solution was
good enough in that case).

Thus without introducing a new structure and functions to deconstruct a URL
into scheme, authority, path, parameters, etc., some variation of this patch
will have to be used to address #352.
2017-05-06 18:54:42 -04:00
Jim Derry 09d1802298 Merge branch 'next' into deprecations 2017-05-06 14:34:48 -04:00
Geoff McLane fd2400d55b Merge pull request #543 from htacg/issue-436
Small documentation change to close #436
2017-05-06 15:44:45 +02:00
Geoff McLane d4978608e7 Merge pull request #537 from deathbaba/next
Correctly process 'bookmarks' in html exported from Google Doc.
2017-05-06 15:35:57 +02:00
Geoff McLane 6839dfe601 Merge pull request #541 from htacg/issue_338
Issue #338 - fix 3 spurious access level 3 warnings...
2017-05-06 15:20:55 +02:00
Geoff McLane 6da0fff256 Merge pull request #532 from lhchavez/add-warn-prop-attrs
Add a flag to warn on proprietary attributes
2017-05-06 14:48:36 +02:00
Jim Derry 846b3cde55 Address #436 just to close it. 2017-05-04 13:45:06 -04:00
Geoff McLane d142527a8e Issue #338 - Deal with two other spurious access warnings 2017-05-04 17:36:39 +02:00
Jim Derry 49b833f63b WIP 2017-05-03 18:16:03 -04:00
Jim Derry 8b2f92f625 Issue #338 occurs because the existing routines assume that any URI with an
extension is a file, and so links to TLD's ending with .pl, .au, etc., will
cause accessibility warnings. This fix attempts to distinguish between URI's
that are likely to be files versus links to domains.
2017-05-03 16:15:44 -04:00
Geoff McLane b03598652f Issue #461 - alternative patch for this issue 2017-05-02 19:39:16 +02:00
Alexander Zolotarev 87169d8953 Correctly process 'bookmarks' in html exported from Google Doc. 2017-04-19 14:47:27 -10:00
lhchavez a19d271f47 Add a flag to warn on proprietary attributes
This change adds the TidyWarnPropAttrs flag (default=on) that emits a
warning every proprietary attribute it finds.
2017-04-15 03:17:16 +00:00
Geoff McLane d8839485a4 Merge branch 'next' of github.com:htacg/tidy-html5 into next 2017-04-09 02:09:19 +02:00
Geoff McLane 219a5c797b Issue #524 - Remove obsolete message 2017-04-09 02:08:03 +02:00
Jim Derry d1e0b22be7 Removed TidyDropFontTags. Note that POs and POT were _not_ updated. 2017-04-04 14:42:47 -04:00
Jim Derry 24afc6a6fa Fixed some casting issues that Ubuntu object to.
- Test on macOS, Win10, Ubuntu.
- No version bump for this change.
2017-04-04 14:33:56 -04:00
Geoff McLane 22dcea067e Issue #335, maybe #333, to output indent char, reduce if tab 2017-03-26 16:57:29 +02:00
Geoff McLane 5f88452487 Issue #333 - create exception for span/meta 2017-03-26 16:57:29 +02:00
Jim Derry 5f05add439 Continue the documentation effort!
- Many, many updates to the public header files.
- tidyenum.h was reorganized substantially in order to better generate
  documentation with Doxygen.
- This was also a good time to clean up all of the various enums for languages
  and strings. Everything is simple and in a single enum now, other than a
  couple of cases (TidyOptionId, for example, doesn't need to be redefined).
- A full and complete audit of the strings meant some opportunities to delete
  useless strings.
- Reorganized the order of the strings in language_en.h in order to better
  find things when programmers want to make changes. There are a lot fewer
  internal "sections" now, and everything has been painstakingly sorted within
  the remaining sections.
- Consequently rebased all of the PO's, POT, and other language files.
- Updated several of the READMEs with the newest information.
- Made the READMEs easier to copy into the Doxygen project by changing some of
  the code format for compatibility, mainly the use of tildes instead of
  backslashes for code blocks.
- Added tidyGetMessageCode() to message API. Despite the huge diff, this is the
  only externally-visible change, other than removing some enums (but not their
  values!).
- Passing `next` tests on Mac, Linux, Win10.
2017-03-22 16:05:13 -04:00
Jim Derry 929575afb4 Picklist enums should all start at zero for external LibTidy user compatibility.
Restore the new custom-tags enum to this state, and add separate string keys.
Updated PO's to reflect; no change to headers.
2017-03-20 12:20:51 -04:00
Jim Derry a4f752f274 Implement TODO:
- tidyDetectedHtmlVersion()
- tidyDetectedXhtml()
- added two new fields to W3C_Doctypes[] in order to simplify this.
- added TY_(HTMLVersionNumberFromCode)() to enable lookup.
- Implement tidyDetectedGenericXml()
- Added a warning message if an XML declaration exists but the document is not
  XHTML.
- Remove dead commented code.
- Updated POs and POT. Headers not affected, but translators should check
  their translations.
- Testing is clean on Mac OS X, Ubuntu 16.04, and Windows 10.
2017-03-19 15:41:51 -04:00
Jim Derry 13122e8862 Added tidyErrorCodeFromKey()
Added tidyGetMessageDoc()
Improved the Public API documentation.
2017-03-19 08:15:32 -04:00
Geoff McLane c8f366b76e Issue #119 - Remove 3 newline chars, that crept in... 2017-03-18 18:52:48 +01:00
Jim Derry da55a6e4ac Removed unused declaration. 2017-03-16 08:00:05 -04:00
Jim Derry 0c5550b06f I think the messages are where I want them to be. Will generate test cases
for comparison. Also regen'd all pots and language headers.
2017-03-15 17:36:05 -04:00
Jim Derry 5606f32f13 WIP; messaging much more logical, except @todo noted. 2017-03-14 21:50:10 -04:00
Jim Derry 66ade9def4 Still noisy, but adds HTML5 dependent output message upon detection. 2017-03-14 16:27:11 -04:00
Jim Derry ed5a1d84ea Add TY_(nodeIsAutonomousCustomTag), so we can use it elsewhere. 2017-03-14 15:44:46 -04:00
Jim Derry 8273491e16 Change allowed values for custom-tags, and make y equal to inline. 2017-03-14 15:16:11 -04:00
Jim Derry 66de84bc2b - Add support for the is attribute.
- Add support for autonomous custom elements.
2017-03-13 13:45:32 -04:00
Jim Derry 11178d775b Massive Revamp of the Messaging System
This is a rather large refactoring of Tidy's messaging system. This was done
mostly to allow non-C libraries that cannot adequately take advantage of
arg_lists a chance to query report filter information for information related
to arguments used in constructing an error message.

Three main goals were in mind for this project:

- Don't change the contents of Tidy's existing output sinks. This will ensure
  that changes do no affect console Tidy users, or LibTidy users who use the
  output sinks directly. This was accomplished 100% other than some improved
  cosmetics in the output. See tidy-html5-tests repository, the `refactor` and
  `more_messages_changes` branches for these minor diffs.
- Provide an API that is simple and also extensible without having to write new
  error filters all the time. This was accomplished by adding the new message
  callback `TidyMessageCallback` that provides callback functions an opaque
  object representing the message, and an API to query the message for wanted
  details. With this, we should never have to add a new callback routine again,
  as additional API can simply be written against the opaque object.
- The API should work the same as the rest of LibTidy's API in that it's
  consistent and only uses simple types with wide interoperability with other
  languages. Thanks to @gagern who suggested the model for the API in #409.
  Although the API uses the "Tidy" way off accessing data via an iterator
  rather than an index, this can be easily abstracted in the target language.

There are two *major* API breaking changes:

- Removed TidyReportFilter2
  - This was only used by one application in the entire world, and was a hacky
    kludge that served its purpose. TidyReportCallback (né TidyReportFilter3)
    is much better. If, for some reason, this affects you, I recommend using
    TidyReportCallback instead. It's a minor change for your application.
- Renamed TidyReportFilter3 to TidyReportCallback
  - This name is much more semantic, and much more sensible in light of
    improved callback system. As the name implies, it remains capable of
    *only* receiving callbacks for Tidy "reports."

Introducing TidyMessageCallback, and a new message interrogation API.

- As its name implies, it is able to capture (and optionally suppress) *all*
  of Tidy's output, including the dialogue messages that never make it to
  the existing report filters.
- Provides an opaque `TidyMessage` and an API that can be used to query against
  it to find the juicy goodness inside.
  - For example, `tidyGetMessageOutput( tmessage )` will return the complete,
    localized message.
  - Another example, `tidyGetMessageLine( tmessage )` will return the line the
    message applies to.
- You can also get information about the individual arguments that make up a
  message. By using the `tidyGetMessageArguments( tmessage )` itorator and
  `tidyGetNextMessageArgument` you will obtain an opaque `TidyMessageArgument`
  which has its own interrogation API. For example:
    - tidyGetArgType( tmessage, &iterator );
    - tidyGetArgFormat( tmessage, &iterator );
    - tidyGetArgValueString( tmessage, &iterator );
    - …and so on.

Other major changes include refactoring `messages.c` to use the new message
"object" directly when emitting messages to the console or output sinks. This
allowed replacement of a lot of specialized functions with generalized ones.

Some of this generalizing involved modifications to the `language_xx.h` header
files, and these are all positive improvements even without the above changes.
2017-03-13 13:28:57 -04:00
Jim Derry 4dc8a2cf9a Bump version to 5.5.5 for this fiasco, and fix poor planning and unfortunate
merge.
  - Sort all of the existing options and re-indent per Tidy standards. This is
    simply for cosmetic effect.
  - Allow the iterator to return all options again, even "internal" options.
    Things are too embedded with N_TIDY_OPTIONS, etc., to try to hide them.
  - Instead, simply add documentation to LibTidy users that they shouldn't use
    internal options.
  - Also added `TidyInternalCategory` to `TidyConfigCategory` without adding a
    new field to the struct. API users should check for this category before
    use.
  - Defined a two character macro for `TidyInternalCategory` for use in
    `option_defs[]`.
  - Changed struct `option_defs[]` to reflect the new category for affected
    options.
  - Removed string indicating * refers to internal options, since it no longer
    applies.
  - Regen'd all strings for previous point.
  - `tidy.c` now checks for `TidyInternalCategory` everywhere in order to
    suppress output.
2017-03-10 09:13:21 -05:00
Jim Derry ac242e9ea4 hotfix 2017-03-09 19:56:16 -05:00
Jim Derry e27cc262fe Bring the local vars into the context, which is allowed in C89. 2017-03-09 12:44:48 -05:00
Jim Derry 005127c733 Address issue #472. 2017-03-08 15:37:01 -05:00
Jim Derry 978756a482 Restore the previous status of gnu-emacs-file
- Updated strings files to match.
- Inhibit internal options from being output via the iterator. Internals should
  never have the chance to be exposed if they shouldn't be use.
- Added tidySetEmacsFile() and TidyGetEmacsFile() to the public API, and use it
  instead of secret API to set the filename in the console application.

The end result is that `gnu-emacs-file` (and also `doctype-mode`) officially no
longer exist to CLI users nor to API users, and tidy console behaves properly
by using a published API to set the filename for emacs.
2017-03-07 20:11:31 -05:00
Jim Derry 03f0192f51 How did this get back in there??? 2017-03-04 15:31:25 -05:00
Jim Derry 74a4fa4049 Merge branch 'next' into clean_deprecations 2017-03-02 11:40:14 -05:00
Jim Derry 3be515b1f9 Merge branch 'next' into messages_squashed 2017-03-02 09:34:58 -05:00
Jim Derry 92621d6f99 MSVC Compatibility
- Changed location of pointer operator in declarations.
  - Updated `CODESTYLE.md` to reflect this.
  - Updated `API_AND_NAMESPACE.md` to reflect this.
2017-03-02 09:32:02 -05:00
Geoff McLane a49890ee55 Issue #498 - parser.c - if a <table> in a <table> just close.
The previous action was to discard the second, while it is the second
table that browsers will render.

This conforms to the principle that the html output by tidy should render
in a browser like the original html.
2017-02-24 16:20:10 +01:00
Geoff McLane c4b5904e1c Issue #497 - lexer.c - Add comment for this PR @seaburg 2017-02-24 14:38:20 +01:00
Geoff McLane e44f4d1469 Merge pull request #497 from seaburg/fix_value_trimming
Fix leading white spaces trimming
2017-02-24 14:30:39 +01:00
Geoff McLane 27fe0548b9 Issue #468 - config.c - use RAW encoding for all cases 2017-02-23 16:28:19 +01:00
Geoff McLane 569ae4b435 Issue #329 - lexer.c - do not discard this newline here 2017-02-23 15:27:03 +01:00
Evgeniy Yurtaev bb1d62d3bd Fix leading white spaces trimming 2017-02-22 14:34:40 +03:00
Jim Derry c54c10f857 - Removed deprecated options:
- TidySlideStyle
  - TidyBurstSlides

- Added documentation for TidyEmacsFile, since it's a valid option.

- Because TidyEmacsFile is a valid option, tweaked tidy.c so that it can
  be specified in a configuration file without being overwritten by the console
  app. Why a user might do this is dumb, but who are we to stop them.
2017-02-18 18:30:41 -05:00
Jim Derry edc548095c Removed language as tidy config option; it is only CLI option. 2017-02-18 17:16:35 -05:00
Jim Derry cbb8354f74 Combined leftover attribute API stuff into single, new file. 2017-02-18 16:57:11 -05:00
Jim Derry f6ce4d130e Removed deprecated tidyAttrGetSOMETHING from API. 2017-02-18 16:46:20 -05:00
Jim Derry 13c6387f47 Removed deprecated AttributeIsSOMETHING from API. 2017-02-18 16:43:47 -05:00
Jim Derry a16f36ce53 Removed deprecated NodeIsElementName from API. 2017-02-18 16:33:21 -05:00
Jim Derry 165acc4f3e Several foundational changes preparing for release of 5.4 and future 5.5:
- Consolidated all output string definitions enums into `tidyenum.h`, which
    is where they belong, and where they have proper visibility.
  - Re-arranged `messages.c/h` with several comments useful to developers.
  - Properly added the key lookup functions and the language localization
    functions into tidy.h/tidylib.c with proper name-spacing.
  - Previous point restored a *lot* of sanity to the #include pollution that's
    been introduced in light of these.
  - Note that opaque types have been (properly) introduced. Look at the updated
    headers for `language.h`. In particular only an opaque structure is passed
    outside of LibTidy, and so use TidyLangWindowsName and TidyLangPosixName
    to poll these objects.
  - Console application updated as a result of this.
  - Removed dead code:
    - void TY_(UnknownOption)( TidyDocImpl* doc, char c );
    - void TY_(UnknownFile)( TidyDocImpl* doc, ctmbstr program, ctmbstr file );
  - Redundant strings were removed with the removal of this dead code.
  - Several enums were given fixed starting values. YOUR PROGRAMS SHOULD NEVER
    depend on enum values. `TidyReportLevel` is an example of such.
  - Some enums were removed as a result of this. `TidyReportLevel` now has
    matching strings, so the redundant `TidyReportLevelStrings` was removed.
  - All of the PO's and language header files were regenerated as a result of
    the string cleanup and header cleanup.
  - Made the interface to the library version and release date consistent.
  - CMakeLists.txt now supports SUPPORT_CONSOLE_APP. The intention is to
    be able to remove console-only code from LibTidy (for LibTidy users).
  - Updated README/MESSAGES.md, which is *vastly* more simple now.
2017-02-17 15:29:26 -05:00
Jim Derry e1f066fe14 Merge branch 'empretty_script' 2017-02-13 08:49:13 -05:00
Jim Derry b7c84b1b57 Merge branch 'surrogates' 2017-02-13 08:49:06 -05:00
Geoff McLane ea49ca0b1d Fix license for SPRTF modules.
Also correct the coding style to conform to HTML Tidy standard.
2017-02-12 17:38:44 +01:00
Geoff McLane 7f73d4f429 Issue #483 - Add ReportSurrogateError() service and connect. 2017-02-11 18:33:45 +01:00
Geoff McLane 75bc1f06c7 More updates for Issue #483 - Start warning msgs - WIP 2017-02-09 20:55:23 +01:00
Jim Derry 1ac50fccb3 Pretty up output of empty script tags.
- No longer break script tags up on two lines if there is content. However
    output is still subject to the `--wrap` behavior.
  - Previous behavior intact if there is content.

Todo.

  - Associate this with a new Tidy option.
2017-02-08 13:53:37 -05:00
Geoff McLane 9dc76c1e77 Issue #483 - Some fixes for error condition 2017-02-02 16:43:10 +01:00
Geoff McLane 259d330780 Issue #483 - First cut dealing with 'surrogate pairs'.
Only deals with a successful case.

TODO: Maybe add a warning/error if the trailing surrogate not found, and
maybe consider substituting to avoid invalid utf-8 output.
2017-02-01 13:50:33 +01:00
Geoff McLane deebc93f97 Merge pull request #480 from onnimonni/feature-fix-xmlns-xlink
Add optional xmlns:xlink attributes as valid to support inline svg
2017-01-29 19:17:43 +01:00
Onni Hakala da27b5e339
Add optional xmlns:xlink attributes as valid to support inline svg
fixes #478
2017-01-09 01:38:16 +02:00
Marcos Caceres 91da8c6f74 style: ansi conforming comments 2016-12-20 16:51:09 +11:00
Geoff McLane fd0ccb2bbf Bad, repeated node iteration! closes #459 2016-10-30 23:37:31 +01:00
Marcos Caceres aff76bec38 fix(lexer.c): fixes from initial review 2016-10-17 17:00:58 +11:00
Marcos Caceres 523d58b004 refactor: ask for charset and http_equiv attrs 2016-10-06 19:30:23 +11:00
Marcos Caceres 932cc104a6 feat(attrask.c): learn about charset attr 2016-10-06 19:29:56 +11:00
Marcos Caceres 53ee94ddba fix: incorrect check for first element in head 2016-10-06 19:07:44 +11:00
Marcos Caceres b1629c4a4f fix(lexer): bad attribute reporting 2016-10-05 20:22:19 +11:00
Marcos Caceres 2d7ddfef94 Part 2.1 - Bug fixes and warning 2016-10-05 20:14:18 +11:00
Marcos Caceres cfc22ac46e Add garvankeeley's suggestions using calloc 2016-10-05 18:54:25 +11:00
Marcos Caceres 040c22c6dc Part 2 - Implement lexer logic 2016-10-04 21:23:57 +11:00
Marcos Caceres 169bd38adf Part 1 - Add basic infra for 'add-meta-charset' option 2016-10-04 17:56:29 +11:00
Geoff McLane d81a9ad901 Merge branch 'issue-428'
Conflicts:
	version.txt

This closes #428
2016-09-11 16:57:07 +02:00
Marcos Caceres e4ae9c064d Add support for link 'as' attribute (closes #449) 2016-08-23 18:46:04 +10:00
Geoff McLane 80e57b23bf Merge branch 'master' into issue-428
Conflicts:
	version.txt
2016-08-09 00:46:40 +02:00