<commit_before>'use strict';

var hexoUtil = require('hexo-util');
var imgUrl = hexo.config.imgurl;


/**
 * Imgurl tag
 * 
 * Syntax:
 * ```
 * {% imgurl imagePath [class1,class2,classN] imgAttr %}
 * ```
 */

hexo.extend.tag.register('imgurl', function(args){
  var imagePath = args[0];
  var classes = args[1] || "";
  var imgAttr = {};

  for (var i = 2; i < args.length; i++) {
    var item = args[i];
    if(item[0] === '\'' || item[0] === '"') {
      item = item.substring(1, item.length - 1);
    }

    var parseAttr = item.split(':');
    imgAttr[parseAttr[0]] = parseAttr[1];
  }

  classes = classes.split(',');
  imgAttr.class = classes.join(' ');
  imgAttr.src = "//" + imgUrl + "/" + imagePath;


  return hexoUtil.htmlTag('img', imgAttr);
  
});<commit_msg>Detects the order of tag elements when rendering<commit_after>'use strict';

var hexoUtil = require('hexo-util');
var imgUrl = hexo.config.imgurl;
var rImgAttr = /[\:]+/;
var rClasses = /[\,]+/;

/**
 * Imgurl tag
 * 
 * Syntax:
 * ```
 * {% imgurl imagePath [class1,class2,classN] imgAttr %}
 * ```
 */

hexo.extend.tag.register('imgurl', function(args){
  // var imagePath = args[0];
  var imgAttr = {};

  for (var i = 0; i < args.length; i++) {
    var item = args[i];

    if (rImgAttr.test(item)) {

      if (item[0] === '\'' || item[0] === '"') {
        item = item.substring(1, item.length - 1);
      }

      var parseAttr = item.split(':');

      imgAttr[parseAttr[0]] = parseAttr[1];
      } else if (rClasses.test(item)) {
        imgAttr.class = item.split(',').join(' ');
      } else {
        imgAttr.src = "//" + imgUrl + "/" + item;
      }
  }

  return hexoUtil.htmlTag('img', imgAttr);

});
{'fraction_non_alphanumeric': 0.216696269982238, 'fraction_numerical': 0.012433392539964476, 'mean_word_length': 2.81489841986456, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3029489', 'n_tokens_mistral': 646, 'n_tokens_neox': 628, 'n_words': 125}