获取文章的配置参数，在文章头部通过[key]: value 的形式
@param  {String} body 文章内容
[intro]: 文章的介绍文章的介绍文章的介绍
@return {Object}      文章的配置参数
489837
function getPostQuery(body) {
  if (!body) return {};

  let result = {};
  let commentReg = /^\[(\w+)\]\:([\s|\S]+)/;
  body.split('\r\n').every((item) => {
    let itemMatch = item.match(commentReg);
    if (itemMatch && itemMatch.length == 3) {
      let queryKey = itemMatch[1],
        queryVal = itemMatch[2];
      result[queryKey] = queryVal && queryVal.trim();
      return true;
    } else {
      return false;
    }
  })

  return result;
}
847754
function getBodyAsBuffer(body, encoding) {
  return body instanceof Buffer
    ? body
    : Buffer.from(`${body || ''}`, normalizeBodyEncoding(encoding));
}
65463
function(apiKey, templateId, pieceTitle,
        category, fromAddress, toAddress, ccAddress, bccAddresses, subject,
        textBody, htmlBody, contentType, mergeContext) {}
127301
function extract ($, base) {
  const candidates = getCandidates($, base)
  let article = getArticle(candidates, $)
  if (article.length < 1) {
    article = getArticle([$('body')], $)
  }
  return article
}
102403
function convertToObject(sectionString) {

    var sectionObj = {};
    //get the section title(get it raw, clean it)
    var sectionTitleRegExp = /(-){3,}([\S\s]+?)(-){3,}/;
    var sectionRawTitle = sectionString.match(sectionTitleRegExp)[0];
    var sectionTitle = cleanUpTitle(sectionRawTitle).toLowerCase();

    //get the section body
    var sectionBody;
    sectionObj.sectionTitle = sectionTitle;
    //these are very special "edge" cases

    //meta data/information about document in the beginning of the doc
    if (sectionTitle.toLowerCase().indexOf("personal health information") >= 0) {
        delete sectionObj.sectionTitle;
        sectionObj.sectionTitle = 'meta';
        sectionBody = getMetaBody(sectionString);
    } else if (sectionTitle.toLowerCase().indexOf("claim") >= 0) {
        sectionBody = getClaimsBody(sectionString);
    } else {
        sectionBody = getSectionBody(sectionString);
    }
    sectionObj.sectionBody = sectionBody;
    return sectionObj;
}
431721
function(db) {

		function get_documents(data, config, plv8, ERROR, WARNING) {

			function get_document(id) {
				return plv8.execute("SELECT * FROM documents WHERE id = $1 LIMIT 1", [id])[0];
			}

			function get_type(id) {
				return plv8.execute("SELECT * FROM types WHERE id = $1 LIMIT 1", [id])[0];
			}

			function error(msg) {
				plv8.elog(ERROR, msg);
			}

			function warn(msg) {
				plv8.elog(WARNING, msg);
			}

			function is_object(a) {
				return a && (typeof a === 'object');
			}

			function is_array(a) {
				return a && (a instanceof Array);
			}

			function is_string(a) {
				return a && (typeof a === 'string');
			}

			function is_uuid(obj) {
				return /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/.test(obj);
			}

			function get_property_step(last, current) {
				return is_object(last) ? last[current] : undefined;
			}

			/** Get value of property from provided object using a path.
			 * @param obj {object} The object from where to find the value.
			 * @param path {string} The path to the value in object.
			 * @returns {mixed} The value from the object at the end of path or `undefined` if any part is missing.
			 */
			function get_property(obj, path) {
				if(!is_object(obj)) { return error('get_property(obj, ...) not object: '+ obj); }
				if(!is_string(path)) { return error('get_property(..., path) not string: '+ path); }
				return path.split('.').reduce(get_property_step, obj);
			}

			/** Get document by UUID */
			function fetch_object_by_uuid(data, prop, uuid) {
				if(!is_object(data)) { return error('fetch_object_by_uuid(data, ..., ...) not object: '+ data); }
				if(!is_string(prop)) { return error('fetch_object_by_uuid(..., prop, ...) not string: '+ prop); }
				if(!is_uuid(uuid)) { return warn('Property ' + prop + ' was not uuid: ' + uuid); }
				if(data.documents[uuid] === undefined) {
					data.documents[uuid] = get_document(uuid);
				} else {
					return warn('Document already fetched: ' + uuid);
				}
			}

			/* */
			function fetch_object(data, prop) {
				var uuid = get_property(data, prop);
				if(is_array(uuid)) {
					return uuid.forEach(fetch_object_by_uuid.bind(undefined, data, prop));
				}
				return fetch_object_by_uuid(data, prop, uuid);
			}

			// Check for bad input

			if(!is_object(data)) { return error("get_documents(data, ...) not object"); }
			if(!is_array(config)) { return error("get_documents(..., config) not array"); }

			//var types_id = data.types_id;
			//if(!is_uuid(types_id)) { return error("data.types_id not valid UUID: " + types_id); }

			// Get document type
			//var type = get_type(types_id);
			//if(!is_object(type)) { return error("type not valid object: " + type); }

			//var relations = type.relations || {};
			//if(!is_object(relations)) { return error("type.relations not valid object: " + relations); }

			// Populate documents from `config`
			data.documents = {};
			config.forEach( fetch_object.bind(undefined, data) );
			return data.documents;
		}

		return db.query('CREATE OR REPLACE FUNCTION get_documents(data json, config json) RETURNS json LANGUAGE plv8 VOLATILE AS ' + NoPg._escapeFunction(get_documents, ["data", "config", "plv8", "ERROR", "WARNING"]));
	}
