Parses content as a sequence of blocks.
@param content The content to parse.
@param baseUri The base URI for content.
@return The sequence of blocks.
@throws ParseException on invalid block format.
540640
public static List<Block> parse(final String content, final String baseUri) throws ParseException {
      Document doc = Jsoup.parseBodyFragment(content, baseUri);
      List<Node> blockMarkers = Lists.newArrayList();
      doc.body().traverse(new NodeVisitor() {
         @Override
         public void head(final Node node, final int i) {
            if(node instanceof Comment) {
               String comment = Strings.nullToEmpty(((Comment)node).getData()).trim();
               if(comment.startsWith("wp:") || comment.startsWith("/wp:")) {
                  blockMarkers.add(node);
               }
            }
         }

         @Override
         public void tail(final Node node, final int i) {

         }
      });

      //Parse/tidy of invalid markup may leave markers as children
      //of nested elements. Move them to the body...

      for(int i = 0; i < blockMarkers.size(); i++) {
         Node node = blockMarkers.get(i);
         if(node.parent() != doc.body()) {
            Node cloneNode = node.clone();
            node.remove();
            if(i == 0) {
               doc.body().prependChild(cloneNode);
            } else {
               blockMarkers.get(i-1).after(cloneNode);
            }
            blockMarkers.set(i, cloneNode);
         }
      }

      Set<Node> markerSet = Sets.newIdentityHashSet();
      markerSet.addAll(blockMarkers);

      List<Block> blocks = Lists.newArrayList();
      Block currBlock = null;
      List<Node> currNodes = Lists.newArrayList();

      for(Node node : doc.body().childNodes()) {
         if(markerSet.contains(node)) {
            String comment = ((Comment)node).getData().trim();
            if(comment.startsWith("wp:")) {
               if(!currNodes.isEmpty()) {
                  //Default block...
                  blocks.add(new Block("html", currNodes));
                  currNodes.clear();
               }
               currBlock = block(comment, 3);
            } else if(comment.startsWith("/wp:")) {
               Block checkBlock = block(comment, 4);
               if(currBlock == null) {
                  throw new ParseException(String.format("Missing start block for 'wp:%s'", checkBlock.type), 0);
               } else if(!currBlock.type.equals(checkBlock.type)) {
                  throw new ParseException(String.format("Start/end block mismatch. Expecting '/wp:%s' but found '/wp:%s",
                          currBlock.type, checkBlock.type), 0);
               } else {
                  blocks.add(currBlock.withContent(currNodes));
                  currBlock = null;
                  currNodes.clear();
               }
            } else {
               currNodes.add(node);
            }
         } else {
            currNodes.add(node);
         }
      }

      if(currBlock != null) {
         throw new ParseException(String.format("Expecting end block for 'wp:%s'", currBlock.type), 0);
      }

      if(!currNodes.isEmpty()) {
         blocks.add(new Block("html", currNodes));
      }

      return removeEmptyBlocks(blocks);
   }
893076
protected function processBlocks(string &$content): void
    {
        $pattern = $this->getTagPattern('block\s+([_a-zA-Z][_a-zA-Z0-9]*)' . preg_quote($this->endTag, '/') . '\s*(.+?)\s*' . preg_quote($this->startTag . '/block', '/'));
        $blockCodes = [];
        $content = preg_replace_callback($pattern, function ($match) use (&$blockCodes) {
            $blockCodes[$match[1]] = $match[2];
            return '';
        }, $content);
        $displayPattern = $this->getTagPattern('display_block\s+([_a-zA-Z][_a-zA-Z0-9]*)');
        $content = preg_replace_callback($displayPattern, function ($match) use ($blockCodes) {
            if (isset($blockCodes[$match[1]])) {
                return $blockCodes[$match[1]];
            }
            return '';
        }, $content);
    }
275878
def parseUri(stream, uri=None):
    """"""
    return etree.parse(stream, parser=_get_xmlparser(), base_url=uri)
1189482
public static String encodeBase64(String content, TestContext context) {
        return new EncodeBase64Function().execute(Collections.singletonList(content), context);
    }
661289
public static ContentType parse(
            final String s) throws ParseException, UnsupportedCharsetException {
        if (s == null) {
            throw new IllegalArgumentException("Content type may not be null");
        }
        HeaderElement[] elements = BasicHeaderValueParser.parseElements(s, null);
        if (elements.length > 0) {
            return create(elements[0]);
        } else {
            throw new ParseException("Invalid content type: " + s);
        }
    }
119447
public static void parse(final URI baseURI, final OutputStream output)
            throws XIncludeFatalException
    {
        final Processor processor = XIncProcEngine.CONFIGURATION.getProcessor();
        final XMLFilter filter = XIncProcEngine.newXIncludeFilter(baseURI);
        final InputSource inputSource = new InputSource(baseURI.toASCIIString());
        try
        {
            final XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
            filter.setParent(xmlReader);
            final SAXSource saxSource = new SAXSource(filter, inputSource);
            final XdmNode node = processor.newDocumentBuilder().wrap(saxSource);
            final Serializer serializer = processor.newSerializer(output);
            processor.writeXdmValue(node, serializer);
        }
        catch (final SAXException | SaxonApiException | ParserConfigurationException e)
        {
            throw new XIncludeFatalException(e);
        }
    }
