Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/main/java/ui/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ private void updatePreview(String markdown, boolean addToHistory) {

String html = htmlRenderer.render(markdownParser.parse(body));

// ── Checkboxes : convertir [ ] et [x] en éléments checkbox HTML
html = processCheckboxes(html);

// ── Images : injecter les attributs width/height
if (!imageSizes.isEmpty()) {
html = applyImageSizes(html, imageSizes);
Expand Down Expand Up @@ -298,6 +301,11 @@ private void updatePreview(String markdown, boolean addToHistory) {
th, td { border: 1px solid #888; padding: 6px 12px; text-align: left; }
th { background: rgba(128,128,128,0.15); font-weight: bold; }
tr:nth-child(even) { background: rgba(128,128,128,0.06); }
/* Checkboxes (task list) */
input[type="checkbox"] { width: 1.1em; height: 1.1em; margin-right: 0.4em;
vertical-align: middle; cursor: default;
accent-color: #0078d7; }
li:has(input[type="checkbox"]) { list-style: none; margin-left: -1.2em; }
/* Front Matter metadata */
.front-matter { background: rgba(128,128,128,0.08); border: 1px solid rgba(128,128,128,0.25);
border-radius: 6px; padding: 0.6em 1em; margin-bottom: 1.2em;
Expand Down Expand Up @@ -397,6 +405,32 @@ function renderMath(el) {
this.currentHtml = htmlPage;
}

/**
* Convertit les marqueurs de checkbox Markdown ([ ] et [x]) en éléments HTML checkbox.
*
* <p>Patterns reconnus :</p>
* <ul>
* <li>{@code [ ]} → checkbox non cochée</li>
* <li>{@code [x]} ou {@code [X]} → checkbox cochée</li>
* </ul>
*
* @param html le HTML généré par Flexmark
* @return le HTML avec les checkboxes converties
*/
private String processCheckboxes(String html) {
// Remplacer [ ] par une checkbox non cochée
html = html.replaceAll(
"\\[ \\]",
"<input type=\"checkbox\" disabled>"
);
// Remplacer [x] ou [X] par une checkbox cochée
html = html.replaceAll(
"\\[[xX]\\]",
"<input type=\"checkbox\" checked disabled>"
);
return html;
}

/**
* Remplace les blocs {@code <pre><code class="language-plantuml">...}
* par des balises {@code <img>} (serveur en ligne) ou par des placeholders
Expand Down