@jsonresume/core 0.4.0 → 0.4.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonresume/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"styled-components": "^6.1.19",
|
|
39
|
-
"@jsonresume/types": "0.
|
|
39
|
+
"@jsonresume/types": "0.8.0",
|
|
40
40
|
"@jsonresume/utils": "0.5.0"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
@@ -111,6 +111,26 @@ describe('ListItem', () => {
|
|
|
111
111
|
expect(html).not.toContain('resume-highlights');
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
+
it('renders inline Markdown in string descriptions and highlights (#600)', () => {
|
|
115
|
+
const { html } = renderHtml(
|
|
116
|
+
<ListItem
|
|
117
|
+
title="t"
|
|
118
|
+
description="Led **five** people"
|
|
119
|
+
highlights={['See [it](https://e.com)', '<script>x</script>']}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
expect(html).toContain('<strong>five</strong>');
|
|
123
|
+
expect(html).toContain('<a href="https://e.com"');
|
|
124
|
+
expect(html).not.toContain('<script>');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('passes React nodes through unchanged', () => {
|
|
128
|
+
const { html } = renderHtml(
|
|
129
|
+
<ListItem title="t" description={<em>node</em>} />
|
|
130
|
+
);
|
|
131
|
+
expect(html).toContain('<em>node</em>');
|
|
132
|
+
});
|
|
133
|
+
|
|
114
134
|
it('renders every highlight as a list item', () => {
|
|
115
135
|
const { html } = renderHtml(
|
|
116
136
|
<ListItem title="t" highlights={['a', 'b', 'c']} />
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import { renderInlineMarkdown } from '@jsonresume/utils/markdown';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* ListItem Component
|
|
@@ -74,6 +75,12 @@ const Highlights = styled.ul`
|
|
|
74
75
|
}
|
|
75
76
|
`;
|
|
76
77
|
|
|
78
|
+
// Strings get their inline Markdown rendered (#600); nodes pass through.
|
|
79
|
+
const prose = (value) =>
|
|
80
|
+
typeof value === 'string'
|
|
81
|
+
? { dangerouslySetInnerHTML: { __html: renderInlineMarkdown(value) } }
|
|
82
|
+
: { children: value };
|
|
83
|
+
|
|
77
84
|
export function ListItem({
|
|
78
85
|
title,
|
|
79
86
|
subtitle,
|
|
@@ -110,13 +117,13 @@ export function ListItem({
|
|
|
110
117
|
)}
|
|
111
118
|
|
|
112
119
|
{description && (
|
|
113
|
-
<Description className="resume-description"
|
|
120
|
+
<Description className="resume-description" {...prose(description)} />
|
|
114
121
|
)}
|
|
115
122
|
|
|
116
123
|
{highlights.length > 0 && (
|
|
117
124
|
<Highlights className="resume-highlights">
|
|
118
125
|
{highlights.map((highlight, index) => (
|
|
119
|
-
<li key={index}
|
|
126
|
+
<li key={index} {...prose(highlight)} />
|
|
120
127
|
))}
|
|
121
128
|
</Highlights>
|
|
122
129
|
)}
|