Sha256: dae7279ef3fd513387fbc38ee323c90dd7ab1d8fb33abbceab2ddbe8d3905482

Contents?: true

Size: 770 Bytes

Versions: 179

Compression:

Stored size: 770 Bytes

Contents

<script>
  promethee.filter('textContentFromHTML', function() {
    return function(val) {
      if (val === undefined) return ''
      // Inner text has a problem with some whitespace/linebreak missing (at least h1, h2...)
      // We fix it by adding whitespaces before each closing tag.
      var valWithSpaces = val.split('</').join(' </');
      // Create a blank div (supposed to be garbage collected afterwards)
      var element = document.createElement('div');
      // Add value as html
      element.innerHTML = valWithSpaces;
      // Use textContent or innerText to convert to plain text
      // http://perfectionkills.com/the-poor-misunderstood-innerText/
      var text = element.textContent || element.innerText
      return text;
    }
  });
</script>

Version data entries

179 entries across 179 versions & 1 rubygems

Version Path
promethee-5.1.1 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-5.1.0 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-5.0.2 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-5.0.1 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-5.0.0 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.28 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.27 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.26 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.25 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.24 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.23 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.22 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.21 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.20 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.19 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.18 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.17 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.16 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.15 app/views/promethee/utils/_text-content-from-html.html.erb
promethee-4.1.14 app/views/promethee/utils/_text-content-from-html.html.erb