cvlist.getList().then(function (list) {
                var resultWebsite = list[website.url.hostname.replace('-', '_').replace('www.', '')];
                if (resultWebsite && (resultWebsite.noFlash || (resultWebsite.featureSwitch && resultWebsite.featureSwitch === "requiresActiveX:true"))) {
                    test.passed = false;
                    test.data = {activex: !resultWebsite.noFlash , cvlist: true};
                } else {
                    var $objects = website.$('object'),
                        $embeds = website.$('embed'),
                        $objectParams = website.$('object param[value*=swf]'),
                        $objectSWFparams = website.$('object[data*=swf]'),
                        $objectSVGparams = website.$('object[data*=svg]'),
                        $embedsSWF = website.$('embed[src*=swf]'),
                        $embedsSVG = website.$('embed[src*=svg]');

                    var activeXcontrols = $objects.length - $objectParams.length - $objectSWFparams.length - $objectSVGparams.length + $embeds.length - $embedsSWF.length - $embedsSVG.length;
                    if (activeXcontrols > 0) {
                        var endPoint, lines,
                            objectsToRemove = $objectParams.toArray().concat($objectSWFparams.toArray(), $objectSVGparams.toArray()),
                            embedsToRemove = $embedsSWF.toArray().concat($embedsSVG.toArray()),
                            uniqueObjects = removeItems($objects, objectsToRemove),
                            uniqueEmbeds = removeItems($embeds, embedsToRemove),
                            objectHtml = $.html($(uniqueObjects[0])),
                            embedHtml = $.html($(uniqueEmbeds[0])),
                            objectRegex = new RegExp(objectHtml, "gi"),
                            embedRegex = new RegExp(embedHtml, "gi"),
                            matches;

                        if (objectHtml !== "") {
                            matches = objectRegex.exec(website.content);
                            if (matches && matches.length > 0) {
                                endPoint = website.content.indexOf(matches[0]);
                            }
                        } else {
                            if (embedHtml !== "") {
                                matches = embedRegex.exec(website.content);
                                if (matches && matches.length > 0) {
                                    endPoint = website.content.indexOf(matches[0]);
                                }
                            }
                        }

                        lines = website.content.substr(0, endPoint)
                            .split('\n').length;

                        test.passed = false;
                        test.data = {activex: true, cvlist: false, lineNumber: lines};
                    }
                }

                deferred.resolve(test);
            },
	it('should render inline code with escaping', () => {
		const markdown = 'Foo `<bar>` baz';

		const actual = render(<Markdown text={markdown} />);

		expect(html(actual)).toMatchSnapshot();
	});
	it('should render links', () => {
		const markdown = 'a [link](http://test.com)';

		const actual = render(<Markdown text={markdown} />);

		expect(html(actual)).toMatchSnapshot();
	});
Beispiel #4
0
 deserialize: (el, next) => {
     if (el.type !== 'text')
         console.log(
             '** no deserializer for: ',
             $.html(el).replace(/\n/g, '\\n')
         );
 },
Beispiel #5
0
stencil.prototype.fillStencil = function(stencil, root, vars)
{
	var objFilledStencil = fillRecurse(this.stencils[stencil].$, root, Object.prototype.toString.call(root), root, vars);
	
	objFilledStencil.html = this.stencils[stencil].$.html;
	
	return cheerio.html(objFilledStencil, {decodeEntities: false});
}
	it('should render code blocks without escaping', () => {
		const markdown = `
\`\`\`html
<foo></foo>
\`\`\`
`;
		const actual = render(<Markdown text={markdown} />);

		expect(html(actual)).toMatchSnapshot();
	});
	it('should render check-lists correctly', () => {
		const markdown = `
* [ ] list 1
* [ ] list 2
* [x] list 3
`;
		const actual = render(<Markdown text={markdown} />);

		expect(html(actual)).toMatchSnapshot();
	});
	it('should render ordered lists correctly', () => {
		const markdown = `
1. list
1. item
1. three
`;
		const actual = render(<Markdown text={markdown} />);

		expect(html(actual)).toMatchSnapshot();
	});
	it('should render Markdown with custom CSS classes', () => {
		const markdown = `
# Header

Text with *some* **formatting** and a [link](/foo).

![Image](/bar.png)`;
		const actual = render(<Markdown text={markdown} />);

		expect(html(actual)).toMatchSnapshot();
	});
Beispiel #10
0
  center: function (element) {
    if (element.children().length > 0) {
      element.children().each(function() {
        $(this).attr('align', 'center');
        $(this).addClass('float-center');
      });
      element.find('item, .menu-item').addClass('float-center');
    }

    element.attr('data-parsed', '');

    return format('%s', $.html(element));
  },
	it('should render mixed nested lists correctly', () => {
		const markdown = `
* list 1
* list 2
  1. Sub-list
  1. Sub-list
  1. Sub-list
* list 3
`;
		const actual = render(<Markdown text={markdown} />);

		expect(html(actual)).toMatchSnapshot();
	});
	it('should render headings correctly', () => {
		const markdown = `
# one
## two
### three
#### four
##### five
###### six
`;
		const actual = render(<Markdown text={markdown} />);

		expect(html(actual)).toMatchSnapshot();
	});
Beispiel #13
0
    function translate(_head, _tail) {
        var result = re.exec(_tail)
        if(result === null) {
            return _head.concat(_tail);
        }
        
        var start = result.index;
        var len = result[0].length;
        var end = start + len;

        var head = _head.concat(_tail.slice(0, start));
        var tail = _tail.slice(end);
        var $tag = $(_tail.slice(start, end));

        var key = $tag.attr('data-l10n');
        $tag.html(selectn(key, bundle));
        if (opts.stripDataAttributes) $tag.removeAttr('data-l10n');

        return translate(head.concat($.html($tag)), tail);
    }
Beispiel #14
0
        files.forEach(function (file, index) {
          // load file contents
          var contents = String(grunt.file.read(file, 'utf-8'));
          $ = cheerio.load(contents);
          // iterate over content nodes to find the correct script tags
          $('script').each(function (idx, elm) {

            // check for require js like script tags
            if ($(elm)[0].name.toLowerCase() === 'script' && $(elm)[0].attribs && $(elm)[0].attribs['data-main']) {
              // replace the attributes of requires script tag
              // with the 'almonded' version of the module
              var insertScript = _.isUndefined(entry.modulePath) !== true ? entry.modulePath : $(elm).attr('data-main');
              $(elm).attr('src', insertScript + '.js').removeAttr('data-main');
            }

          });

          // write out newly created file contents
          grunt.file.write(file, $.html(), 'utf-8');
        });
module.exports = function(element) {
  var inner = element.html();

  switch (element[0].name) {
    // <column>
    case this.components.columns:
      return this.makeColumn(element, 'columns');

    // <row>
    case this.components.row:
      var classes = ['row'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }

      return format('<table class="%s"><tbody><tr>%s</tr></tbody></table>', classes.join(' '), inner);

    // <button>
    case this.components.button:
      var expander = '';

      // Prepare optional target attribute for the <a> element
      var target = '';
      if (element.attr('target')) {
        target = ' target=' + element.attr('target');
      }

      // If we have the href attribute we can create an anchor for the inner of the button;
      if (element.attr('href')) {
        inner = format('<a href="%s"%s>%s</a>', element.attr('href'), target, inner);
      }

      // If the button is expanded, it needs a <center> tag around the content
      if (element.hasClass('expand') || element.hasClass('expanded')) {
        inner = format('<center>%s</center>', inner);
        expander = '\n<td class="expander"></td>';
      }

      // The .button class is always there, along with any others on the <button> element
      var classes = ['button'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }

      return format('<table class="%s"><tr><td><table><tr><td>%s</td></tr></table></td>%s</tr></table>', classes.join(' '), inner, expander);

    // <container>
    case this.components.container:
      var classes = ['container'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }

      return format('<table class="%s"><tbody><tr><td>%s</td></tr></tbody></table>', classes.join(' '), inner);

    // <inky>
    case this.components.inky:
      return '<tr><td><img src="https://raw.githubusercontent.com/arvida/emoji-cheat-sheet.com/master/public/graphics/emojis/octopus.png" /></tr></td>';

    // <block-grid>
    case this.components.blockGrid:
      var classes = ['block-grid', 'up-'+element.attr('up')];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }
      return format('<table class="%s"><tr>%s</tr></table>', classes.join(' '), inner);

    // <menu>
    case this.components.menu:
      var classes = ['menu'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }
      var centerAttr = element.attr('align') ? 'align="center"' : '';
      return format('<table class="%s"%s><tr><td><table><tr>%s</tr></table></td></tr></table>', classes.join(' '), centerAttr, inner);

    // <item>
    case this.components.menuItem:
      var classes = ['menu-item'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }
      return format('<th class="%s"><a href="%s">%s</a></th>', classes.join(' '), element.attr('href'), inner);

    // <center>
    case this.components.center:
      if (element.children().length > 0) {
        element.children().each(function() {
          $(this).attr('align', 'center');
          $(this).addClass('float-center');
        });
        element.find('item, .menu-item').addClass('float-center');
      }

      element.attr('data-parsed', '');

      return format('%s', $.html(element));

    // <callout>
    case this.components.callout:
      var classes = ['callout-inner'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }

      return format('<table class="callout"><tr><th class="%s">%s</th><th class="expander"></th></tr></table>', classes.join(' '), inner);

    // <spacer>
    case this.components.spacer:
      var classes = ['spacer'];
      var size = 16;
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }
      if (element.attr('size')) {
        size = (element.attr('size'));
      }

      return format('<table class="%s"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&#xA0;</td></tr></tbody></table>', classes.join(' '), inner);

    // <wrapper>
    case this.components.wrapper:
      var classes = ['wrapper'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }

      return format('<table class="%s" align="center"><tr><td class="wrapper-inner">%s</td></tr></table>', classes.join(' '), inner);

    default:
      // If it's not a custom component, return it as-is
      return format('<tr><td>%s</td></tr>', $.html(element));
  }
}
	it('should render a heading', () => {
		const actual = render(<Heading level={2}>The heading</Heading>);

		expect(html(actual)).toMatchSnapshot();
	});
