Main
+This is the main content.
+ +diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index 0235f811..c31cf4bb 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -15,11 +15,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '17' + java-version: '21' # Given the fact that this is a multimodule project, build process will take long time so we activate caching # To know more: https://maven.apache.org/extensions/maven-build-cache-extension/cache.html cache: 'maven' diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 1b1e9aa6..f13d6d0e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -6,8 +6,12 @@ name: Java CI with Maven on: push: branches: [ main ] + paths-ignore: + - '**.md' pull_request: branches: [ main ] + paths-ignore: + - '**.md' permissions: contents: read @@ -19,11 +23,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '17' + java-version: '21' # Given the fact that this is a multimodule project, build process will take long time so we activate caching # To know more: https://maven.apache.org/extensions/maven-build-cache-extension/cache.html cache: 'maven' diff --git a/README.api.md b/README.api.md index d50ce812..bcd520bf 100644 --- a/README.api.md +++ b/README.api.md @@ -1,68 +1,5 @@ # API -Using [`httpie`](https://httpie.io/): -```shell -# You can also pass as many HTML content as you want -# Response will be of 'application/json' content type -http -vf :8080/convert \ - extension='.js' \ - contents[]='
This is the main content.
+ ++ *
* Result of HTML conversion to JS code from * HTML Code Generator: * @@ -90,23 +92,23 @@ public void before() { *
* {@code * - let code = ""; - code += "- - * - * - * - *3 possible results of HTML conversion to JS code from WTOOLS: + *HTML To JavaScript
\n"; - code += "\n"; - code += "\t
\n"; + * let code = ""; + * code += "- First item
\n"; - code += "\t- Second item
\n"; - code += "\t- Third item
\n"; - code += "\t- Fourth item
\n"; - code += "HTML To JavaScript
\n"; + * code += "\n"; + * code += "\t
\n"; * * * } *- First item
\n"; + * code += "\t- Second item
\n"; + * code += "\t- Third item
\n"; + * code += "\t- Fourth item
\n"; + * code += "
+ *
+ *
+ *
+ * 3 possible results of HTML conversion to JS code from WTOOLS: * * *
@@ -123,8 +125,8 @@ public void before() { * * } *- * - *----------------------------------------------------- + *
+ * ----------------------------------------------------- * *
* {@code @@ -140,32 +142,30 @@ public void before() { * * } *- - - ----------------------------------------------------- - + *
+ *
+ * ----------------------------------------------------- + * *
* {@code * - var variable = '' + - '- * - * + *HTML To JavaScript
' + - '' + - '
' + - ''; + * var variable = '' + + * '- First item
' + - '- Second item
' + - '- Third item
' + - '- Fourth item
' + - 'HTML To JavaScript
' + + * '' + + * '
' + + * ''; * * * } *- First item
' + + * '- Second item
' + + * '- Third item
' + + * '- Fourth item
' + + * '
+ *
* Our results use let,var and const as variable declarations, we also generate js variable for each element. - * - * - * */ + */ //TODO: Remove this method and put that in comparison issue @ParameterizedTest @MethodSource("provideVariableDeclarationsAndQuerySelectorAdded") @@ -187,7 +187,7 @@ void comparisonBetweenJsGeneratorAndOtherConverters(final VariableDeclaration va if (querySelectorAdded) { - assertThat(converted).containsExactly( "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), + assertThat(converted).containsExactly("%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s h1_001 = document.createElement('h1');".formatted(keyword), "%s text_001 = document.createTextNode(`HTML To JavaScript`);".formatted(keyword), "h1_001.appendChild(text_001);", @@ -255,7 +255,7 @@ void comparisonBetweenJsGeneratorAndOtherConverters(final VariableDeclaration va @ParameterizedTest @MethodSource("provideVariableDeclarationsAndQuerySelectorAddedAndCommentConversionModeActivated") - void comparisonBetweenJsGeneratorAndOtherConvertersWithComment(final VariableDeclaration variableDeclaration, final boolean querySelectorAdded,final boolean commentConversionModeActivated) throws IOException { + void comparisonBetweenJsGeneratorAndOtherConvertersWithComment(final VariableDeclaration variableDeclaration, final boolean querySelectorAdded, final boolean commentConversionModeActivated) throws IOException { final var keyword = keyword(variableDeclaration); final var converted = convert( """ @@ -274,8 +274,8 @@ void comparisonBetweenJsGeneratorAndOtherConvertersWithComment(final VariableDec printConverted(converted); if (querySelectorAdded) { - if(commentConversionModeActivated){ - assertThat(converted).containsExactly( "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), + if (commentConversionModeActivated) { + assertThat(converted).containsExactly("%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s h1_001 = document.createElement('h1');".formatted(keyword), "%s text_001 = document.createTextNode(`HTML To JavaScript`);".formatted(keyword), "h1_001.appendChild(text_001);", @@ -315,8 +315,8 @@ void comparisonBetweenJsGeneratorAndOtherConvertersWithComment(final VariableDec "ol_001.appendChild(li_004);", "targetElement_001.appendChild(ol_001);" ); - }else{ - assertThat(converted).containsExactly( "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), + } else { + assertThat(converted).containsExactly("%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s h1_001 = document.createElement('h1');".formatted(keyword), "%s text_001 = document.createTextNode(`HTML To JavaScript`);".formatted(keyword), "h1_001.appendChild(text_001);", @@ -354,7 +354,7 @@ void comparisonBetweenJsGeneratorAndOtherConvertersWithComment(final VariableDec ); } } else { - if(commentConversionModeActivated){ + if (commentConversionModeActivated) { assertThat(converted).containsExactly( "%s h1_001 = document.createElement('h1');".formatted(keyword), "%s text_001 = document.createTextNode(`HTML To JavaScript`);".formatted(keyword), @@ -393,7 +393,7 @@ void comparisonBetweenJsGeneratorAndOtherConvertersWithComment(final VariableDec "li_004.appendChild(text_011);", "ol_001.appendChild(li_004);" ); - }else{ + } else { assertThat(converted).containsExactly( "%s h1_001 = document.createElement('h1');".formatted(keyword), "%s text_001 = document.createTextNode(`HTML To JavaScript`);".formatted(keyword), @@ -480,7 +480,7 @@ void issue145WithCustomTagJavaScriptIdentifiersWithComment(final VariableDeclara printConverted(converted); if (querySelectorAdded) { - if (commentConversionModeActivated){ + if (commentConversionModeActivated) { assertThat(converted).containsExactly( "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s comment_001 = document.createComment(`Angular Comment`);".formatted(keyword), @@ -497,7 +497,7 @@ void issue145WithCustomTagJavaScriptIdentifiersWithComment(final VariableDeclara "targetElement_001.appendChild(custom_web_component_001);", "%s comment_003 = document.createComment(`Custom Tags`);".formatted(keyword), "targetElement_001.appendChild(comment_003);"); - }else{ + } else { assertThat(converted).containsExactly( "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s custom_angulartext_001 = document.createElement('AngularText');".formatted(keyword), @@ -510,7 +510,7 @@ void issue145WithCustomTagJavaScriptIdentifiersWithComment(final VariableDeclara "targetElement_001.appendChild(custom_web_component_001);"); } } else { - if (commentConversionModeActivated){ + if (commentConversionModeActivated) { assertThat(converted).containsExactly( "%s comment_001 = document.createComment(`Angular Comment`);".formatted(keyword), "%s custom_angulartext_001 = document.createElement('AngularText');".formatted(keyword), @@ -521,7 +521,7 @@ void issue145WithCustomTagJavaScriptIdentifiersWithComment(final VariableDeclara "%s text_002 = document.createTextNode(`Web Component`);".formatted(keyword), "custom_web_component_001.appendChild(text_002);", "%s comment_003 = document.createComment(`Custom Tags`);".formatted(keyword)); - }else{ + } else { assertThat(converted).containsExactly( "%s custom_angulartext_001 = document.createElement('AngularText');".formatted(keyword), "%s text_001 = document.createTextNode(`Angular`);".formatted(keyword), @@ -548,7 +548,7 @@ void issue41WithSelfClosingTags(final VariableDeclaration variableDeclaration, f printConverted(converted); if (querySelectorAdded) { - if(commentConversionModeActivated){ + if (commentConversionModeActivated) { assertThat(converted).containsExactly( "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s input_001 = document.createElement('input');".formatted(keyword), @@ -572,7 +572,7 @@ void issue41WithSelfClosingTags(final VariableDeclaration variableDeclaration, f "script_001.text = `// no-comment`;", "targetElement_001.appendChild(script_001);", "}"); - }else{ + } else { assertThat(converted).containsExactly( "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s input_001 = document.createElement('input');".formatted(keyword), @@ -596,7 +596,7 @@ void issue41WithSelfClosingTags(final VariableDeclaration variableDeclaration, f "}"); } } else { - if(commentConversionModeActivated){ + if (commentConversionModeActivated) { assertThat(converted).containsExactly( "%s input_001 = document.createElement('input');".formatted(keyword), "input_001.setAttribute(`type`, `text`);", @@ -613,7 +613,7 @@ void issue41WithSelfClosingTags(final VariableDeclaration variableDeclaration, f "} catch (_) {", "script_001.text = `// no-comment`;", "}"); - }else{ + } else { assertThat(converted).containsExactly( "%s input_001 = document.createElement('input');".formatted(keyword), "input_001.setAttribute(`type`, `text`);", @@ -644,11 +644,13 @@ void produceValidCodeWhenGivenCDATA(VariableDeclaration variableDeclaration, fin printConverted(converted); if (querySelectorAdded) { - assertThat(converted).containsExactly( - "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), - "%s text_001 = document.createTextNode(` < %s > & `);".formatted(keyword, token), - "targetElement_001.appendChild(text_001);"); - } else {assertThat(converted).containsExactly("%s text_001 = document.createTextNode(` < %s > & `);".formatted(keyword, token));} + assertThat(converted).containsExactly( + "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), + "%s text_001 = document.createTextNode(` < %s > & `);".formatted(keyword, token), + "targetElement_001.appendChild(text_001);"); + } else { + assertThat(converted).containsExactly("%s text_001 = document.createTextNode(` < %s > & `);".formatted(keyword, token)); + } } @ParameterizedTest @@ -666,7 +668,9 @@ void produceValidCodeWhenGivenPlainText(VariableDeclaration variableDeclaration, "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s text_001 = document.createTextNode(`%s`);".formatted(keyword, token), "targetElement_001.appendChild(text_001);"); - } else {assertThat(converted).containsExactly("%s text_001 = document.createTextNode(`%s`);".formatted(keyword, token));} + } else { + assertThat(converted).containsExactly("%s text_001 = document.createTextNode(`%s`);".formatted(keyword, token)); + } } @ParameterizedTest @@ -675,29 +679,31 @@ void produceValidCodeWhenGivenPlainTextWithComment(VariableDeclaration variableD final var token = randomUUID().toString(); final var keyword = keyword(variableDeclaration); final var configuration = new Configuration(variableDeclaration, querySelectorAdded, commentConversionModeActivated); - final var converted = convert(" %s".formatted(token,token), configuration); + final var converted = convert(" %s".formatted(token, token), configuration); printConverted(converted); if (querySelectorAdded) { - if(commentConversionModeActivated){ + if (commentConversionModeActivated) { assertThat(converted).containsExactly("%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s comment_001 = document.createComment(` %s `);".formatted(keyword, token), "targetElement_001.appendChild(comment_001);", "%s text_001 = document.createTextNode(` %s`);".formatted(keyword, token), "targetElement_001.appendChild(text_001);"); - }else{ + } else { assertThat(converted).containsExactly("%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s text_001 = document.createTextNode(` %s`);".formatted(keyword, token), "targetElement_001.appendChild(text_001);"); } } else { - if(commentConversionModeActivated){ + if (commentConversionModeActivated) { assertThat(converted).containsExactly( "%s comment_001 = document.createComment(` %s `);".formatted(keyword, token), "%s text_001 = document.createTextNode(` %s`);".formatted(keyword, token)); - }else{assertThat(converted).containsExactly("%s text_001 = document.createTextNode(` %s`);".formatted(keyword, token));} + } else { + assertThat(converted).containsExactly("%s text_001 = document.createTextNode(` %s`);".formatted(keyword, token)); + } } } @@ -707,25 +713,25 @@ void produceValidCodeWhenGivenPlainTextWithComment(VariableDeclaration variableD void produceValidCodeWhenGivenComment(VariableDeclaration variableDeclaration, final boolean querySelectorAdded, final boolean commentConversionModeActivated) throws IOException { final var token = randomUUID().toString(); final var keyword = keyword(variableDeclaration); - final var configuration = new Configuration(variableDeclaration, querySelectorAdded,commentConversionModeActivated); + final var configuration = new Configuration(variableDeclaration, querySelectorAdded, commentConversionModeActivated); final var converted = convert("".formatted(token), configuration); printConverted(converted); if (querySelectorAdded) { - if(commentConversionModeActivated){ + if (commentConversionModeActivated) { assertThat(converted).containsExactly( "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword), "%s comment_001 = document.createComment(` %s `);".formatted(keyword, token), "targetElement_001.appendChild(comment_001);"); - }else{ + } else { assertThat(converted).containsExactly( "%s targetElement_001 = document.querySelector(`:root > body`);".formatted(keyword)); } } else { - if(commentConversionModeActivated){ + if (commentConversionModeActivated) { assertThat(converted).containsExactly("%s comment_001 = document.createComment(` %s `);".formatted(keyword, token)); - }else{ + } else { assertThat(converted).containsExactly(); } } @@ -860,16 +866,16 @@ void produceValidCodeWhenGivenTagWithAttributes(VariableDeclaration variableDecl @ParameterizedTest @MethodSource("provideVariableDeclarationsAndQuerySelectorAddedAndCommentConversionModeActivated") - void produceValidCodeWhenGivenTagWithAttributesWithComment(VariableDeclaration variableDeclaration, final boolean querySelectorAdded,final boolean commentConversionModeActivated) throws IOException { + void produceValidCodeWhenGivenTagWithAttributesWithComment(VariableDeclaration variableDeclaration, final boolean querySelectorAdded, final boolean commentConversionModeActivated) throws IOException { final var keyword = keyword(variableDeclaration); if (querySelectorAdded) { String input = "
"; - var configuration = new Configuration(variableDeclaration, true,commentConversionModeActivated); + var configuration = new Configuration(variableDeclaration, true, commentConversionModeActivated); var converted = convert(input, configuration); - if(commentConversionModeActivated){ + if (commentConversionModeActivated) { printConverted(converted); assertThat(converted).containsExactly( @@ -880,7 +886,7 @@ void produceValidCodeWhenGivenTagWithAttributesWithComment(VariableDeclaration v "div_001.setAttribute(`id`, `id-value`);", "targetElement_001.appendChild(div_001);"); - }else{ + } else { printConverted(converted); assertThat(converted).containsExactly( @@ -892,10 +898,10 @@ void produceValidCodeWhenGivenTagWithAttributesWithComment(VariableDeclaration v } input = "