Skip to content

Commit b35e7ce

Browse files
authored
Interprête le contenu des champs textarea comme du markdown (#227)
* parse error description and recommendation markdown into html * parse notCompliantContent, derogatedContent and notInScopeContent markdown to html * fix marked config * update changelog
1 parent b413321 commit b35e7ce

5 files changed

Lines changed: 55 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@
22

33
Tous les changements notables de Ara sont documentés ici avec leur date, leur catégorie (nouvelle fonctionnalité, correction de bug ou autre changement) et leur pull request (PR) associée.
44

5+
## 12/12/2022
6+
7+
### Nouvelles fonctionnalités 🚀
8+
9+
- Formate les éléments suivant dans le rapport avec Markdown ([#227](https://github.com/DISIC/Ara/pull/227)) :
10+
- Description d'une erreur de conformité
11+
- Recommandation sur un critère
12+
- Non-conformités
13+
- Contenu dérogé
14+
- Contenus non soumis à l’obligation d’accessibilité
15+
516
## 30/11/2022
617

718
### Nouvelles fonctionnalités 🚀
19+
820
- Ajout d’une mise en avant pour notifier le caractère obligatoire de la déclaration d’accessibilité ([#206](https://github.com/DISIC/Ara/pull/206))
21+
922
### Autres changements ⚙️
1023

1124
- Ajout du changelog ([#207](https://github.com/DISIC/Ara/pull/207))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script lang="ts" setup>
2+
import { marked } from "marked";
3+
import { computed } from "vue";
4+
5+
const props = defineProps<{
6+
markdown: string;
7+
}>();
8+
9+
const html = computed(() => marked.parse(props.markdown));
10+
</script>
11+
12+
<template>
13+
<div v-html="html"></div>
14+
</template>

confiture-web-app/src/components/ReportA11yStatement.vue

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useRoute } from "vue-router";
55
import { useWrappedFetch } from "../composables/useWrappedFetch";
66
import { useReportStore } from "../store";
77
import { formatDate } from "../utils";
8+
import MarkdownRenderer from "./MarkdownRenderer.vue";
89
910
const report = useReportStore();
1011
@@ -204,16 +205,24 @@ function hideCopyAlert() {
204205
</li>
205206
</ul-->
206207
<h4 class="fr-h2 fr-mb-2w fr-mb-md-3w">Contenus non accessibles</h4>
208+
207209
<h5 class="fr-h3">Non-conformités</h5>
208-
<p class="fr-mb-2w fr-mb-md-3w">
209-
{{ report.data.notCompliantContent }}
210-
</p>
210+
<MarkdownRenderer
211+
class="fr-mb-2w fr-mb-md-3w"
212+
:markdown="report.data.notCompliantContent"
213+
/>
211214

212215
<h5 class="fr-h3">Dérogations pour charge disproportionnée</h5>
213-
<p class="fr-mb-2w fr-mb-md-3w">{{ report.data.derogatedContent }}</p>
216+
<MarkdownRenderer
217+
class="fr-mb-2w fr-mb-md-3w"
218+
:markdown="report.data.derogatedContent"
219+
/>
214220

215221
<h5 class="fr-h3">Contenus non soumis à l’obligation d’accessibilité</h5>
216-
<p class="fr-mb-2w fr-mb-md-3w">{{ report.data.notInScopeContent }}</p>
222+
<MarkdownRenderer
223+
class="fr-mb-2w fr-mb-md-3w"
224+
:markdown="report.data.notInScopeContent"
225+
/>
217226

218227
<h4 class="fr-h2">Établissement de cette déclaration d’accessibilité</h4>
219228
<p v-if="report.data.publishDate" class="fr-mb-2w fr-mb-md-3w">

confiture-web-app/src/components/ReportErrors.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { CriterionResultUserImpact, CriteriumResultStatus } from "../types";
1010
import { formatStatus, formatUserImpact, slugify } from "../utils";
1111
import CriteriumTestsAccordion from "./CriteriumTestsAccordion.vue";
1212
import LazyAccordion from "./LazyAccordion.vue";
13+
import MarkdownRenderer from "./MarkdownRenderer.vue";
1314
1415
const report = useReportStore();
1516
const router = useRouter();
@@ -406,9 +407,10 @@ function updateActiveAnchorLink(id: string, event: MouseEvent) {
406407
title="Description de l'erreur"
407408
data-accordion
408409
>
409-
<p class="fr-mb-3w">
410-
{{ error.errorDescription }}
411-
</p>
410+
<MarkdownRenderer
411+
class="fr-mb-3w"
412+
:markdown="error.errorDescription"
413+
/>
412414
<!-- <p class="fr-text--xs fr-mb-1w error-accordion-subtitle">
413415
Exemple(s) d’erreur(s)
414416
</p>
@@ -448,9 +450,10 @@ function updateActiveAnchorLink(id: string, event: MouseEvent) {
448450
title="Recommandation de correction"
449451
data-accordion
450452
>
451-
<p class="fr-mb-0">
452-
{{ error.recommandation }}
453-
</p>
453+
<MarkdownRenderer
454+
class="fr-mb-0"
455+
:markdown="error.recommandation"
456+
/>
454457
</LazyAccordion>
455458

456459
<!-- Tests -->

confiture-web-app/src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ import router from "./router";
1919
// TODO: use a <RouterLink />
2020
const renderer = {
2121
link(href: string, title: string, text: string) {
22-
return `<a href="/ressources/glossaire${href}">${text}</a>`;
22+
if (href.startsWith("#")) {
23+
return `<a href="/ressources/glossaire${href}">${text}</a>`;
24+
} else {
25+
return `<a href="${href}">${text}</a>`;
26+
}
2327
},
2428
};
2529

0 commit comments

Comments
 (0)