Beispiel #17
0
module.exports = function(element) {
  var inner = element.html();

  switch (element[0].name) {
    // <column>
    case this.components.columns:
      return this.makeColumn(element, 'columns');

    // <row>
    case this.components.row:
      var classes = ['row'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }

      return format('<table class="%s"><tbody><tr>%s</tr></tbody></table>', classes.join(' '), inner);

    // <button>
    case this.components.button:
      // If we have the href attribute we can create an anchor for the inner of the button;
      if (element.attr('href')) {
        inner = format('<a href="%s">%s</a>', element.attr('href'), inner);
      }

      // If the button is expanded, it needs a <center> tag around the content
      if (element.hasClass('expand')) {
        inner = format('<center>%s</center>', inner);
      }

      // The .button class is always there, along with any others on the <button> element
      var classes = ['button'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }

      return format('<table class="%s"><tr><td><table><tr><td>%s</td></tr></table></td></tr></table>', classes.join(' '), inner);

    // <container>
    case this.components.container:
      var classes = ['container'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }

      return format('<table class="%s"><tbody><tr><td>%s</td></tr></tbody></table>', classes.join(' '), inner);

    // <inky>
    case this.components.inky:
      return '<tr><td><img src="https://raw.githubusercontent.com/arvida/emoji-cheat-sheet.com/master/public/graphics/emojis/octopus.png" /></tr></td>';

    // <block-grid>
    case this.components.blockGrid:
      var classes = ['block-grid', 'up-'+element.attr('up')];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }
      return format('<table class="%s"><tr>%s</tr></table>', classes.join(' '), inner);

    // <menu>
    case this.components.menu:
      var classes = ['menu'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
        if (classes.indexOf('vertical') !== -1) {
          element.children().attr('data-vertical', '1');
          // In vertical case to support outlook, we'll do an inner table.
          // However, we DON'T do this for small-vertical because outlook never shows the small version
          return format('<table class="%s"><tr><th>%s</th></tr></table>', classes.join(' '), element.html());
        }
      }
      return format('<table class="%s"><tr>%s</tr></table>', classes.join(' '), inner);

    // <item>
    case this.components.menuItem:
      if (element.attr('data-vertical')) {
        return format('<table class="menu-item"><tr><th><a href="%s">%s</a></th></tr></table>', element.attr('href'), inner);
      } else {
        return format('<th><a href="%s">%s</a></th>', element.attr('href'), inner);
      }

    // <center>
    case this.components.center:
      if (element.children().length > 0) {
        element.children()
          .attr('align', 'center')
          .addClass('text-center');
      }

      element.attr('data-parsed', '');

      return format('%s', $.html(element));

    // <callout>
    case this.components.callout:
      var classes = ['callout'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }

      return format('<table><tr><th class="%s">%s</th></tr></table>', classes.join(' '), inner);

    default:
      // If it's not a custom component, return it as-is
      return format('<tr><td>%s</td></tr>', $.html(element));
  }
}
Beispiel #18
0
 template: function(contents, el) {
   el.attr('src', 'data:image/unknown;base64,' + contents.toString('base64'));
   return cheerio.html(el);
 },
Beispiel #19
0
			currentVw.render().promise().then(function () {
				html = $.html(currentVw.$el);
				resp.render('layout', { body: html })
			});
Beispiel #20
0
import collectAllPages from 'extractors/collect-all-pages';

const Mercury = {
  async parse(url, { html, ...opts } = {}) {
    const {
      fetchAllPages = true,
      fallback = true,
      contentType = 'html',
    } = opts;

    // if no url was passed and this is the browser version,
    // set url to window.location.href and load the html
    // from the current page
    if (!url && cheerio.browser) {
      url = window.location.href; // eslint-disable-line no-undef
      html = html || cheerio.html();
    }

    const parsedUrl = URL.parse(url);

    if (!validateUrl(parsedUrl)) {
      return Errors.badUrl;
    }

    const $ = await Resource.create(url, html, parsedUrl);

    // If we found an error creating the resource, return that error
    if ($.failed) {
      return $;
    }
Beispiel #21
0
 function present(view) {
   res.write(cheerio.html(view.render().$el))
 }
	it('should render Markdown in span in inline mode', () => {
		const markdown = 'Hello *world*!';
		const actual = render(<Markdown text={markdown} inline />);

		expect(html(actual)).toMatchSnapshot();
	});