diff --git a/.gitignore b/.gitignore index 17ad51e..88dfe91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /out/ /docs/ -node_modules/ diff --git a/README.md b/README.md index 62908eb..63edb79 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,15 @@ # hyperbuild -A fast HTML minifier written in C. -Designed to be used in C projects, as an executable, and in Node.js thanks to Emscripten. -Minifier heavily influenced by [kangax's html-minifier](https://github.com/kangax/html-minifier). +A fast HTML minifier written in C, heavily influenced by [kangax's html-minifier](https://github.com/kangax/html-minifier). + +Available in different flavours: + +- Standalone 64-bit Linux executable (this) +- [Node.js](https://github.com/wilsonzlin/hyperbuild-nodejs) +- [Express](https://github.com/wilsonzlin/hyperbuild-express) +- [Webpack](https://github.com/wilsonzlin/hyperbuild-webpack) +- [Apache](https://github.com/wilsonzlin/hyperbuild-apache) +- [Nginx](https://github.com/wilsonzlin/hyperbuild-nginx) ## Features @@ -12,7 +19,7 @@ hyperbuild minifies as it parses, directly streaming processed HTML to the outpu ### Super fast -hyperbuild is written in C, and can be run on Node.js using Emscripten, which generates fast Wasm code. +hyperbuild is written in C, and uses technologies like Emscripten and Cython to preserve performance in higher-level languages. ### Smart whitespace handling diff --git a/package.json b/package.json deleted file mode 100644 index 3ba29d6..0000000 --- a/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "hyperbuild", - "version": "0.0.3", - "description": "Streaming HTML minifier written in C and Emscripten for Node.js", - "types": "out/main.d.js", - "main": "out/hyperbuild.em.js", - "files": [ - "out/hyperbuild.em.js", - "out/hyperbuild.em.wasm", - "out/main.d.ts" - ], - "scripts": { - "clean": "rm -rf tmp out", - "preprocess": "./preprocess.sh", - "build": "npm run clean && ./compile.sh", - "buildDebug": "npm run clean && ./compile.sh --debug", - "buildInternalDocs": "npm run preprocess && doxygen Doxyfile", - "test": "mocha out/test/**/*.spec.js", - "prepublishOnly": "npm run test && npm run build" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/wilsonzlin/hyperbuild.git" - }, - "keywords": [ - "html", - "c", - "fast", - "build", - "builder", - "preprocess", - "preprocessor", - "minify", - "minifier" - ], - "author": { - "email": "contact@wilsonl.in", - "name": "Wilson Lin", - "url": "https://wilsonl.in/" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/wilsonzlin/hyperbuild/issues" - }, - "homepage": "https://github.com/wilsonzlin/hyperbuild#readme", - "devDependencies": { - "@types/chai": "^4.1.3", - "@types/emscripten": "0.0.31", - "@types/fs-extra": "^5.0.4", - "@types/mocha": "^5.2.1", - "@types/node": "^10.5.6", - "@types/strip-ansi": "^3.0.0", - "chai": "^4.1.2", - "fs-extra": "7.0.0", - "mocha": "^5.2.0", - "strip-ansi": "^4.0.0", - "ts-node": "^6.1.0", - "typescript": "3.0.1" - } -} diff --git a/src/main/c/__main__.c b/src/__main__.c similarity index 100% rename from src/main/c/__main__.c rename to src/__main__.c diff --git a/src/main/c/cli.c b/src/cli.c similarity index 100% rename from src/main/c/cli.c rename to src/cli.c diff --git a/src/main/c/em.c b/src/main/c/em.c deleted file mode 100644 index 2d6ac02..0000000 --- a/src/main/c/em.c +++ /dev/null @@ -1,191 +0,0 @@ -#include "./stream/content/html.c" -#include "./__main__.c" - -void em_init(void) { - hb_init(); -} - -hbe_err_t em_entry( - // Can be NULL - char *input_code, - size_t input_code_length, - - // Can be NULL - char *input_path, - - // Can be NULL - char **output_code, - // Can be NULL - size_t *output_code_length, - - // Can be NULL - char *output_path, - - int config_keep, - int config_buffer, - - // Can be NULL - char *suppress, - - // Need nondefault_ex_* because NULL is a valid value for ex_* - int nondefault_ex_collapse_whitespace, - char *ex_collapse_whitespace, - int nondefault_ex_destroy_whole_whitespace, - char *ex_destroy_whole_whitespace, - int nondefault_ex_trim_whitespace, - char *ex_trim_whitespace, - - int trim_class_attr, - int decode_entities, - int min_conditional_comments, - int remove_attr_quotes, - int remove_comments, - int remove_optional_tags, - int remove_tag_whitespace -) { - em_init(); - - hbe_err_t err = NULL; - hbe_err_t *hbe_err = &err; - - hbu_fstreamin_t input_file = NULL; - hbu_list_char_t input_buffer = NULL; - - hbu_fstreamout_t output_file = NULL; - hbu_list_char_t output_buffer = NULL; - - hbu_streamoptions_t config_stream = hbu_streamoptions_create(); - hbu_pipe_t pipe = NULL; - - nh_set_str_t ex_collapse_whitespace_set = NULL; - nh_set_str_t ex_destroy_whole_whitespace_set = NULL; - nh_set_str_t ex_trim_whitespace_set = NULL; - - if (suppress != NULL) { - HBE_CATCH_F(hbu_streamoptions_parse_and_add_errors_to_suppress, config_stream->suppressed_errors, suppress); - } - - if (nondefault_ex_collapse_whitespace) { - ex_collapse_whitespace_set = HBE_CATCH_F(hbu_streamoptions_parse_list_of_tags, ex_collapse_whitespace); - config_stream->ex_collapse_whitespace = ex_collapse_whitespace_set; - } else { - config_stream->ex_collapse_whitespace = hbu_streamoptions_default_ex_collapse_whitespace(); - } - - if (nondefault_ex_destroy_whole_whitespace) { - ex_destroy_whole_whitespace_set = HBE_CATCH_F(hbu_streamoptions_parse_list_of_tags, ex_destroy_whole_whitespace); - config_stream->ex_destroy_whole_whitespace = ex_destroy_whole_whitespace_set; - } else { - config_stream->ex_destroy_whole_whitespace = hbu_streamoptions_default_ex_destroy_whole_whitespace(); - } - - if (nondefault_ex_trim_whitespace) { - ex_trim_whitespace_set = HBE_CATCH_F(hbu_streamoptions_parse_list_of_tags, ex_trim_whitespace); - config_stream->ex_trim_whitespace = ex_trim_whitespace_set; - } else { - config_stream->ex_trim_whitespace = hbu_streamoptions_default_ex_trim_whitespace(); - } - - config_stream->trim_class_attr = trim_class_attr; - config_stream->decode_entities = decode_entities; - config_stream->min_conditional_comments = min_conditional_comments; - config_stream->remove_attr_quotes = remove_attr_quotes; - config_stream->remove_comments = remove_comments; - config_stream->remove_optional_tags = remove_optional_tags; - config_stream->remove_tag_whitespace = remove_tag_whitespace; - - pipe = hbu_pipe_create_blank(input_path); - - if (input_code != NULL) { - // Use provided code as input - input_buffer = hbu_list_char_create(); - hbu_list_char_extend_arr(input_buffer, (hb_char_t *) input_code, input_code_length); - hbu_pipe_blank_set_input_buffer(pipe, input_buffer); - } else { - // Read from a file as input - input_file = HBE_CATCH_F(hbu_fstreamin_create, input_path); - hbu_pipe_blank_set_input_fstreamin(pipe, input_file); - } - - if (config_buffer || input_code != NULL) { - // Direct output to a buffer if --buffer or input is code (not file) - output_buffer = hbu_list_char_create(); - hbu_pipe_blank_set_output_buffer(pipe, output_buffer); - } else { - // Direct output to a file - output_file = HBE_CATCH_F(hbu_fstreamout_create, output_path); - hbu_pipe_blank_set_output_fstreamout(pipe, output_file); - } - - // Magic - HBE_CATCH_F(hbs_content, config_stream, pipe, NULL); - - if (output_code != NULL) { - // Send back pointer to underlying data in output buffer - *output_code = (char *) hbu_list_char_underlying(output_buffer); - *output_code_length = output_buffer->length; - hbu_list_char_destroy_shallow(output_buffer); - output_buffer = NULL; - } else if (config_buffer) { - // Write buffered output data to file - output_file = HBE_CATCH_F(hbu_fstreamout_create, output_path); - HBE_CATCH_F(hbu_fstreamout_write_buffer, output_file, output_buffer); - } - - finally: - if (err != NULL) { - if (output_file != NULL && input_buffer == NULL && !config_keep) { - // Delete only after opening output stream (don't delete before existing file has not been touched) - // Don't need to set if $config_buffer, as it won't write anything anyway - if (unlink(output_path)) { - hbl_log(HBL_LOG_WARN, "Failed to delete file %s with error %d", output_path, errno); - } - } - } - - // Don't overwrite any existing err - if (input_file != NULL) { - hbe_err_t fstreamin_destroy_error = NULL; - hbu_fstreamin_destroy(&fstreamin_destroy_error, input_file); - if (fstreamin_destroy_error != NULL) { - hbl_error(fstreamin_destroy_error); - } - } - - if (input_buffer != NULL) { - hbu_list_char_destroy(input_buffer); - } - - // Don't overwrite any existing err - if (output_file != NULL) { - hbe_err_t fstreamout_destroy_error = NULL; - hbu_fstreamout_destroy(&fstreamout_destroy_error, output_file); - if (fstreamout_destroy_error != NULL) { - hbl_error(fstreamout_destroy_error); - } - } - - if (output_buffer != NULL) { - hbu_list_char_destroy(output_buffer); - } - - hbu_streamoptions_destroy(config_stream); - - if (pipe != NULL) { - hbu_pipe_destroy(pipe); - } - - if (ex_collapse_whitespace_set != NULL) { - nh_set_str_destroy(ex_collapse_whitespace_set); - } - - if (ex_destroy_whole_whitespace_set != NULL) { - nh_set_str_destroy(ex_destroy_whole_whitespace_set); - } - - if (ex_trim_whitespace_set != NULL) { - nh_set_str_destroy(ex_trim_whitespace_set); - } - - return err; -} diff --git a/src/main/resources/scrape/entityrefs.js b/src/main/resources/scrape/entityrefs.js deleted file mode 100644 index fefe6ef..0000000 --- a/src/main/resources/scrape/entityrefs.js +++ /dev/null @@ -1,16 +0,0 @@ -(function() { - "use strict"; - - let lines = []; - document.querySelectorAll(".named").forEach(t => { - let hex = t.nextElementSibling.textContent.slice(3, -1); - t.textContent.trim().split(/\s+/).map(raw => { - let r = raw.slice(1, -1); - lines.push([r, Number.parseInt(hex, 16)]); - }); - }); - - console.log(lines.map(l => { - return `nh_map_str_int32_set(hbr_entityrefs_map, "${l[0]}", 0x${l[1].toString(16)});` - }).sort().join("\n")); -})(); diff --git a/src/main/ts/main.ts b/src/main/ts/main.ts deleted file mode 100644 index fc11983..0000000 --- a/src/main/ts/main.ts +++ /dev/null @@ -1,233 +0,0 @@ -declare var _em_init: any; -declare var _free: any; -declare var _hbe_err_code: any; -declare var _hbe_err_destroy: any; -declare var _hbe_err_message: any; -declare var _malloc: any; -declare var ALLOC_NORMAL: any; -declare var allocate: any; -declare var cwrap: any; -declare var getValue: any; -declare var lengthBytesUTF8: any; -declare var Pointer_stringify: any; -declare var stringToUTF8: any; -declare var UTF8ToString: any; - -export interface IHyperbuildSettings { - keep?: boolean; - buffer?: boolean; - - inputCode?: string; - inputFile?: string; - outputFile?: O; - - suppress?: string[]; - - MXcollapseWhitespace?: string[]; - MXdestroyWholeWhitespace?: string[]; - MXtrimWhitespace?: string[]; - - trim_class_attr?: boolean; - decode_entities?: boolean; - min_conditional_comments?: boolean; - remove_attr_quotes?: boolean; - remove_comments?: boolean; - remove_optional_tags?: boolean; - remove_tag_whitespace?: boolean; -} - -export class HyperbuildError extends Error { - code: number; - - public constructor(code: number, message: string) { - super(); - this.code = code; - this.message = message; - } -} - -const hyperbuild_c_arg_types = [ - 'pointer', // input_code - 'number', // input_code_length - - 'string', // input_path - - 'number', // output_code (pointer) - 'number', // output_code_length (pointer) - - 'string', // output_path - - 'boolean', // config_keep - 'boolean', // config_buffer - - 'string', // suppress - - 'boolean', // nondefault_ex_collapse_whitespace - 'string', // ex_collapse_whitespace - 'boolean', // nondefault_ex_destroy_whole_whitespace - 'string', // ex_destroy_whole_whitespace - 'boolean', // nondefault_ex_trim_whitespace - 'string', // ex_trim_whitespace - - 'boolean', // trim_class_attr - 'boolean', // decode_entities - 'boolean', // min_conditional_comments - 'boolean', // remove_attr_quotes - 'boolean', // remove_comments - 'boolean', // remove_optional_tags - 'boolean', // remove_tag_whitespace -]; - -const hyperbuild_c = cwrap('em_entry', 'number', hyperbuild_c_arg_types); - -export interface IHyperbuild { - (settings: IHyperbuildSettings): O -} - -export function hyperbuild({ - keep = false, - buffer = false, - - inputCode, - inputFile, - outputFile, - - suppress, - - MXcollapseWhitespace, - MXdestroyWholeWhitespace, - MXtrimWhitespace, - - trim_class_attr = true, - decode_entities = true, - min_conditional_comments = true, - remove_attr_quotes = true, - remove_comments = true, - remove_optional_tags = true, - remove_tag_whitespace = true, -}: IHyperbuildSettings): O { - let args: any[] = hyperbuild_c_arg_types.map(() => null); - - let input_code_ptr = 0; - - let output_ptr = 0; - let output_size_ptr = 0; - - if (inputCode != undefined) { - let bytes = lengthBytesUTF8(inputCode); - args[0] = input_code_ptr = _malloc(bytes + 1); - stringToUTF8(inputCode, input_code_ptr, bytes + 1); - args[1] = bytes; - } else { - args[2] = inputFile; - } - - if (outputFile == undefined) { - // Pointers are 32-bit integers in Emscripten - // https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.htm - args[3] = output_ptr = allocate([0], "*", ALLOC_NORMAL); - args[4] = output_size_ptr = allocate([0], "*", ALLOC_NORMAL); - } else { - args[5] = outputFile; - } - - args[6] = keep; - args[7] = buffer; - - if (suppress != undefined) { - args[8] = suppress.join(","); - } - - if (MXcollapseWhitespace != undefined) { - args[9] = true; - args[10] = MXcollapseWhitespace.join(","); - } else { - args[9] = false; - } - if (MXdestroyWholeWhitespace != undefined) { - args[11] = true; - args[12] = MXdestroyWholeWhitespace.join(","); - } else { - args[11] = false; - } - if (MXtrimWhitespace != undefined) { - args[13] = true; - args[14] = MXtrimWhitespace.join(","); - } else { - args[13] = false; - } - - args[15] = trim_class_attr; - args[16] = decode_entities; - args[17] = min_conditional_comments; - args[18] = remove_attr_quotes; - args[19] = remove_comments; - args[20] = remove_optional_tags; - args[21] = remove_tag_whitespace; - - let err = null; - - let err_ptr = hyperbuild_c.apply(undefined, args); - if (err_ptr) { - let err_code = _hbe_err_code(err_ptr); - // TODO Does this work with non-ASCII? - // TODO Needs length as error message might contain NUL - let err_message = Pointer_stringify(_hbe_err_message(err_ptr)); - _hbe_err_destroy(err_ptr); - err = new HyperbuildError(err_code, err_message); - } - - let rv: O = undefined as O; - - if (output_ptr) { - // TODO Figure out size_t - let length = getValue(output_size_ptr, "i64"); - // TODO Does this work with non-ASCII? - rv = Pointer_stringify(getValue(output_ptr, "*"), length) as O; - } - - [input_code_ptr, output_ptr, output_size_ptr].forEach(ptr => { - if (ptr) { - _free(ptr); - } - }); - - if (err) { - throw err; - } - - return rv; -} - -let loaded = false; -const onload_functions: ((hyperbuild: IHyperbuild) => any)[] = []; -const onload_promises: Function[] = []; - -export function onload(callback: (hyperbuild: IHyperbuild) => any) { - if (loaded) { - callback(hyperbuild); - } else { - onload_functions.push(callback); - } -} - -export function load(): Promise { - if (loaded) { - return Promise.resolve(hyperbuild); - } else { - return new Promise(resolve => { - onload_promises.push(resolve); - }); - } -} - -Module['onRuntimeInitialized'] = () => { - _em_init(); - loaded = true; - onload_functions.forEach(fn => { - fn(hyperbuild); - }); - onload_promises.forEach(res => { - res(hyperbuild); - }); -}; diff --git a/src/main/c/rule/__main__.c b/src/rule/__main__.c similarity index 100% rename from src/main/c/rule/__main__.c rename to src/rule/__main__.c diff --git a/src/main/c/rule/char/attrname.c b/src/rule/char/attrname.c similarity index 100% rename from src/main/c/rule/char/attrname.c rename to src/rule/char/attrname.c diff --git a/src/main/c/rule/char/attrvalquote.c b/src/rule/char/attrvalquote.c similarity index 100% rename from src/main/c/rule/char/attrvalquote.c rename to src/rule/char/attrvalquote.c diff --git a/src/main/c/rule/char/c0.c b/src/rule/char/c0.c similarity index 100% rename from src/main/c/rule/char/c0.c rename to src/rule/char/c0.c diff --git a/src/main/c/rule/char/digit.c b/src/rule/char/digit.c similarity index 100% rename from src/main/c/rule/char/digit.c rename to src/rule/char/digit.c diff --git a/src/main/c/rule/char/hex.c b/src/rule/char/hex.c similarity index 100% rename from src/main/c/rule/char/hex.c rename to src/rule/char/hex.c diff --git a/src/main/c/rule/char/lcalpha.c b/src/rule/char/lcalpha.c similarity index 100% rename from src/main/c/rule/char/lcalpha.c rename to src/rule/char/lcalpha.c diff --git a/src/main/c/rule/char/tagname.c b/src/rule/char/tagname.c similarity index 100% rename from src/main/c/rule/char/tagname.c rename to src/rule/char/tagname.c diff --git a/src/main/c/rule/char/ucalpha.c b/src/rule/char/ucalpha.c similarity index 100% rename from src/main/c/rule/char/ucalpha.c rename to src/rule/char/ucalpha.c diff --git a/src/main/c/rule/char/unquotedattrval.c b/src/rule/char/unquotedattrval.c similarity index 100% rename from src/main/c/rule/char/unquotedattrval.c rename to src/rule/char/unquotedattrval.c diff --git a/src/main/c/rule/char/whitespace.c b/src/rule/char/whitespace.c similarity index 100% rename from src/main/c/rule/char/whitespace.c rename to src/rule/char/whitespace.c diff --git a/src/main/c/rule/entity/entityrefs.c b/src/rule/entity/entityrefs.c similarity index 100% rename from src/main/c/rule/entity/entityrefs.c rename to src/rule/entity/entityrefs.c diff --git a/src/main/c/rule/relation/blacklistchildren.c b/src/rule/relation/blacklistchildren.c similarity index 100% rename from src/main/c/rule/relation/blacklistchildren.c rename to src/rule/relation/blacklistchildren.c diff --git a/src/main/c/rule/relation/blacklistparents.c b/src/rule/relation/blacklistparents.c similarity index 100% rename from src/main/c/rule/relation/blacklistparents.c rename to src/rule/relation/blacklistparents.c diff --git a/src/main/c/rule/relation/whitelistchildren.c b/src/rule/relation/whitelistchildren.c similarity index 100% rename from src/main/c/rule/relation/whitelistchildren.c rename to src/rule/relation/whitelistchildren.c diff --git a/src/main/c/rule/relation/whitelistparents.c b/src/rule/relation/whitelistparents.c similarity index 100% rename from src/main/c/rule/relation/whitelistparents.c rename to src/rule/relation/whitelistparents.c diff --git a/src/main/c/rule/tag/contentfirsttags.c b/src/rule/tag/contentfirsttags.c similarity index 100% rename from src/main/c/rule/tag/contentfirsttags.c rename to src/rule/tag/contentfirsttags.c diff --git a/src/main/c/rule/tag/contenttags.c b/src/rule/tag/contenttags.c similarity index 100% rename from src/main/c/rule/tag/contenttags.c rename to src/rule/tag/contenttags.c diff --git a/src/main/c/rule/tag/formattingtags.c b/src/rule/tag/formattingtags.c similarity index 100% rename from src/main/c/rule/tag/formattingtags.c rename to src/rule/tag/formattingtags.c diff --git a/src/main/c/rule/tag/headingtags.c b/src/rule/tag/headingtags.c similarity index 100% rename from src/main/c/rule/tag/headingtags.c rename to src/rule/tag/headingtags.c diff --git a/src/main/c/rule/tag/htmltags.c b/src/rule/tag/htmltags.c similarity index 100% rename from src/main/c/rule/tag/htmltags.c rename to src/rule/tag/htmltags.c diff --git a/src/main/c/rule/tag/layouttags.c b/src/rule/tag/layouttags.c similarity index 100% rename from src/main/c/rule/tag/layouttags.c rename to src/rule/tag/layouttags.c diff --git a/src/main/c/rule/tag/mediatags.c b/src/rule/tag/mediatags.c similarity index 100% rename from src/main/c/rule/tag/mediatags.c rename to src/rule/tag/mediatags.c diff --git a/src/main/c/rule/tag/sectioningtags.c b/src/rule/tag/sectioningtags.c similarity index 100% rename from src/main/c/rule/tag/sectioningtags.c rename to src/rule/tag/sectioningtags.c diff --git a/src/main/c/rule/tag/specifictags.c b/src/rule/tag/specifictags.c similarity index 100% rename from src/main/c/rule/tag/specifictags.c rename to src/rule/tag/specifictags.c diff --git a/src/main/c/rule/tag/svgtags.c b/src/rule/tag/svgtags.c similarity index 100% rename from src/main/c/rule/tag/svgtags.c rename to src/rule/tag/svgtags.c diff --git a/src/main/c/rule/tag/tags.c b/src/rule/tag/tags.c similarity index 100% rename from src/main/c/rule/tag/tags.c rename to src/rule/tag/tags.c diff --git a/src/main/c/rule/tag/voidtags.c b/src/rule/tag/voidtags.c similarity index 100% rename from src/main/c/rule/tag/voidtags.c rename to src/rule/tag/voidtags.c diff --git a/src/main/c/rule/tag/wsstags.c b/src/rule/tag/wsstags.c similarity index 100% rename from src/main/c/rule/tag/wsstags.c rename to src/rule/tag/wsstags.c diff --git a/src/main/c/stream/attr/attr.c b/src/stream/attr/attr.c similarity index 100% rename from src/main/c/stream/attr/attr.c rename to src/stream/attr/attr.c diff --git a/src/main/c/stream/attr/attrval.c b/src/stream/attr/attrval.c similarity index 100% rename from src/main/c/stream/attr/attrval.c rename to src/stream/attr/attrval.c diff --git a/src/main/c/stream/attr/quoteattrval.c b/src/stream/attr/quoteattrval.c similarity index 100% rename from src/main/c/stream/attr/quoteattrval.c rename to src/stream/attr/quoteattrval.c diff --git a/src/main/c/stream/attr/unquoteattrval.c b/src/stream/attr/unquoteattrval.c similarity index 100% rename from src/main/c/stream/attr/unquoteattrval.c rename to src/stream/attr/unquoteattrval.c diff --git a/src/main/c/stream/bang/bang.c b/src/stream/bang/bang.c similarity index 100% rename from src/main/c/stream/bang/bang.c rename to src/stream/bang/bang.c diff --git a/src/main/c/stream/comment/comment.c b/src/stream/comment/comment.c similarity index 100% rename from src/main/c/stream/comment/comment.c rename to src/stream/comment/comment.c diff --git a/src/main/c/stream/content/html.c b/src/stream/content/html.c similarity index 100% rename from src/main/c/stream/content/html.c rename to src/stream/content/html.c diff --git a/src/main/c/stream/content/script.c b/src/stream/content/script.c similarity index 100% rename from src/main/c/stream/content/script.c rename to src/stream/content/script.c diff --git a/src/main/c/stream/content/style.c b/src/stream/content/style.c similarity index 100% rename from src/main/c/stream/content/style.c rename to src/stream/content/style.c diff --git a/src/main/c/stream/entity/entity.c b/src/stream/entity/entity.c similarity index 100% rename from src/main/c/stream/entity/entity.c rename to src/stream/entity/entity.c diff --git a/src/main/c/stream/tag/tag.c b/src/stream/tag/tag.c similarity index 100% rename from src/main/c/stream/tag/tag.c rename to src/stream/tag/tag.c diff --git a/src/main/c/stream/tag/tagname.c b/src/stream/tag/tagname.c similarity index 100% rename from src/main/c/stream/tag/tagname.c rename to src/stream/tag/tagname.c diff --git a/src/test/ts/main.spec.ts b/src/test/ts/main.spec.ts deleted file mode 100644 index 4b490b9..0000000 --- a/src/test/ts/main.spec.ts +++ /dev/null @@ -1,70 +0,0 @@ -import {expect} from "chai"; -import "mocha"; - -const {load: loadHyperbuild, hyperbuild} = require("../../hyperbuild.em.js"); - -before(() => { - return loadHyperbuild(); -}); - -describe("hyperbuild", () => { - it("should trim whitespace", () => { - expect(hyperbuild({ - inputCode: `

