@jsonresume/core 0.3.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -581,20 +581,10 @@ export function render(resume) {
581
581
 
582
582
  ### Step 5: Register Theme
583
583
 
584
- Add to `apps/registry/lib/formatters/template/themeConfig.js`:
585
-
586
- ```javascript
587
- import * as myTheme from 'jsonresume-theme-myname';
588
-
589
- export const THEMES = {
590
- // ...
591
- myname: {
592
- name: 'My Theme',
593
- theme: myTheme,
594
- description: 'A beautiful custom theme',
595
- },
596
- };
597
- ```
584
+ jsonresume.org renders themes through `@repo/resume-themes`. Add the package
585
+ as a dependency there, a loader in `packages/resume-themes/src/loaders.ts`,
586
+ and an entry in `packages/theme-config/src/metadata.js`: the full checklist
587
+ is in [`docs/CREATING_A_THEME.md`](../../docs/CREATING_A_THEME.md#3-registration-checklist).
598
588
 
599
589
  ## Examples
600
590
 
package/dist/tokens.css CHANGED
@@ -98,13 +98,13 @@
98
98
  }
99
99
 
100
100
  @page {
101
- size: A4;
101
+ size: auto;
102
102
  margin: 0.5in;
103
103
  }
104
104
 
105
105
  /* Prevent awkward breaks */
106
106
  .resume-section {
107
- page-break-inside: avoid;
107
+ page-break-inside: auto;
108
108
  }
109
109
 
110
110
  .resume-item {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonresume/core",
3
- "version": "0.3.7",
3
+ "version": "0.4.0",
4
4
  "description": "Framework-agnostic resume component core - design tokens, primitives, and validators",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -36,8 +36,8 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "styled-components": "^6.1.19",
39
- "@jsonresume/types": "0.6.1",
40
- "@jsonresume/utils": "0.4.1"
39
+ "@jsonresume/types": "0.7.0",
40
+ "@jsonresume/utils": "0.5.0"
41
41
  },
42
42
  "keywords": [
43
43
  "resume",
@@ -0,0 +1,29 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import React from 'react';
3
+ import { renderHtml } from './renderHtml.jsx';
4
+ import { InlineMarkdown, renderInlineMarkdown } from '../../index.js';
5
+
6
+ describe('InlineMarkdown (component)', () => {
7
+ it('renders the inline Markdown the schema allows', () => {
8
+ const { html } = renderHtml(
9
+ <InlineMarkdown text="Shipped **v2** with [Rust](https://rust-lang.org)" />
10
+ );
11
+ expect(html).toContain('<span>Shipped <strong>v2</strong> with ');
12
+ expect(html).toContain('<a href="https://rust-lang.org">Rust</a>');
13
+ });
14
+
15
+ it('renders as another element, escaping what it is given', () => {
16
+ const { html } = renderHtml(
17
+ <ul>
18
+ <InlineMarkdown as="li" className="x" text="<b>raw</b> *ok*" />
19
+ </ul>
20
+ );
21
+ expect(html).toContain(
22
+ '<li class="x">&lt;b&gt;raw&lt;/b&gt; <em>ok</em></li>'
23
+ );
24
+ });
25
+
26
+ it('is the same renderer @jsonresume/utils exports', () => {
27
+ expect(renderInlineMarkdown('`a`')).toBe('<code>a</code>');
28
+ });
29
+ });
package/src/index.js CHANGED
@@ -28,8 +28,15 @@ export {
28
28
  AccentSidebarStripe,
29
29
  AccentTopRule,
30
30
  RulesetStack,
31
+ InlineMarkdown,
31
32
  } from './primitives/index.jsx';
32
33
 
34
+ // Inline Markdown in resume text (#600): one renderer for every theme
35
+ export {
36
+ renderInlineMarkdown,
37
+ stripInlineMarkdown,
38
+ } from '@jsonresume/utils/markdown';
39
+
33
40
  // Export design tokens
34
41
  export {
35
42
  default as tokens,
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { renderInlineMarkdown } from '@jsonresume/utils/markdown';
3
+
4
+ /**
5
+ * InlineMarkdown Component
6
+ * Resume text with its inline Markdown rendered (#600): **strong**,
7
+ * *emphasis*, `code` and [links](https://example.com), the subset the
8
+ * schema allows in summaries, work and project highlights and project
9
+ * descriptions. Every theme that uses it shows the same thing. The text is
10
+ * escaped first and links keep only http(s) and mailto addresses, so it is
11
+ * safe with resume text from anyone.
12
+ *
13
+ * @component
14
+ * @example
15
+ * <InlineMarkdown text={work.summary} />
16
+ * <InlineMarkdown as="li" text={highlight} />
17
+ *
18
+ * @param {string} text - The resume text
19
+ * @param {React.ElementType} [as='span'] - HTML element to render as
20
+ */
21
+ export function InlineMarkdown({ text, as: Tag = 'span', ...rest }) {
22
+ return (
23
+ <Tag
24
+ {...rest}
25
+ dangerouslySetInnerHTML={{ __html: renderInlineMarkdown(text) }}
26
+ />
27
+ );
28
+ }
29
+
30
+ export default InlineMarkdown;
@@ -18,7 +18,8 @@ const StyledSection = styled.section`
18
18
  props.theme?.spacing?.section || 'var(--resume-space-section, 2rem)'};
19
19
 
20
20
  @media print {
21
- page-break-inside: avoid;
21
+ /* Sections can span pages; their headings stay with the first entry. */
22
+ page-break-inside: auto;
22
23
  }
23
24
  `;
24
25
 
@@ -12,6 +12,7 @@ export { Badge, BadgeList } from './Badge.jsx';
12
12
  export { ContactInfo } from './ContactInfo.jsx';
13
13
  export { Link } from './Link.jsx';
14
14
  export { InlineSeparatorPipe } from './InlineSeparatorPipe.jsx';
15
+ export { InlineMarkdown } from './InlineMarkdown.jsx';
15
16
 
16
17
  // Divider and separator components
17
18
  export { KeylineDivider } from './KeylineDivider';
package/src/ssr/index.js CHANGED
@@ -25,6 +25,18 @@ const CSS_RESET =
25
25
  '<style>*,*::before,*::after{box-sizing:border-box}' +
26
26
  'html,body{margin:0;padding:0}body{-webkit-font-smoothing:antialiased}</style>';
27
27
 
28
+ // Page margins repeat on continuation pages; body padding does not. Themes
29
+ // can override these defaults with their own print rules later in the head.
30
+ const PRINT_DEFAULTS = `<style data-jsonresume-core-print>
31
+ @page{size:auto;margin:12mm}
32
+ @media print{
33
+ body,h1,h2,h3,h4,p,li,a{overflow-wrap:anywhere}
34
+ :where(main,aside,section,article,header,div){min-width:0}
35
+ h1,h2,h3,h4,h5,h6{break-inside:avoid;break-after:avoid}
36
+ p,li{orphans:2;widows:2}
37
+ }
38
+ </style>`;
39
+
28
40
  /** Stylesheet href for the @jsonresume/core design tokens (CSS custom props). */
29
41
  const TOKENS_CSS_HREF = 'https://unpkg.com/@jsonresume/core/dist/tokens.css';
30
42
 
@@ -147,6 +159,7 @@ export function renderResumeDocument(element, options = {}) {
147
159
  fontLinks +
148
160
  tokensLink +
149
161
  resetTag +
162
+ PRINT_DEFAULTS +
150
163
  head +
151
164
  styleTags +
152
165
  headAfterStyles +
@@ -98,13 +98,13 @@
98
98
  }
99
99
 
100
100
  @page {
101
- size: A4;
101
+ size: auto;
102
102
  margin: 0.5in;
103
103
  }
104
104
 
105
105
  /* Prevent awkward breaks */
106
106
  .resume-section {
107
- page-break-inside: avoid;
107
+ page-break-inside: auto;
108
108
  }
109
109
 
110
110
  .resume-item {