Skip to content

Commit c778e8a

Browse files
authored
Merge pull request #314 from skohub-io/313-markdown-render
Add Markdown Rendering for Documentary Notes
2 parents a86f954 + 79bd877 commit c778e8a

3 files changed

Lines changed: 69 additions & 21 deletions

File tree

src/components/Concept.jsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ const Concept = ({
6060
<h3 id="note">Note</h3>
6161
<ul aria-labelledby="note">
6262
{i18n(language)(concept.note).map((note, i) => (
63-
<li key={i}>{note}</li>
63+
<li key={i}>
64+
<Markdown>{note}</Markdown>
65+
</li>
6466
))}
6567
</ul>
6668
</div>
@@ -70,7 +72,9 @@ const Concept = ({
7072
<h3 id="changenote">ChangeNote</h3>
7173
<ul aria-labelledby="changenote">
7274
{i18n(language)(concept.changeNote).map((changeNote, i) => (
73-
<li key={i}>{changeNote}</li>
75+
<li key={i}>
76+
<Markdown>{changeNote}</Markdown>
77+
</li>
7478
))}
7579
</ul>
7680
</div>
@@ -81,7 +85,9 @@ const Concept = ({
8185
<h3 id="editorialnote">EditorialNote</h3>
8286
<ul aria-labelledby="editorialnote">
8387
{i18n(language)(concept.editorialNote).map((editorialNote, i) => (
84-
<li key={i}>{editorialNote}</li>
88+
<li key={i}>
89+
<Markdown>{editorialNote}</Markdown>
90+
</li>
8591
))}
8692
</ul>
8793
</div>
@@ -91,7 +97,9 @@ const Concept = ({
9197
<h3 id="historynote">HistoryNote</h3>
9298
<ul aria-labelledby="historynote">
9399
{i18n(language)(concept.historyNote).map((historyNote, i) => (
94-
<li key={i}>{historyNote}</li>
100+
<li key={i}>
101+
<Markdown>{historyNote}</Markdown>
102+
</li>
95103
))}
96104
</ul>
97105
</div>
@@ -101,7 +109,9 @@ const Concept = ({
101109
<h3 id="scopenote">ScopeNote</h3>
102110
<ul aria-labelledby="scopenote">
103111
{i18n(language)(concept.scopeNote).map((scopeNote, i) => (
104-
<li key={i}>{scopeNote}</li>
112+
<li key={i}>
113+
<Markdown>{scopeNote}</Markdown>
114+
</li>
105115
))}
106116
</ul>
107117
</div>

test/concept.test.jsx

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ describe.concurrent("Concept", () => {
6363
expect(
6464
screen.getByRole("heading", { name: "Definition" })
6565
).toBeInTheDocument()
66-
expect(screen.getByText("Meine Definition")).toBeInTheDocument()
66+
const definition = screen.getByText("Meine Definition")
67+
expect(definition).toBeInTheDocument()
68+
69+
const linkElement = within(definition).getByRole("link", { name: /link/i })
70+
expect(linkElement).toBeInTheDocument()
6771
})
6872

6973
it("renders no definition if not provided in language", () => {
@@ -120,15 +124,25 @@ describe.concurrent("Concept", () => {
120124

121125
it("renders examples", () => {
122126
render(<Concept pageContext={ConceptPC} />)
123-
expect(
124-
screen.getByRole("heading", { name: /^example$/i })
125-
).toBeInTheDocument()
127+
128+
const exampleHeading = screen.getByRole("heading", { name: /^example$/i })
129+
expect(exampleHeading).toBeInTheDocument()
130+
131+
const example = screen.getByText(/Ein Beispiel/i)
132+
expect(example).toBeInTheDocument()
133+
134+
const linkElement = within(example).getByRole("link", { name: /link/i })
135+
expect(linkElement).toBeInTheDocument()
126136
})
127137

128138
it("renders notes", () => {
129139
render(<Concept pageContext={ConceptPC} />)
130140

131-
expect(screen.getByText(/Meine Anmerkung/i)).toBeInTheDocument()
141+
const note = screen.getByText(/Meine Anmerkung/i)
142+
expect(note).toBeInTheDocument()
143+
144+
const linkElement = within(note).getByRole("link", { name: /link/i })
145+
expect(linkElement).toBeInTheDocument()
132146

133147
const list = screen.getByRole("list", {
134148
name: "Note",
@@ -141,7 +155,11 @@ describe.concurrent("Concept", () => {
141155
it("renders changeNotes", () => {
142156
render(<Concept pageContext={ConceptPC} />)
143157

144-
expect(screen.getByText(/Meine Change Note/i)).toBeInTheDocument()
158+
const changeNote = screen.getByText(/Meine Change Note/i)
159+
expect(changeNote).toBeInTheDocument()
160+
161+
const linkElement = within(changeNote).getByRole("link", { name: /link/i })
162+
expect(linkElement).toBeInTheDocument()
145163

146164
const list = screen.getByRole("list", {
147165
name: /changenote/i,
@@ -154,7 +172,13 @@ describe.concurrent("Concept", () => {
154172
it("renders editorialNotes", () => {
155173
render(<Concept pageContext={ConceptPC} />)
156174

157-
expect(screen.getByText(/Meine Editorial Note/i)).toBeInTheDocument()
175+
const editorialNote = screen.getByText(/Meine Editorial Note/i)
176+
expect(editorialNote).toBeInTheDocument()
177+
178+
const linkElement = within(editorialNote).getByRole("link", {
179+
name: /link/i,
180+
})
181+
expect(linkElement).toBeInTheDocument()
158182

159183
const list = screen.getByRole("list", {
160184
name: /editorialnote/i,
@@ -167,7 +191,11 @@ describe.concurrent("Concept", () => {
167191
it("renders historyNotes", () => {
168192
render(<Concept pageContext={ConceptPC} />)
169193

170-
expect(screen.getByText(/Meine History Note/i)).toBeInTheDocument()
194+
const historyNote = screen.getByText(/Meine History Note/i)
195+
expect(historyNote).toBeInTheDocument()
196+
197+
const linkElement = within(historyNote).getByRole("link", { name: /link/i })
198+
expect(linkElement).toBeInTheDocument()
171199

172200
const list = screen.getByRole("list", {
173201
name: /historynote/i,
@@ -180,7 +208,11 @@ describe.concurrent("Concept", () => {
180208
it("renders scopeNotes", () => {
181209
render(<Concept pageContext={ConceptPC} />)
182210

183-
expect(screen.getByText(/Meine Scope Note/i)).toBeInTheDocument()
211+
const scopeNote = screen.getByText(/Meine Scope Note/i)
212+
expect(scopeNote).toBeInTheDocument()
213+
214+
const linkElement = within(scopeNote).getByRole("link", { name: /link/i })
215+
expect(linkElement).toBeInTheDocument()
184216

185217
const list = screen.getByRole("list", {
186218
name: /scopenote/i,

test/data/pageContext.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,31 @@ export const topConcept = {
4444
de: ["Verstecktes Label 1", "Verstecktes Label 2"],
4545
},
4646
definition: {
47-
de: "Meine Definition",
47+
de: "Meine Definition [Link](https://w3c.org)",
4848
},
4949
example: {
50-
de: "Ein Beispiel",
50+
de: "Ein Beispiel [Link](https://w3c.org)",
5151
},
5252
note: {
53-
de: ["Meine Anmerkung", "Noch eine Anmerkung"],
53+
de: ["Meine Anmerkung mit [Link](https://w3c.org)", "Noch eine Anmerkung"],
5454
},
5555
changeNote: {
56-
de: ["Meine Change Note", "Noch eine Change Note"],
56+
de: ["Meine Change Note [Link](https://w3c.org)", "Noch eine Change Note"],
5757
},
5858
editorialNote: {
59-
de: ["Meine Editorial Note", "Noch eine Editorial Note"],
59+
de: [
60+
"Meine Editorial Note [Link](https://w3c.org)",
61+
"Noch eine Editorial Note",
62+
],
6063
},
6164
historyNote: {
62-
de: ["Meine History Note", "Noch eine History Note"],
65+
de: [
66+
"Meine History Note [Link](https://w3c.org)",
67+
"Noch eine History Note",
68+
],
6369
},
6470
scopeNote: {
65-
de: ["Meine Scope Note", "Noch eine Scope Note"],
71+
de: ["Meine Scope Note [Link](https://w3c.org)", "Noch eine Scope Note"],
6672
},
6773
notation: ["1"],
6874
narrower: [concept2],

0 commit comments

Comments
 (0)