1166668
public BinarySparseDataset parse(String name, URI uri) throws IOException, ParseException {
        return parse(name, new File(uri));
    }
449107
public final void block() throws RecognitionException {
		int block_StartIndex = input.index();


		            increaseLevel();
		        
		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 80) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:693:5: ( '{' ( blockStatement )* '}' )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:693:7: '{' ( blockStatement )* '}'
			{
			match(input,121,FOLLOW_121_in_block2769); if (state.failed) return;
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:693:11: ( blockStatement )*
			loop104:
			while (true) {
				int alt104=2;
				int LA104_0 = input.LA(1);
				if ( ((LA104_0 >= CharacterLiteral && LA104_0 <= DecimalLiteral)||LA104_0==ENUM||LA104_0==FloatingPointLiteral||(LA104_0 >= HexLiteral && LA104_0 <= Identifier)||(LA104_0 >= OctalLiteral && LA104_0 <= StringLiteral)||LA104_0==29||LA104_0==36||(LA104_0 >= 40 && LA104_0 <= 41)||(LA104_0 >= 44 && LA104_0 <= 45)||(LA104_0 >= 52 && LA104_0 <= 53)||LA104_0==58||(LA104_0 >= 63 && LA104_0 <= 67)||(LA104_0 >= 70 && LA104_0 <= 73)||(LA104_0 >= 75 && LA104_0 <= 77)||(LA104_0 >= 79 && LA104_0 <= 80)||(LA104_0 >= 82 && LA104_0 <= 83)||(LA104_0 >= 85 && LA104_0 <= 87)||LA104_0==90||(LA104_0 >= 92 && LA104_0 <= 98)||(LA104_0 >= 100 && LA104_0 <= 112)||(LA104_0 >= 114 && LA104_0 <= 121)||LA104_0==126) ) {
					alt104=1;
				}

				switch (alt104) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:693:11: blockStatement
					{
					pushFollow(FOLLOW_blockStatement_in_block2771);
					blockStatement();
					state._fsp--;
					if (state.failed) return;
					}
					break;

				default :
					break loop104;
				}
			}

			match(input,125,FOLLOW_125_in_block2774); if (state.failed) return;
			}

			if ( state.backtracking==0 ) {
			            if( localVariableLevel <= 1 ) {
			                // this is the top level block, so set the top level declarations
			                rootBlockDescr.setInScopeLocalVars( getLocalDeclarations() );
			            }
			            decreaseLevel();
			        }
		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 80, block_StartIndex); }

		}
	}
254997
public static Document parseBodyFragment(String bodyHtml, String baseUri) {
        Document doc = Document.createShell(baseUri);
        Element body = doc.body();
        List<Node> nodeList = parseFragment(bodyHtml, body, baseUri);
        Node[] nodes = nodeList.toArray(new Node[0]); // the node list gets modified when re-parented
        for (int i = nodes.length - 1; i > 0; i--) {
            nodes[i].remove();
        }
        for (Node node : nodes) {
            body.appendChild(node);
        }
        return doc;
    }
925096
public static String decryptToBase64(String content) {
        byte[] decodedValue = DatatypeConverter.parseBase64Binary(content);
        return new String(decodedValue, CHARSET);
    }
609190
private static ContentType parse(final String contentTypeString) {

		try {

			return new ContentType(contentTypeString);

		} catch (ParseException pe) {

			logger.warn("Could not parse " + contentTypeString, pe);

		}

		return null;
	}
1200372
public static String encryptToBase64(String content) {
        byte[] val = content.getBytes(CHARSET);
        return DatatypeConverter.printBase64Binary(val);
    }
1253995
private int parseAnnotationStart(List<String> content, int lineIndex) {
        while (lineIndex > 0 && content.get(lineIndex - 1).trim().startsWith("@")) {
            lineIndex = lineIndex - 1;
        }
        return lineIndex;
    }
144296
public static void parse(String content, Object data) {
    if (content == null) {
      return;
    }
    try {
      parse(new StringReader(content), data);
    } catch (IOException exception) {
      // I/O exception not expected on a string
      throw Throwables.propagate(exception);
    }
  }
479013
function parseUri(uri) {
  if (uri instanceof Array) {
    uri = eut(uri[0], uri[1]);
  }

  return baseUrl + uri;
}
670623
@SuppressWarnings("unchecked")
  @NonNull public CMARichBlock setContent(@NonNull List<CMARichNode> content) {
    if (content == null) {
      throw new NullPointerException("content is null");
    }

    this.content.clear();
    this.content.addAll(content);

    return this;
  }
746041
public static String encode(String content) {
		if (content == null || content.length() == 0) {
			return content;
		}
		return org.apache.commons.codec.binary.Base64.encodeBase64String(content.getBytes()).trim();

	}