diff --git a/webclient/src/Article.js b/webclient/src/Article.js index 78c3a06..e997706 100644 --- a/webclient/src/Article.js +++ b/webclient/src/Article.js @@ -4,6 +4,8 @@ import { Helmet } from 'react-helmet'; import localForage from 'localforage'; import { sourceLink, infoLine, ToggleDot } from './utils.js'; +const VOID_ELEMENTS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; + function Article({ cache }) { const { id } = useParams(); @@ -96,8 +98,20 @@ function Article({ cache }) { ); } + const props = { key: key }; + if (v.hasAttributes()) { + for (const attr of v.attributes) { + const name = attr.name === 'class' ? 'className' : attr.name; + props[name] = attr.value; + } + } + + if (VOID_ELEMENTS.includes(Tag)) { + return ; + } + return ( - + {renderNodes(v.childNodes, `${key}-`)} );