<#-- ${order.path} -->
- <#list excerpts as excerptProperties>
- <#if order.elenphExcerpt?has_content && excerptProperties.elenphExcerpt == order.elenphExcerpt>
- <#assign excerptText = excerptProperties.htmlContent >
- <#assign excerptTextName = excerptProperties.htmlLabel >
- <#assign worksCounter = excerptProperties.worksCounter >
- <#assign bibliographyCounter = excerptProperties.bibliographyCounter >
- #if>
- #list>
+ <#list excerpts as excerptProperties>
+ <#if order.elenphExcerpt?has_content && excerptProperties.elenphExcerpt == order.elenphExcerpt>
+ <#assign excerptText = excerptProperties.htmlContent >
+ <#assign excerptTextName = excerptProperties.htmlLabel >
+ <#assign worksCounter = excerptProperties.worksCounter >
+ <#assign bibliographyCounter = excerptProperties.bibliographyCounter >
+ #if>
+ #list>
+ <@startDocumentPart order.level?number lastLevel/>
<#if excerptText?? && excerptTextName?? && excerptTextName?has_content && excerptText?has_content>
-
-
- ${excerptText}
- <@arrangeSources works worksCounter?number order.elenphExcerpt />
- <@arrangeLiterature bibliography bibliographyCounter?number order.elenphExcerpt />
+
+ ${excerptText}
+ <@arrangeSources works worksCounter?number order.elenphExcerpt />
+ <@arrangeLiterature bibliography bibliographyCounter?number order.elenphExcerpt />
#if>
-
-
+ <#assign lastLevel = order.level?number >
#list>
+ <@endDocumentPart lastLevel />
<@arrangeSources works works?size />
<@arrangeLiterature bibliography bibliography?size />
#macro>
+<#macro startDocumentPart newLevel lastLevel=0 >
+ <#assign depth = newLevel - lastLevel >
+ <#if depth == 0>
+ <@closeDocPart 1 />
+ <@openDocPart 1 />
+ <#elseif depth > 0>
+ <@openDocPart depth />
+ <#else >
+ <@closeDocPart -depth+1 />
+ <@openDocPart 1 />
+ #if>
+#macro>
+
+<#macro endDocumentPart lastLevel newLevel=0>
+ <#assign depth = lastLevel - newLevel >
+ <#if depth > 0>
+ <@closeDocPart depth />
+ #if>
+#macro>
+
+<#macro closeDocPart count>
+ <#list 1..count as x>
+