Skip to content

Commit d831f43

Browse files
committed
refactor(templates): extract the text layer to templates.core.text
Move the neutral text-rendering primitives into com.demcha.compose.document.templates.core.text so every template family shares them without depending on cv: MarkdownText (from templates.components), plus CvTextStyles -> TextStyles, MarkdownInline, RichParagraphRenderer, and TextOrnaments (from cv.v2.components). ParagraphPrimitive and ParagraphRenderer stay in cv.v2.components — they are CV-section plumbing used only by the CV section renderers. Repoint all callers (cv.v2, coverletter.v2, the Gen-2 cv/coverletter presets, and the invoice/proposal builders that already used MarkdownText); relocate MarkdownInlineTest to core.text. Render is byte-identical (1607 tests green, zero snapshot updates); the move is a deliberate binary break on the 2.0 line (japicmp report-only). Markdown docs follow in the docs refresh.
1 parent 5dc5475 commit d831f43

59 files changed

Lines changed: 295 additions & 234 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/com/demcha/compose/document/templates/components/Module.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.demcha.compose.document.templates.components;
22

3+
import com.demcha.compose.document.templates.core.text.MarkdownText;
4+
35
import com.demcha.compose.document.node.*;
46
import com.demcha.compose.document.style.DocumentInsets;
57
import com.demcha.compose.document.style.DocumentTextStyle;

src/main/java/com/demcha/compose/document/templates/cv/v2/components/MarkdownInline.java renamed to src/main/java/com/demcha/compose/document/templates/core/text/MarkdownInline.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
package com.demcha.compose.document.templates.cv.v2.components;
1+
package com.demcha.compose.document.templates.core.text;
22

33
import com.demcha.compose.document.dsl.RichText;
44
import com.demcha.compose.document.node.InlineRun;
55
import com.demcha.compose.document.node.InlineTextRun;
66
import com.demcha.compose.document.style.DocumentTextStyle;
7-
import com.demcha.compose.document.templates.components.MarkdownText;
87

98
import java.util.regex.Matcher;
109
import java.util.regex.Pattern;
@@ -15,8 +14,8 @@
1514
* (non-emphasised) segments.
1615
*
1716
* <p>Honours {@code **bold**}, {@code *italic*}, {@code _italic_} via
18-
* the shared {@link MarkdownText} parser. Lives in the components
19-
* layer because every body / row / entry renderer calls it.</p>
17+
* the shared {@link MarkdownText} parser. Part of the neutral core text
18+
* layer, shared by every template family's body / row / entry rendering.</p>
2019
*
2120
* <p><strong>Inline links (since v1.6.8).</strong> Recognises the
2221
* standard Markdown {@code [label](url)} syntax and emits a clickable

src/main/java/com/demcha/compose/document/templates/components/MarkdownText.java renamed to src/main/java/com/demcha/compose/document/templates/core/text/MarkdownText.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.demcha.compose.document.templates.components;
1+
package com.demcha.compose.document.templates.core.text;
22

33
import com.demcha.compose.document.node.InlineRun;
44
import com.demcha.compose.document.node.InlineTextRun;

src/main/java/com/demcha/compose/document/templates/cv/v2/components/RichParagraphRenderer.java renamed to src/main/java/com/demcha/compose/document/templates/core/text/RichParagraphRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package com.demcha.compose.document.templates.cv.v2.components;
1+
package com.demcha.compose.document.templates.core.text;
22

33
import com.demcha.compose.document.dsl.SectionBuilder;
44
import com.demcha.compose.document.node.TextAlign;
55
import com.demcha.compose.document.style.DocumentInsets;
66
import com.demcha.compose.document.style.DocumentTextStyle;
77

