Skip to content

Commit

Permalink
Correct visual styles for images with captions
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Mar 25, 2024
1 parent be168ad commit 4a23b07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/components/markdown.tsx
Expand Up @@ -19,14 +19,14 @@ renderer.code = function (code, lang, escaped) {

// add captions to images
renderer.image = function (href, title, text) {
const html = `<figure><img src="${href}" title="${title}" alt="${text}" /></figure>`;
const html = `<img src="${href}" title="${title}" alt="${text}" />`;
if (title) {
return `<figure>
return `<figure class="not-prose markdown-image">
${html}
<figcaption>${title}</figcaption>
</figure>`;
}
return html;
return `<figure class="not-prose markdown-image">${html}</figure>`;
};

const parseMarkdown = (content: string, options = {}): string => {
Expand Down
12 changes: 12 additions & 0 deletions app/styles/index.css
Expand Up @@ -235,3 +235,15 @@ label select {
@apply pr-0;
}
}

.prose figure.markdown-image {
@apply flex items-center flex-col my-8;
}

.prose figure.markdown-image > img {
@apply mb-0;
}

.prose figure.markdown-image > figcaption {
@apply text-secondary-light dark:text-secondary-dark text-xs mt-0 text-center;
}

0 comments on commit 4a23b07

Please sign in to comment.