Skip to content

Commit

Permalink
fix asciidocFormatter as it now supports fontawesome properly (adopti…
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams authored Sep 20, 2023
1 parent 32c926b commit 38e557e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/__fixtures__/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const createAsciidocData = (): {
}</code></pre>
<table><thead><td>Header 1</td><td>Header 2</td></thead><tbody><tr><td>Cell 1</td><td class="icon">Cell 2</td></tr></tbody></table>
<a href="https://www.eclipse.org">Eclipse</a>
<span class="icon">[docker]</span>
<span class="icon">[check]</span>
<i class="fa fa-docker"></i>
<i class="fa fa-check"></i>
<div class="toc">
<ul class="sectlevel1">
<li><a href="#section-1">Section 1</a></li>
Expand Down
18 changes: 5 additions & 13 deletions src/util/asciidocFormatter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,11 @@ export default function asciidocFormatter (t /* 't' from useI18next to retrieve
link.append(anchorIcon)
}
})
// Hack to get fontawesome to render correctly
const spans = document.querySelectorAll('span')
spans.forEach(span => {
if (span.className === 'icon') {
const iconName = span.innerHTML.substring(1, span.innerHTML.length - 1)
let iconClass = 'fa'
if (iconName === 'docker') {
iconClass = 'fab'
}
const archiveTypeIcon = document.createElement('i')
archiveTypeIcon.className = `${iconClass} fa-${iconName}`
archiveTypeIcon.ariaHidden = true
span.replaceWith(archiveTypeIcon)
// Look for i class="fa fa-docker" and replace with fab fa-docker
const icons = asciidocContent.querySelectorAll('i')
icons.forEach(icon => {
if (icon.className.includes('fa-docker')) {
icon.className = icon.className.replace('fa', 'fab')
}
})
const tds = document.querySelectorAll('td')
Expand Down

0 comments on commit 38e557e

Please sign in to comment.