88
/**
9-
* Reusable rich paragraph primitive for CV presets that need explicit
9+
* Reusable rich paragraph primitive for any preset that needs explicit
1010
* style, line spacing, and margin while still honouring inline markdown.
1111
*/
1212
public final class RichParagraphRenderer {

src/main/java/com/demcha/compose/document/templates/cv/v2/components/TextOrnaments.java renamed to src/main/java/com/demcha/compose/document/templates/core/text/TextOrnaments.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.demcha.compose.document.templates.cv.v2.components;
1+
package com.demcha.compose.document.templates.core.text;
22

33
import java.util.Locale;
44

src/main/java/com/demcha/compose/document/templates/cv/v2/components/CvTextStyles.java renamed to src/main/java/com/demcha/compose/document/templates/core/text/TextStyles.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.demcha.compose.document.templates.cv.v2.components;
1+
package com.demcha.compose.document.templates.core.text;
22

33
import com.demcha.compose.document.style.DocumentColor;
44
import com.demcha.compose.document.style.DocumentTextDecoration;
@@ -8,8 +8,8 @@
88
/**
99
* Small factory for preset-local text styles.
1010
*/
11-
public final class CvTextStyles {
12-
private CvTextStyles() {
11+
public final class TextStyles {
12+
private TextStyles() {
1313
}
1414

1515
/**
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* <h2>Core — neutral text rendering (text)</h2>
3+
*
4+
* <p>Family-agnostic text primitives shared by every template family. They turn
5+
* text plus a {@link com.demcha.compose.document.style.DocumentTextStyle} (or a
6+
* theme-derived style) into DSL nodes, and depend on no document family's data
7+
* model — so invoice, proposal, CV, and cover-letter all build on the same text
8+
* layer.</p>
9+
*
10+
* <ul>
11+
* <li>{@link com.demcha.compose.document.templates.core.text.MarkdownText}
12+
* — parse inline {@code **bold**} / {@code *italic*} markdown into inline runs.</li>
13+
* <li>{@link com.demcha.compose.document.templates.core.text.MarkdownInline}
14+
* — append parsed inline markdown into a {@code RichText} run.</li>
15+
* <li>{@link com.demcha.compose.document.templates.core.text.RichParagraphRenderer}
16+
* — render a markdown paragraph into a section.</li>
17+
* <li>{@link com.demcha.compose.document.templates.core.text.TextStyles}
18+
* — {@code DocumentTextStyle} factory helpers.</li>
19+
* <li>{@link com.demcha.compose.document.templates.core.text.TextOrnaments}
20+
* — spaced-caps, pipe-joins, and other small string helpers.</li>
21+
* </ul>
22+
*/
23+
package com.demcha.compose.document.templates.core.text;

src/main/java/com/demcha/compose/document/templates/coverletter/builder/CoverLetterBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import com.demcha.compose.document.style.DocumentTextStyle;
1010
import com.demcha.compose.document.templates.api.DocumentTemplate;
1111
import com.demcha.compose.document.templates.components.Header;
12-
import com.demcha.compose.document.templates.components.MarkdownText;
12+
import com.demcha.compose.document.templates.core.text.MarkdownText;
1313
import com.demcha.compose.document.templates.coverletter.layouts.LetterFormat;
1414
import com.demcha.compose.document.templates.coverletter.spec.CoverLetterHeader;
1515
import com.demcha.compose.document.templates.coverletter.spec.CoverLetterSpec;

src/main/java/com/demcha/compose/document/templates/coverletter/v2/components/LetterBody.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import com.demcha.compose.document.style.DocumentTextDecoration;
66
import com.demcha.compose.document.style.DocumentTextStyle;
77
import com.demcha.compose.document.templates.coverletter.v2.data.CoverLetterDocument;
8-
import com.demcha.compose.document.templates.cv.v2.components.CvTextStyles;
9-
import com.demcha.compose.document.templates.cv.v2.components.RichParagraphRenderer;
8+
import com.demcha.compose.document.templates.core.text.TextStyles;
9+
import com.demcha.compose.document.templates.core.text.RichParagraphRenderer;
1010
import com.demcha.compose.document.templates.core.theme.BrandTheme;
1111

1212
/**
@@ -58,7 +58,7 @@ public static void render(SectionBuilder host, CoverLetterDocument doc,
5858
*/
5959
public static void render(SectionBuilder host, CoverLetterDocument doc,
6060
BrandTheme theme, double bodySize) {
61-
DocumentTextStyle bodyStyle = CvTextStyles.of(
61+
DocumentTextStyle bodyStyle = TextStyles.of(
6262
theme.typography().bodyFont(),
6363
bodySize,
6464
DocumentTextDecoration.DEFAULT,
@@ -80,7 +80,7 @@ public static void render(SectionBuilder host, CoverLetterDocument doc,
8080
// The signed name sits on the line directly below the sign-off
8181
// (standard letter convention), so it gets only a small gap.
8282
double signatureGap = bodySize * 0.4;
83-
DocumentTextStyle signatureStyle = CvTextStyles.of(
83+
DocumentTextStyle signatureStyle = TextStyles.of(
8484
theme.typography().bodyFont(),
8585
bodySize,
8686
DocumentTextDecoration.ITALIC,

src/main/java/com/demcha/compose/document/templates/coverletter/v2/presets/CenteredHeadlineLetter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import com.demcha.compose.document.templates.api.DocumentTemplate;
1010
import com.demcha.compose.document.templates.coverletter.v2.components.LetterBody;
1111
import com.demcha.compose.document.templates.coverletter.v2.data.CoverLetterDocument;
12-
import com.demcha.compose.document.templates.cv.v2.components.CvTextStyles;
12+
import com.demcha.compose.document.templates.core.text.TextStyles;
1313
import com.demcha.compose.document.templates.cv.v2.data.CvIdentity;
1414
import com.demcha.compose.document.templates.core.theme.BrandTheme;
1515
import com.demcha.compose.document.templates.cv.v2.widgets.ContactLine;
@@ -122,7 +122,7 @@ public void compose(DocumentSession document, CoverLetterDocument doc) {
122122
}
123123

124124
private DocumentTextStyle subheadlineStyle() {
125-
return CvTextStyles.of(theme.typography().headlineFont(), 8.6,
125+
return TextStyles.of(theme.typography().headlineFont(), 8.6,
126126
DocumentTextDecoration.DEFAULT, theme.palette().muted());
127127
}
128128

0 commit comments

Comments
 (0)