564309
function processBody(opts, body) {
  if (body === undefined) {
    return '';
  }
  const handlers = Object.assign({}, serializers, opts.serializers);
  const headers = typeof opts.headers === 'object' ? opts.headers : {};
  const contentType = Object.keys(headers).reduce((type, header) => {
    if (typeof type === 'string') {
      return type;
    }
    if (
      header.match(/^content-type$/i) &&
      typeof headers[header] === 'string'
    ) {
      return headers[header].toLowerCase();
    }
    return type;
  }, undefined);

  const handler = handlers[contentType];

  if (typeof handler === 'function') {
    return String(handler(body));
  }
  if (typeof body === 'object') {
    return JSON.stringify(body);
  }
  return String(body);
}
374171
String getBody(Object object, ContentType contentType) {
        if (contentType == ContentType.APPLICATION_FORM_URLENCODED) {
            return jsonToUrlEncodedString((JsonObject) new JsonParser().parse(gson.toJson(object)));
        }

        return gson.toJson(object);
    }
252363
public static Map<String, Object> bodyOfSelectedRevision(Document doc) {
        byte[] body;
        try {
            body = doc.getSelectedBody();
        } catch (ForestException e) {
            return null;
        }
        Map<String, Object> properties = null;
        if (body != null && body.length > 0) {
            try {
                properties = Manager.getObjectMapper().readValue(body, Map.class);
            } catch (IOException e) {
                Log.w(TAG, "Failed to parse body: [%s]", new String(body));
            }
        }
        return properties;
    }
550901
function xmlbodyparser(req, res, next) {

    var data = '';

    var parser = new xml2js.Parser(parserOptions);

    /**
     * @param {Error} err
     * @param {Object} [xml]
     */

    var responseHandler = function (err, xml) {
        if (err) {
          err.status = 400;
          return next(err);
        }

        req.body = xml || req.body;
        req.rawBody = data;
        next();
    };

    if (req._body) {
      return next();
    }

    req.body = req.body || {};

    if (!hasBody(req) || !module.exports.regexp.test(mime(req))) {
      return next();
    }

    req._body = true;

    // explicitly cast incoming to string
    req.setEncoding('utf-8');
    req.on('data', function (chunk) {
      data += chunk;
    });

    // in case `parseString` callback never was called, ensure response is sent
    parser.saxParser.onend = function() {
      if (req.complete && req.rawBody === undefined) {
        return responseHandler(null);
      }
    };

    req.on('end', function () {

      // invalid xml, length required
      if (data.trim().length === 0) {
        return next(error(411));
      }

      parser.parseString(data, responseHandler);

    });
  }