a

`, - })).to.equal("

a

"); - }); - - it("should destroy whole whitespace", () => { - expect(hyperbuild({ - inputCode: `
-
- -
-

Helloo

-
-
`, - })).to.equal("

Helloo

"); - }); - - it("should destroy whole whitespace at root", () => { - expect(hyperbuild({ - inputCode: ` -
-
-
- -
-
- `, - })).to.equal("
"); - }); - - it("should throw an error on malformed entities", () => { - [ - `
&x10FFF;
`, - `
Johnson & Johnson
`, - `
&10FFFF;
`, - `
&mdash
`, - ].map(p => { - let err = null; - try { - hyperbuild({inputCode: p}); - } catch (e) { - err = e; - } - - expect(err) - .and.have.property("code", 65); - }); - }); -}); - -it("should decode valid entities", () => { - expect(hyperbuild({ - inputCode: `
􏿿
`, - })).to.equal(`
\u{10FFFF}
`); - - expect(hyperbuild({ - inputCode: `
'
`, - })).to.equal(`
'
`); -}); diff --git a/src/main/c/util/__main__.c b/src/util/__main__.c similarity index 100% rename from src/main/c/util/__main__.c rename to src/util/__main__.c diff --git a/src/main/c/util/char/char.c b/src/util/char/char.c similarity index 100% rename from src/main/c/util/char/char.c rename to src/util/char/char.c diff --git a/src/main/c/util/config/streamoptions.c b/src/util/config/streamoptions.c similarity index 100% rename from src/main/c/util/config/streamoptions.c rename to src/util/config/streamoptions.c diff --git a/src/main/c/util/execution/error.c b/src/util/execution/error.c similarity index 100% rename from src/main/c/util/execution/error.c rename to src/util/execution/error.c diff --git a/src/main/c/util/execution/logging.c b/src/util/execution/logging.c similarity index 100% rename from src/main/c/util/execution/logging.c rename to src/util/execution/logging.c diff --git a/src/main/c/util/fstream/__base__.c b/src/util/fstream/__base__.c similarity index 100% rename from src/main/c/util/fstream/__base__.c rename to src/util/fstream/__base__.c diff --git a/src/main/c/util/fstream/fstreamin.c b/src/util/fstream/fstreamin.c similarity index 100% rename from src/main/c/util/fstream/fstreamin.c rename to src/util/fstream/fstreamin.c diff --git a/src/main/c/util/fstream/fstreamout.c b/src/util/fstream/fstreamout.c similarity index 100% rename from src/main/c/util/fstream/fstreamout.c rename to src/util/fstream/fstreamout.c diff --git a/src/main/c/util/list/__base__.c b/src/util/list/__base__.c similarity index 100% rename from src/main/c/util/list/__base__.c rename to src/util/list/__base__.c diff --git a/src/main/c/util/list/char.c b/src/util/list/char.c similarity index 100% rename from src/main/c/util/list/char.c rename to src/util/list/char.c diff --git a/src/main/c/util/list/charlist.c b/src/util/list/charlist.c similarity index 100% rename from src/main/c/util/list/charlist.c rename to src/util/list/charlist.c diff --git a/src/main/c/util/map/str-int32.c b/src/util/map/str-int32.c similarity index 100% rename from src/main/c/util/map/str-int32.c rename to src/util/map/str-int32.c diff --git a/src/main/c/util/map/str-strset.c b/src/util/map/str-strset.c similarity index 100% rename from src/main/c/util/map/str-strset.c rename to src/util/map/str-strset.c diff --git a/src/main/c/util/math/math.c b/src/util/math/math.c similarity index 100% rename from src/main/c/util/math/math.c rename to src/util/math/math.c diff --git a/src/main/c/util/pipe/pipe.c b/src/util/pipe/pipe.c similarity index 100% rename from src/main/c/util/pipe/pipe.c rename to src/util/pipe/pipe.c diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index beb0d02..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "src/**/*.ts" - ], - "compilerOptions": { - "target": "es5", - "lib": [ - "es5", - "es6", - "es7", - "es2017" - ], - "module": "commonjs", - "esModuleInterop": true, - "skipLibCheck": true, - "allowJs": false, - "declaration": true, - "outDir": "out", - "strict": true, - "suppressImplicitAnyIndexErrors": true, - "noImplicitAny": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strictPropertyInitialization": true, - "noImplicitThis": true, - "alwaysStrict": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - } -} -