Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render section label outside content #1510

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/formatter/templates/html_div_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ export default (
${ each(bodyParagraphs, (paragraph) => `
<div class="${ paragraphClasses(paragraph) }">
${ when(paragraph.isLiteral(), () => `
<div class="row">
${ when(isPresent(paragraph.label), () => `
${ when(isPresent(paragraph.label), () => `
<div class="row">
<h3 class="label">${ paragraph.label }</h3>
`) }
</div>
`) }

<div class="row">
<div class="literal">${ newlinesToBreaks(renderSection(paragraph, configuration)) }</div>
</div>
`).else(() => `
Expand Down
13 changes: 10 additions & 3 deletions src/formatter/templates/html_table_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ export default (
${ each(bodyParagraphs, (paragraph) => `
<div class="${ paragraphClasses(paragraph) }">
${ when(paragraph.isLiteral(), () => `
${ when(isPresent(paragraph.label), () => `
<table class="row">
<tr>
<td>
<h3 class="label">${ paragraph.label }</h3>
</td>
</tr>
</table>
`) }

<table class="literal">
<tr>
${ when(isPresent(paragraph.label), () => `
<td class="label">${ paragraph.label }</td>
`) }
<td class="contents">${ newlinesToBreaks(renderSection(paragraph, configuration)) }</td>
</tr>
</table>
Expand Down
40 changes: 40 additions & 0 deletions test/formatter/html_div_formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph tab">
<div class="row">
<h3 class="label">Tab 1</h3>
</div>
<div class="row">
<div class="literal">
Tab line 1<br>
Tab line 2
Expand All @@ -179,6 +181,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph abc">
<div class="row">
<h3 class="label">ABC 1</h3>
</div>
<div class="row">
<div class="literal">
ABC line 1<br>
ABC line 2
Expand All @@ -189,6 +193,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph ly">
<div class="row">
<h3 class="label">LY 1</h3>
</div>
<div class="row">
<div class="literal">
LY line 1<br>
LY line 2
Expand All @@ -211,6 +217,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph grid">
<div class="row">
<h3 class="label">Grid 1</h3>
</div>
<div class="row">
<div class="literal">
Grid line 1<br>
Grid line 2
Expand Down Expand Up @@ -371,6 +379,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph tab">
<div class="row">
<h3 class="label">Tab 1</h3>
</div>
<div class="row">
<div class="literal">
Tab line 1<br>
Tab line 2
Expand All @@ -381,6 +391,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph abc">
<div class="row">
<h3 class="label">ABC 1</h3>
</div>
<div class="row">
<div class="literal">
ABC line 1<br>
ABC line 2
Expand All @@ -391,6 +403,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph ly">
<div class="row">
<h3 class="label">LY 1</h3>
</div>
<div class="row">
<div class="literal">
LY line 1<br>
LY line 2
Expand All @@ -413,6 +427,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph grid">
<div class="row">
<h3 class="label">Grid 1</h3>
</div>
<div class="row">
<div class="literal">
Grid line 1<br>
Grid line 2
Expand Down Expand Up @@ -753,6 +769,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph tab">
<div class="row">
<h3 class="label">Tab 1</h3>
</div>
<div class="row">
<div class="literal">
Tab line 1<br>
Tab line 2
Expand All @@ -763,6 +781,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph abc">
<div class="row">
<h3 class="label">ABC 1</h3>
</div>
<div class="row">
<div class="literal">
ABC line 1<br>
ABC line 2
Expand All @@ -773,6 +793,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph ly">
<div class="row">
<h3 class="label">LY 1</h3>
</div>
<div class="row">
<div class="literal">
LY line 1<br>
LY line 2
Expand All @@ -795,6 +817,9 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph grid">
<div class="row">
<h3 class="label">Grid 1</h3>
</div>

<div class="row">
<div class="literal">
Grid line 1<br>
Grid line 2
Expand Down Expand Up @@ -956,6 +981,9 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph tab">
<div class="row">
<h3 class="label">Tab 1</h3>
</div>

<div class="row">
<div class="literal">
Tab line 1<br>
Tab line 2
Expand All @@ -966,6 +994,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph abc">
<div class="row">
<h3 class="label">ABC 1</h3>
</div>
<div class="row">
<div class="literal">
ABC line 1<br>
ABC line 2
Expand All @@ -976,6 +1006,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph ly">
<div class="row">
<h3 class="label">LY 1</h3>
</div>
<div class="row">
<div class="literal">
LY line 1<br>
LY line 2
Expand All @@ -998,6 +1030,8 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph grid">
<div class="row">
<h3 class="label">Grid 1</h3>
</div>
<div class="row">
<div class="literal">
Grid line 1<br>
Grid line 2
Expand Down Expand Up @@ -1114,6 +1148,9 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph ${type}">
<div class="row">
<h3 class="label">${type} section</h3>
</div>

<div class="row">
<div class="literal">
${type.toUpperCase()} LINE 1<br>
${type.toUpperCase()} LINE 2
Expand All @@ -1138,6 +1175,9 @@ describe('HtmlDivFormatter', () => {
<div class="paragraph ${type}">
<div class="row">
<h3 class="label">${type} section</h3>
</div>

<div class="row">
<div class="literal">
${type} line 1<br>
${type} line 2
Expand Down
Loading
Loading