Skip to content

Commit c5b9b31

Browse files
authored
Merge pull request #584 from fugerit-org/583-bug-some-characters-like-not-rendering-properly-on-html-renderer
fix: fj-doc-freemarker, set default charset for html renderer #584
2 parents 4a9840e + c827a9a commit c5b9b31

File tree

10 files changed

+81
-7
lines changed

10 files changed

+81
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- fj-doc-freemarker, set default charset for html renderer <https://github.com/fugerit-org/fj-doc/issues/583>
13+
1014
## [8.17.8] - 2025-11-26
1115

1216
### Added

docs/html/doc_meta_info.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<title>Documentation for Venus Doc Format standard meta informations</title>
5-
5+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
66
<meta name="author" content="Matteo Franci a.k.a. Fugerit"/>
77

88
<meta http-equiv="content-language" content="en"/>

fj-doc-base/src/main/docs/doc_xsd_config_ref.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<title>Reference xsd documentation for Venus - Fugerit Document Generation Framework (fj-doc)</title>
5-
5+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
66

77

88
<meta http-equiv="content-language" content="en"/>

fj-doc-base/src/main/java/org/fugerit/java/doc/base/process/DocProcessContext.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class DocProcessContext extends MiniFilterContext implements Serializable
2121

2222
public static final String ATT_NAME_DOC_TYPE = "docType";
2323

24+
public static final String ATT_NAME_DOC_CHARSET = "docCharset";
25+
2426
@Getter
2527
private int sourceType;
2628

