Skip to content

Commit ddfa81e

Browse files
committed
* Html type handle can now set custom head info
1 parent 3a4e9c4 commit ddfa81e

File tree

4 files changed

+57
-13
lines changed

4 files changed

+57
-13
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.fugerit.java.doc.base.typehelper.html;
2+
3+
public class HtmlHelperConsts {
4+
5+
public final static String PROP_HTML_ADD_TO_HEAD = "html-add-to-head";
6+
7+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<#if (docBase.infoDocSubject)??><meta name="description" content="${docBase.infoDocSubject}"/></#if>
1414
<#if (docBase.infoDocLanguage)??><meta http-equiv="content-language" content="${docBase.infoDocLanguage}"/></#if>
1515
<meta name="doc-version-compatibility" content="${comp}"/>
16+
${docBase.stableInfo['html-add-to-head']!''}
1617
</head>
1718
<body>
1819
<div>

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@
2626

2727
<#macro handlePhrase current>
2828
<#if (current.link)??>
29-
<a <@handleStyleOnly styleValue=current.style/> href="${current.link}">${current.text}</a>
29+
<a <@handleId element=current/><@handleStyleOnly styleValue=current.style/> href="${current.link}">${current.text}</a>
3030
<#elseif (current.anchor)??>
31-
<a <@handleStyleOnly styleValue=current.style/> name="${current.anchor}">${current.text}</a>
31+
<a <@handleId element=current/><@handleStyleOnly styleValue=current.style/> name="${current.anchor}">${current.text}</a>
3232
<#else>
33-
<span <@handleStyleOnly styleValue=current.style/>>${current.text}</span>
33+
<span <@handleId element=current/><@handleStyleOnly styleValue=current.style/>>${current.text}</span>
3434
</#if>
3535
</#macro>
3636

3737
<#macro handlePara current>
3838
<#if current.headLevel == 0>
39-
<p <@handleStyleComplete element=current styleValue=current.originalStyle alignValue=current.align spaceBefore=current.spaceBefore!0 spaceAfter=current.spaceAfter!0/>>${current.text}<#list current.elementList as currentChild><@handleElement current=currentChild/></#list></p>
39+
<p <@handleId element=current/><@handleStyleComplete element=current styleValue=current.originalStyle alignValue=current.align spaceBefore=current.spaceBefore!0 spaceAfter=current.spaceAfter!0/>>${current.text}<#list current.elementList as currentChild><@handleElement current=currentChild/></#list></p>
4040
<#else>
41-
<h${current.headLevel} <@handleStyleComplete element=current styleValue=current.style alignValue=current.align spaceBefore=current.spaceBefore!0 spaceAfter=current.spaceAfter!0/>>${current.text}<#list current.elementList as currentChild><@handleElement current=currentChild/></#list></h${current.headLevel}>
41+
<h${current.headLevel} <@handleId element=current/><@handleStyleComplete element=current styleValue=current.style alignValue=current.align spaceBefore=current.spaceBefore!0 spaceAfter=current.spaceAfter!0/>>${current.text}<#list current.elementList as currentChild><@handleElement current=currentChild/></#list></h${current.headLevel}>
4242
</#if>
4343
</#macro>
4444

@@ -53,15 +53,15 @@
5353
<#assign imageAlign="style='display: block; margin-left: auto; margin-right: auto;'"/>
5454
</#if>
5555
</#if>
56-
<img ${imageAlign!''} <#if (docImage.alt)??> alt="${docImage.alt}" </#if> ${imageScaling} src="data:image/png;base64, ${docImage.resolvedBase64}" />
56+
<img <@handleId element=current/> ${imageAlign!''} <#if (docImage.alt)??> alt="${docImage.alt}" </#if> ${imageScaling} src="data:image/png;base64, ${docImage.resolvedBase64}" />
5757
</#macro>
5858

5959
<#macro handleList docList>
6060
<#if docList.elementList?size gt 0>
61-
<${docList.htmlType}>
61+
<${docList.htmlType} <@handleId element=current/>>
6262
<#list docList.elementList as li>
6363
<#if (li?counter > 0)>
64-
<li <#if li.contentList>style="list-style-type: none;"<#elseif docList.listType = 'oll'>style="list-style-type: lower-alpha;"<#elseif docList.listType = 'ulm'>style="list-style-type: square;"<#elseif docList.listType = 'uld'>style="list-style-type: circle;"</#if>> <#list li.elementList as element><@handleElement current=element/></#list></li>
64+
<li <@handleId element=current/><#if li.contentList>style="list-style-type: none;"<#elseif docList.listType = 'oll'>style="list-style-type: lower-alpha;"<#elseif docList.listType = 'ulm'>style="list-style-type: square;"<#elseif docList.listType = 'uld'>style="list-style-type: circle;"</#if>> <#list li.elementList as element><@handleElement current=element/></#list></li>
6565
</#if>
6666
<#assign prevLi=li/>
6767
</#list>
@@ -71,9 +71,9 @@
7171

7272
<#macro handleRowList docTable rowList cellType>
7373
<#list rowList as row>
74-
<tr>
75-
<#list row.elementList as cell>
76-
<${cellType} id="cell_${row?index}_${cell?index}" style="width: ${docTable.colWithds[cell?index]}%; <@handleAlign alignValue=cell.align/> <@handleBorders docBorders=cell.docBorders/>" <@handleColspan colspanValue=cell.columnSpan/> <@handleRowspan rowspanValue=cell.rowSpan/>>
74+
<tr <@handleId element=row/>>
75+
<#list row.elementList as cell><#assign defCellId>cell_${row?index}_${cell?index}</#assign>
76+
<${cellType} <@handleIdDef element=cell defId=defCellId/> style="width: ${docTable.colWithds[cell?index]}%; <@handleAlign alignValue=cell.align/> <@handleBorders docBorders=cell.docBorders/>" <@handleColspan colspanValue=cell.columnSpan/> <@handleRowspan rowspanValue=cell.rowSpan/>>
7777
<#list cell.elementList as cellElement>
7878
<@handleElement current=cellElement/>
7979
</#list>
@@ -130,6 +130,10 @@
130130
<@handleBorder mode='border-right' size=docBorders.borderWidthRight color=borderColorRight/>
131131
</#macro>
132132

133+
<#macro handleIdDef element defId><#if element.id??>id="${element.id}" <#else>id="${defId}"</#if></#macro>
134+
135+
<#macro handleId element><#if element.id??>id="${element.id}" </#if></#macro>
136+
133137
<#macro handleRowspan rowspanValue> rowspan="${rowspanValue}" </#macro>
134138

135139
<#macro handleColspan colspanValue> colspan="${colspanValue}" </#macro>

fj-doc-sample/src/test/resources/sample_docs/full_doc_header_footer.xml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020

2121
<info name="excel-table-id">excel-table=print</info>
2222
<info name="excel-width-multiplier">450</info>
23-
23+
24+
<info name="html-add-to-head"><![CDATA[
25+
<style type="text/css">
26+
#paraArial { background-color: red; }
27+
</style>
28+
]]></info>
29+
2430
<header numbered="true">
2531
<para align="center">Header, page ${currentPage}</para>
2632
</header>
@@ -33,9 +39,35 @@
3339

3440
<body>
3541

42+
<table width="100" columns="3" colwidths="30;40;40">
43+
<row>
44+
<cell id="test_cell_id_1_1"><para>test 1 1</para></cell>
45+
<cell id="testCell_1_2"><para>test 1 2</para></cell>
46+
<cell><para>test 1 3</para></cell>
47+
</row>
48+
<row>
49+
<cell><para>test 2 1</para></cell>
50+
<cell><para>test 2 2</para></cell>
51+
<cell><para>test 2 3</para></cell>
52+
</row>
53+
</table>
54+
55+
<phrase style="normal">para style="normal"</phrase>
56+
<br/>
57+
<phrase>para style not set (should behaves as style="normal")</phrase>
58+
<br/>
59+
<phrase style="bold">phrase style="bold"</phrase>
60+
<br/>
61+
<phrase style="bolditalic">phrase style="bolditalic"</phrase>
62+
<br/>
63+
<phrase style="italic">phrase style="italic"</phrase>
64+
<br/>
65+
<phrase style="underline">phrase style="underline"</phrase>
66+
<br/>
67+
3668
<para back-color="#000000" fore-color="#90ff90">para back-color="#000000" fore-color="#90ff90"</para>
3769
<br/>
38-
<para size="20" font-name="Arial">para font-name='Arial' size='20'</para>
70+
<para id="paraArial" size="20" font-name="Arial">para font-name='Arial' size='20'</para>
3971
<br/>
4072
<para align="center">para align="center" (Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.)</para>
4173
<br/>

0 commit comments

Comments
 (0)