diff --git a/CHANGELOG.md b/CHANGELOG.md index 888318363..9cb0a7d2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- fj-doc-freemarker, set default charset for html renderer + ## [8.17.8] - 2025-11-26 ### Added diff --git a/docs/html/doc_meta_info.html b/docs/html/doc_meta_info.html index 76f9904a3..d0aa6ded3 100644 --- a/docs/html/doc_meta_info.html +++ b/docs/html/doc_meta_info.html @@ -2,7 +2,7 @@ Documentation for Venus Doc Format standard meta informations - + diff --git a/fj-doc-base/src/main/docs/doc_xsd_config_ref.html b/fj-doc-base/src/main/docs/doc_xsd_config_ref.html index 2944d84a0..e7ef5f636 100644 --- a/fj-doc-base/src/main/docs/doc_xsd_config_ref.html +++ b/fj-doc-base/src/main/docs/doc_xsd_config_ref.html @@ -2,7 +2,7 @@ Reference xsd documentation for Venus - Fugerit Document Generation Framework (fj-doc) - + diff --git a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/process/DocProcessContext.java b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/process/DocProcessContext.java index d36eeecb6..199efa156 100644 --- a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/process/DocProcessContext.java +++ b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/process/DocProcessContext.java @@ -21,6 +21,8 @@ public class DocProcessContext extends MiniFilterContext implements Serializable public static final String ATT_NAME_DOC_TYPE = "docType"; + public static final String ATT_NAME_DOC_CHARSET = "docCharset"; + @Getter private int sourceType; @@ -44,7 +46,11 @@ public DocProcessContext withDocBase( DocBase docBase ) { public DocProcessContext withDocType( String type ) { return this.withAtt( ATT_NAME_DOC_TYPE , type ); } - + + public DocProcessContext withDocCharset( String type ) { + return this.withAtt( ATT_NAME_DOC_CHARSET, type ); + } + public DocProcessContext withAtt( String key, Object value ) { this.setAttribute(key, value); return this; diff --git a/fj-doc-base/src/test/java/test/org/fugerit/java/doc/base/process/TestDocProcessContext.java b/fj-doc-base/src/test/java/test/org/fugerit/java/doc/base/process/TestDocProcessContext.java index 705734288..79a4883dc 100644 --- a/fj-doc-base/src/test/java/test/org/fugerit/java/doc/base/process/TestDocProcessContext.java +++ b/fj-doc-base/src/test/java/test/org/fugerit/java/doc/base/process/TestDocProcessContext.java @@ -1,5 +1,6 @@ package test.org.fugerit.java.doc.base.process; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -19,10 +20,11 @@ class TestDocProcessContext { @Test void testContext1() { DocProcessContext context = DocProcessContext.newContext( "c", "d" ).withSourceType(DocFacadeSource.SOURCE_TYPE_XML) - .withAtt( "a" , "b" ).withDocBase( new DocBase() ).withDocType( DocConfig.TYPE_PDF ); + .withAtt( "a" , "b" ).withDocBase( new DocBase() ).withDocType( DocConfig.TYPE_PDF ).withDocCharset(StandardCharsets.UTF_8.toString()); log.info( "context : {}", context ); Assertions.assertEquals( "b" , context.getAttribute( "a" ) ); Assertions.assertEquals( DocFacadeSource.SOURCE_TYPE_XML , context.getSourceType() ); + Assertions.assertEquals( "UTF-8" , context.getAttribute( DocProcessContext.ATT_NAME_DOC_CHARSET ) ); } @Test diff --git a/fj-doc-freemarker/src/main/docs/fdp_xsd_config_ref.html b/fj-doc-freemarker/src/main/docs/fdp_xsd_config_ref.html index d8037d0c0..6cd990980 100644 --- a/fj-doc-freemarker/src/main/docs/fdp_xsd_config_ref.html +++ b/fj-doc-freemarker/src/main/docs/fdp_xsd_config_ref.html @@ -2,7 +2,7 @@ Reference xsd documentation for Venus - Fugerit Document Generation Framework (fj-doc) - Freemarker Configuration - + diff --git a/fj-doc-freemarker/src/main/resources/fj_doc_freemarker_config/template/html_doc.ftl b/fj-doc-freemarker/src/main/resources/fj_doc_freemarker_config/template/html_doc.ftl index 42e0f8ca3..02c93f52f 100644 --- a/fj-doc-freemarker/src/main/resources/fj_doc_freemarker_config/template/html_doc.ftl +++ b/fj-doc-freemarker/src/main/resources/fj_doc_freemarker_config/template/html_doc.ftl @@ -10,7 +10,7 @@ ${docBase.infoDocTitle!'Generated document'} - <#if (docBase.stableInfo['html-charset'])??> + <#if (docBase.stableInfo['html-charset'])??><#else> <#if (docBase.infoDocAuthor)??> <#if (docBase.infoDocSubject)??> <#if (docBase.infoDocLanguage)??> diff --git a/fj-doc-freemarker/src/test/java/test/org/fugerit/java/doc/freemarker/issue/TestIssue583POC.java b/fj-doc-freemarker/src/test/java/test/org/fugerit/java/doc/freemarker/issue/TestIssue583POC.java new file mode 100644 index 000000000..0d527c296 --- /dev/null +++ b/fj-doc-freemarker/src/test/java/test/org/fugerit/java/doc/freemarker/issue/TestIssue583POC.java @@ -0,0 +1,38 @@ +package test.org.fugerit.java.doc.freemarker.issue; + +import org.fugerit.java.core.function.SafeFunction; +import org.fugerit.java.core.io.FileIO; +import org.fugerit.java.core.lang.helpers.ClassHelper; +import org.fugerit.java.doc.base.config.DocConfig; +import org.fugerit.java.doc.base.config.DocInput; +import org.fugerit.java.doc.base.config.DocOutput; +import org.fugerit.java.doc.base.config.DocTypeHandler; +import org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandler; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; + +class TestIssue583POC { + + @Test + void testIssue583() throws IOException { + String xmlPath = "issue/583-some-characters-not-rendered-properly/issue-583-poc.xml"; + DocTypeHandler handler = FreeMarkerHtmlTypeHandler.HANDLER_UTF8; + String type = DocConfig.TYPE_HTML; + File outputFile = new File( "target/issue-583-some-characters-not-rendered-properly."+type ); + SafeFunction.apply( () -> { + try (InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( xmlPath ) ); + FileOutputStream fos = new FileOutputStream( outputFile ) ) { + handler.handle( DocInput.newInput( handler.getType() , reader ) , DocOutput.newOutput( fos ) ); + } + } ); + Assertions.assertTrue( outputFile.exists() ); + String content = FileIO.readString( outputFile ); + Assertions.assertTrue( content.contains( "✅" ) ); + } + +} diff --git a/fj-doc-freemarker/src/test/resources/issue/583-some-characters-not-rendered-properly/issue-583-poc.xml b/fj-doc-freemarker/src/test/resources/issue/583-some-characters-not-rendered-properly/issue-583-poc.xml new file mode 100644 index 000000000..5ac01a5a3 --- /dev/null +++ b/fj-doc-freemarker/src/test/resources/issue/583-some-characters-not-rendered-properly/issue-583-poc.xml @@ -0,0 +1,22 @@ + + + + + + 10;10;10;30 + + Issue 583 POC + some characters, like ✅ not rendering properly on html renderer + fugerit79 + en + + header test + + + + Issue 583 POC : ❌ ⚠️ ✅ ⊘ + + \ No newline at end of file diff --git a/fj-doc-guide/src/main/docs/asciidoc/chapters/00_2_release_notes.adoc b/fj-doc-guide/src/main/docs/asciidoc/chapters/00_2_release_notes.adoc index 1647effd2..dc633b94e 100644 --- a/fj-doc-guide/src/main/docs/asciidoc/chapters/00_2_release_notes.adoc +++ b/fj-doc-guide/src/main/docs/asciidoc/chapters/00_2_release_notes.adoc @@ -6,6 +6,8 @@ Whereas the link:https://github.com/fugerit-org/fj-doc/blob/main/CHANGELOG.md[CH [#doc-release-notes-unreleased] ==== Unreleased +- fj-doc-freemarker, set default charset for html renderer link:https://github.com/fugerit-org/fj-doc/issues/583[#583] + [#doc-release-notes-8-17-8] ==== Version 8.17.8 [2025-11-26] @@ -14,7 +16,7 @@ Whereas the link:https://github.com/fugerit-org/fj-doc/blob/main/CHANGELOG.md[CH [#doc-release-notes-8-17-7] ==== Version 8.17.7 [2025-11-20] -- new built-in function stringToBase64 link:https://github.com/fugerit-org/fj-doc/issues/580[#590] +- new built-in function stringToBase64 link:https://github.com/fugerit-org/fj-doc/issues/580[#580] [#doc-release-notes-8-17-6] ==== Version 8.17.6 [2025-11-11]