cozy / cozy-libs

Libraries used to build Cozy products and tools.
MIT License
7 stars 12 forks source link

Snarkdown #759

Open ptbrowne opened 5 years ago

ptbrowne commented 5 years ago

https://github.com/cozy/cozy-libs/pull/758

I wanted to use it also in harvest, but we can't since we've a custom renderers.

I wanted to know what kind of renderers we use and why ? And explore what could we do not to use them ?

Crash-- commented 5 years ago

You can find our custom renderers here: https://github.com/cozy/cozy-libs/blob/master/packages/cozy-harvest-lib/src/components/Markdown.jsx

We use it specially for styling purpose but also for referrer.

This is something we can't do with snarkdown. It seems that te recommended way is to pipe the result of snarkdown and make the transformation ourself (https://github.com/developit/snarkdown/issues/5#issuecomment-282924371)

ptbrowne commented 5 years ago

It seems that te recommended way is to pipe the result of snarkdown and make the transformation ourself.

I'd be OK with that.

We could also do :

const snarkWithNoReferer = content => {
   const div = createElement('div')
  div.innerHTML = snarkdown(content)
  div.querySelectorAll('a').forEach(a => a.setAttribute('noreferer', true))
  return div.innerHTML
}

This way we do not have to deal with regexps.