diff options
author | Boris Nagaev <bnagaev@gmail.com> | 2017-04-01 23:14:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-01 23:14:52 (GMT) |
commit | f4bcbe9237a99a8956759a4c22062d24c75812e8 (patch) | |
tree | ceed8c7f1dc3870b1432031c0ea0db61820e50b2 | |
parent | 671d517af3c0504a62dd37862b102c3ebeba5593 (diff) | |
parent | 0992da162aa265b92e3cdb7b0a82e1b316a2bede (diff) | |
download | mxe-f4bcbe9237a99a8956759a4c22062d24c75812e8.zip mxe-f4bcbe9237a99a8956759a4c22062d24c75812e8.tar.gz mxe-f4bcbe9237a99a8956759a4c22062d24c75812e8.tar.bz2 |
Merge pull request #1707 from sibuserv/add-tidy
add package tidy-html5
-rw-r--r-- | src/tidy-html5-test.c | 49 | ||||
-rw-r--r-- | src/tidy-html5.mk | 30 |
2 files changed, 79 insertions, 0 deletions
diff --git a/src/tidy-html5-test.c b/src/tidy-html5-test.c new file mode 100644 index 0000000..8f3df77 --- /dev/null +++ b/src/tidy-html5-test.c @@ -0,0 +1,49 @@ +// This file is part of MXE. See LICENSE.md for licensing information. + +#include <tidy.h> +#include <tidybuffio.h> + +#include <stdbool.h> +#include <stdio.h> + + +int main() +{ + const char *input = "<h1>Blah</h1><p><b>Blah-blah-blah!</b>"; + printf("Input (HTML fragment):\n%s\n\n", input); + fflush(stdout); + + TidyDoc tDoc = tidyCreate(); + TidyBuffer output = {0}; + TidyBuffer errBuf = {0}; + int rc = -1; + + const bool ok = tidyOptSetBool(tDoc, TidyXhtmlOut, yes); + + if (ok) + rc = tidySetErrorBuffer(tDoc, &errBuf); + if (rc >= 0) + rc = tidyParseString(tDoc, input); + if (rc >= 0) + rc = tidyCleanAndRepair(tDoc); + if (rc >= 0) + rc = tidyRunDiagnostics(tDoc); + if (rc > 1) + rc = (tidyOptSetBool(tDoc, TidyForceOutput, yes) ? rc : -1); + if (rc >= 0) + rc = tidySaveBuffer(tDoc, &output); + + if (rc > 0) + printf("Diagnostics:\n%s\n\n", errBuf.bp); + if (rc >= 0) + printf("Output (valid HTML document):\n%s\n\n", output.bp); + else + printf("Unknown error: %d.\n\n", rc); + fflush(stdout); + + tidyBufFree(&errBuf); + tidyBufFree(&output); + tidyRelease(tDoc); + + return rc; +} diff --git a/src/tidy-html5.mk b/src/tidy-html5.mk new file mode 100644 index 0000000..33af291 --- /dev/null +++ b/src/tidy-html5.mk @@ -0,0 +1,30 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +PKG := tidy-html5 +$(PKG)_WEBSITE := http://www.html-tidy.org/ +$(PKG)_DESCR := HTML/XML syntax checker and reformatter +$(PKG)_IGNORE := +$(PKG)_VERSION := 5.4.0 +$(PKG)_CHECKSUM := a2d754b7349982e33f12d798780316c047a3b264240dc6bbd4641542e57a0b7a +$(PKG)_GH_CONF := htacg/tidy-html5 +$(PKG)_DEPS := gcc + +define $(PKG)_BUILD + cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(SOURCE_DIR)' \ + -DTIDY_COMPAT_HEADERS:BOOL=YES \ + -DBUILD_SHARED_LIB=$(CMAKE_SHARED_BOOL) + $(MAKE) -C '$(BUILD_DIR)' -j $(JOBS) + $(MAKE) -C '$(BUILD_DIR)' -j 1 install + + $(if $(BUILD_STATIC), + cd '$(PREFIX)/$(TARGET)/lib' && mv libtidys.a libtidy.a, + rm -f '$(PREFIX)/$(TARGET)/lib/libtidys.a') + rm -f '$(PREFIX)/$(TARGET)/bin/tidy.exe' + + # build test manually + '$(TARGET)-gcc' \ + -W -Wall -Werror \ + '$(PWD)/src/$(PKG)-test.c' \ + -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \ + -ltidy +endef |