310317
def parse_post(self, response):
        '''
        
        '''
        content = json.loads(response.body.decode(), encoding='UTF-8')
        post = response.meta['post']

        post['origin_url'] = content.get('share_url', '')
        if not all([post['origin_url']]):
            raise ValueError('原文地址为空')

        post['title'] = html.escape(content.get('title', ''))
        if not all([post['title']]):
            raise ValueError('文章标题为空 - {}'.format(post.get('origin_url')))

        # 单独处理type字段为1的情况，即该文章为站外转发文章
        if content.get('type') == 1:
            self.logger.warn('遇到站外文章，单独处理 - {}'.format(post['title']))
            return post

        soup = BeautifulSoup(content.get('body', ''), 'lxml')
        author_obj = soup.select('span.author')
        self.logger.debug(author_obj)
        if author_obj:
            author_list = []
            for author in author_obj:
                author_list.append(
                    author.string.rstrip('，, ').replace('，', ','))
            author_list = list(set(author_list))
            post['author'] = html.escape('，'.join(author_list))
        post['content'] = str(soup.div)

        # 继续填充post数据
        image_back = content.get('images', [None])[0]
        if image_back:
            post['meta']['moear.cover_image_slug'] = \
                content.get('image', image_back)
        self.logger.debug(post)
102993
function getDocObject(dir, info) {
  const markdown = getReadmeText(dir);
  const html = marked(markdown);
  const cleanedHTML = prepareHTML(html, info);
  return { pkg: dir, html: cleanedHTML };
}
693145
function parseBODYSTRUCTURE(node, path = []) {
  let curNode = {};
  let i = 0;
  let part = 0;

  if (path.length) {
    curNode.part = path.join('.');
  }

  // multipart
  if (Array.isArray(node[0])) {
    curNode.childNodes = [];
    while (Array.isArray(node[i])) {
      curNode.childNodes.push(parseBODYSTRUCTURE(node[i], path.concat(++part)));
      i++;
    }

    // multipart type
    curNode.type = 'multipart/' + ((node[i++] || {}).value || '').toString().toLowerCase();

    // extension data (not available for BODY requests)

    // body parameter parenthesized list
    if (i < node.length - 1) {
      if (node[i]) {
        curNode.parameters = attributesToObject(node[i]);
      }
      i++;
    }
  } else {
    // content type
    curNode.type = [((node[i++] || {}).value || '').toString().toLowerCase(), ((node[i++] || {}).value || '').toString().toLowerCase()].join('/');

    // body parameter parenthesized list
    if (node[i]) {
      curNode.parameters = attributesToObject(node[i]);
    }
    i++;

    // id
    if (node[i]) {
      curNode.id = ((node[i] || {}).value || '').toString();
    }
    i++;

    // description
    if (node[i]) {
      curNode.description = ((node[i] || {}).value || '').toString();
    }
    i++;

    // encoding
    if (node[i]) {
      curNode.encoding = ((node[i] || {}).value || '').toString().toLowerCase();
    }
    i++;

    // size
    if (node[i]) {
      curNode.size = Number((node[i] || {}).value || 0) || 0;
    }
    i++;

    if (curNode.type === 'message/rfc822') {
      // message/rfc adds additional envelope, bodystructure and line count values

      // envelope
      if (node[i]) {
        curNode.envelope = parseENVELOPE([].concat(node[i] || []));
      }
      i++;

      if (node[i]) {
        curNode.childNodes = [
        // rfc822 bodyparts share the same path, difference is between MIME and HEADER
        // path.MIME returns message/rfc822 header
        // path.HEADER returns inlined message header
        parseBODYSTRUCTURE(node[i], path)];
      }
      i++;

      // line count
      if (node[i]) {
        curNode.lineCount = Number((node[i] || {}).value || 0) || 0;
      }
      i++;
    } else if (/^text\//.test(curNode.type)) {
      // text/* adds additional line count values

      // line count
      if (node[i]) {
        curNode.lineCount = Number((node[i] || {}).value || 0) || 0;
      }
      i++;
    }

    // extension data (not available for BODY requests)

    // md5
    if (i < node.length - 1) {
      if (node[i]) {
        curNode.md5 = ((node[i] || {}).value || '').toString().toLowerCase();
      }
      i++;
    }
  }

  // the following are shared extension values (for both multipart and non-multipart parts)
  // not available for BODY requests

  // body disposition
  if (i < node.length - 1) {
    if (Array.isArray(node[i]) && node[i].length) {
      curNode.disposition = ((node[i][0] || {}).value || '').toString().toLowerCase();
      if (Array.isArray(node[i][1])) {
        curNode.dispositionParameters = attributesToObject(node[i][1]);
      }
    }
    i++;
  }

  // body language
  if (i < node.length - 1) {
    if (node[i]) {
      curNode.language = [].concat(node[i]).map(val => (0, _ramda.propOr)('', 'value', val).toLowerCase());
    }
    i++;
  }

  // body location
  // NB! defined as a "string list" in RFC3501 but replaced in errata document with "string"
  // Errata: http://www.rfc-editor.org/errata_search.php?rfc=3501
  if (i < node.length - 1) {
    if (node[i]) {
      curNode.location = ((node[i] || {}).value || '').toString();
    }
    i++;
  }

  return curNode;
}
956968
public org.w3c.dom.Node getMessageBody(Object rawData, boolean bReturnCopy)
    {
        if (this.getRawData() instanceof String)
        {   // Always
            String strXML = this.getXML();
            return Utility.convertXMLToDOM(strXML);
        }
        return super.getMessageBody(rawData, bReturnCopy);
    }