@@ -44,7 +46,11 @@ public DocProcessContext withDocBase( DocBase docBase ) {
4446
public DocProcessContext withDocType( String type ) {
4547
return this.withAtt( ATT_NAME_DOC_TYPE , type );
4648
}
47-
49+
50+
public DocProcessContext withDocCharset( String type ) {
51+
return this.withAtt( ATT_NAME_DOC_CHARSET, type );
52+
}
53+
4854
public DocProcessContext withAtt( String key, Object value ) {
4955
this.setAttribute(key, value);
5056
return this;

fj-doc-base/src/test/java/test/org/fugerit/java/doc/base/process/TestDocProcessContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package test.org.fugerit.java.doc.base.process;
22

3+
import java.nio.charset.StandardCharsets;
34
import java.util.HashMap;
45
import java.util.Map;
56

@@ -19,10 +20,11 @@ class TestDocProcessContext {
1920
@Test
2021
void testContext1() {
2122
DocProcessContext context = DocProcessContext.newContext( "c", "d" ).withSourceType(DocFacadeSource.SOURCE_TYPE_XML)
22-
.withAtt( "a" , "b" ).withDocBase( new DocBase() ).withDocType( DocConfig.TYPE_PDF );
23+
.withAtt( "a" , "b" ).withDocBase( new DocBase() ).withDocType( DocConfig.TYPE_PDF ).withDocCharset(StandardCharsets.UTF_8.toString());
2324
log.info( "context : {}", context );
2425
Assertions.assertEquals( "b" , context.getAttribute( "a" ) );
2526
Assertions.assertEquals( DocFacadeSource.SOURCE_TYPE_XML , context.getSourceType() );
27+
Assertions.assertEquals( "UTF-8" , context.getAttribute( DocProcessContext.ATT_NAME_DOC_CHARSET ) );
2628
}
2729

2830
@Test

fj-doc-freemarker/src/main/docs/fdp_xsd_config_ref.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<title>Reference xsd documentation for Venus - Fugerit Document Generation Framework (fj-doc) - Freemarker Configuration</title>
5-
5+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
66

77

88
<meta http-equiv="content-language" content="en"/>

fj-doc-freemarker/src/main/resources/fj_doc_freemarker_config/template/html_doc.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<html lang="${docBase.infoDocLanguage!'en'}">
1111
<head>
1212
<title>${docBase.infoDocTitle!'Generated document'}</title>
13-
<#if (docBase.stableInfo['html-charset'])??><meta charset="${docBase.stableInfo['html-charset']}"></#if>
13+
<#if (docBase.stableInfo['html-charset'])??><meta charset="${docBase.stableInfo['html-charset']}"><#else><meta http-equiv="Content-Type" content="text/html;charset=${docCharset!'utf-8'}"></#if>
1414
<#if (docBase.infoDocAuthor)??><meta name="author" content="${docBase.infoDocAuthor}"/></#if>
1515
<#if (docBase.infoDocSubject)??><meta name="description" content="${docBase.infoDocSubject}"/></#if>
1616
<#if (docBase.infoDocLanguage)??><meta http-equiv="content-language" content="${docBase.infoDocLanguage}"/></#if>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package test.org.fugerit.java.doc.freemarker.issue;
2+
3+
import org.fugerit.java.core.function.SafeFunction;
4+
import org.fugerit.java.core.io.FileIO;
5+
import org.fugerit.java.core.lang.helpers.ClassHelper;
6+
import org.fugerit.java.doc.base.config.DocConfig;
7+
import org.fugerit.java.doc.base.config.DocInput;
8+
import org.fugerit.java.doc.base.config.DocOutput;
9+
import org.fugerit.java.doc.base.config.DocTypeHandler;
10+
import org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandler;
11+
import org.junit.jupiter.api.Assertions;
12+
import org.junit.jupiter.api.Test;
13+
14+
import java.io.File;
15+
import java.io.FileOutputStream;
16+
import java.io.IOException;
17+
import java.io.InputStreamReader;
18+
19+
class TestIssue583POC {
20+
21+
@Test
22+
void testIssue583() throws IOException {
23+
String xmlPath = "issue/583-some-characters-not-rendered-properly/issue-583-poc.xml";
24+
DocTypeHandler handler = FreeMarkerHtmlTypeHandler.HANDLER_UTF8;
25+
String type = DocConfig.TYPE_HTML;
26+
File outputFile = new File( "target/issue-583-some-characters-not-rendered-properly."+type );
27+
SafeFunction.apply( () -> {
28+
try (InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( xmlPath ) );
29+
FileOutputStream fos = new FileOutputStream( outputFile ) ) {
30+
handler.handle( DocInput.newInput( handler.getType() , reader ) , DocOutput.newOutput( fos ) );
31+
}
32+
} );
33+
Assertions.assertTrue( outputFile.exists() );
34+
String content = FileIO.readString( outputFile );
35+
Assertions.assertTrue( content.contains( "✅" ) );
36+
}
37+
38+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<doc
3+
xmlns="http://javacoredoc.fugerit.org"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://javacoredoc.fugerit.org https://www.fugerit.org/data/java/doc/xsd/doc-2-1.xsd" >
6+
7+
<metadata>
8+
<!-- Margin for document : left;right;top;bottom -->
9+
<info name="margins">10;10;10;30</info>
10+
<!-- documenta meta information -->
11+
<info name="doc-title">Issue 583 POC</info>
12+
<info name="doc-subject">some characters, like ✅ not rendering properly on html renderer</info>
13+
<info name="doc-author">fugerit79</info>
14+
<info name="doc-language">en</info>
15+
<header-ext>
16+
<para align="center" fore-color="#eeeeee">header test</para>
17+
</header-ext>
18+
</metadata>
19+
<body>
20+
<h id="title" head-level="1">Issue 583 POC : ❌ ⚠️ ✅ ⊘</h>
21+
</body>
22+
</doc>

fj-doc-guide/src/main/docs/asciidoc/chapters/00_2_release_notes.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Whereas the link:https://github.com/fugerit-org/fj-doc/blob/main/CHANGELOG.md[CH
66
[#doc-release-notes-unreleased]
77
==== Unreleased
88

9+
- fj-doc-freemarker, set default charset for html renderer link:https://github.com/fugerit-org/fj-doc/issues/583[#583]
10+
911
[#doc-release-notes-8-17-8]
1012
==== Version 8.17.8 [2025-11-26]
1113

@@ -14,7 +16,7 @@ Whereas the link:https://github.com/fugerit-org/fj-doc/blob/main/CHANGELOG.md[CH
1416
[#doc-release-notes-8-17-7]
1517
==== Version 8.17.7 [2025-11-20]
1618

17-
- new built-in function stringToBase64 link:https://github.com/fugerit-org/fj-doc/issues/580[#590]
19+
- new built-in function stringToBase64 link:https://github.com/fugerit-org/fj-doc/issues/580[#580]
1820
1921
[#doc-release-notes-8-17-6]
2022
==== Version 8.17.6 [2025-11-11]

0 commit comments

Comments
 (0)