39179
function parseBodyParam (req, res, next) {
  let params = getParams(req);

  params.some((param) => {
    if (param.in === "body") {
      util.debug('    Parsing the "%s" body parameter', param.name);

      if (_.isPlainObject(req.body) && _.isEmpty(req.body)) {
        if (param.type === "string" || (param.schema && param.schema.type === "string")) {
          // Convert {} to ""
          req.body = "";
        }
        else {
          // Convert {} to undefined
          req.body = undefined;
        }
      }

      // Parse the body
      req.body = parseParameter(param, req.body, param.schema);

      // There can only be one "body" parameter, so skip the rest
      return true;
    }
  });

  // If there are no body/formData parameters, then reset `req.body` to undefined
  if (params.length > 0) {
    let hasBody = params.some((param) => {
      return param.in === "body" || param.in === "formData";
    });

    if (!hasBody) {
      req.body = undefined;
    }
  }

  next();
}
287217
function(body) {
    var $     = cheerio.load(body),
        page  = {};

    // Meta signals
    page.title = $('title').text() || null;
    page.description = $('meta[name=description]').attr('content') || null;
    page.author = $('meta[name=author]').attr('content') || null;
    page.keywords = $('meta[name=keywords]').attr('content') || null;

    // Heading signals
    var h1s = 0;
    $('h1').each(function() {
      h1s++;
    });
    page.heading1 = $('body h1:first-child').text().trim().replace('\n', '');
    page.totalHeadings = h1s;

    // Accessibility signals
    var totalImgs       = 0,
        accessibleImgs  = 0;
    $('img').each(function(index) {
      totalImgs++;
      if ($(this).attr('alt') || $(this).attr('title')) {
        accessibleImgs++;
      }
    });
    page.imgAccessibility = (accessibleImgs / totalImgs) * 100;
    return page;
  }
616808
public static Map<?, ?> parseJson(String body) {
        JSONReader jr = new JSONValidatingReader();
        Object obj = jr.read(body);
        if (obj instanceof Map<?, ?>) {
            return (Map<?, ?>) obj;
        } else {
            return null;
        }
    }