Build a Markdown document.

@param string $in
@param string $out
@return void
170536
protected function build($in, $out)
    {
        $workDir = getenv('WORK_DIR').'/';

        $content = $this->filesystem->read($workDir.$in);

        $document = $this->builder->build($content);

        $this->filesystem->overwrite($workDir.$out, $document);
    }
15475
public function markup($nodes = null, $innerMarkup = false) 
    {
        if (isset($nodes) && count($nodes) == 1 && $nodes[0] instanceof DOMDOCUMENT) {
            $nodes = null;
        }
        if (isset($nodes)) {
            $markup = '';
            if (!is_array($nodes) && !($nodes instanceof DOMNODELIST) ) {
                $nodes = array($nodes);
            }
            if ($this->isDocumentFragment && ! $innerMarkup) {
                foreach($nodes as $i => $node) {
                    if ($node->isSameNode($this->root)) {
                        //    var_dump($node);
                        $nodes = array_slice($nodes, 0, $i)
                        + phpQuery::DOMNodeListToArray($node->childNodes)
                        + array_slice($nodes, $i+1);
                    }
                }
            }
            if ($this->isXML && ! $innerMarkup) {
                self::debug("Getting outerXML with charset '{$this->charset}'");
                // we need outerXML, so we can benefit from
                // $node param support in saveXML()
                foreach($nodes as $node) {
                    $markup .= $this->document->saveXML($node);
                }
            } else {
                $loop = array();
                if ($innerMarkup) {
                    foreach($nodes as $node) {
                        if ($node->childNodes) {
                            foreach($node->childNodes as $child) {
                                $loop[] = $child;
                            } 
                        } else {
                                        $loop[] = $node;
                        }
                    }
                } else {
                    $loop = $nodes;
                }
                self::debug("Getting markup, moving selected nodes (".count($loop).") to new DocumentFragment");
                $fake = $this->documentFragmentCreate($loop);
                $markup = $this->documentFragmentToMarkup($fake);
            }
            if ($this->isXHTML) {
                self::debug("Fixing XHTML");
                $markup = self::markupFixXHTML($markup);
            }
            self::debug("Markup: ".substr($markup, 0, 250));
            return $markup;
        } else {
            if ($this->isDocumentFragment) {
                // documentFragment, html only...
                self::debug("Getting markup, DocumentFragment detected");
                //                return $this->markup(
                ////                    $this->document->getElementsByTagName('body')->item(0)
                //                    $this->document->root, true
                //                );
                $markup = $this->documentFragmentToMarkup($this);
                // no need for markupFixXHTML, as it's done thought markup($nodes) method
                return $markup;
            } else {
                self::debug("Getting markup (".($this->isXML?'XML':'HTML')."), final with charset '{$this->charset}'");
                $markup = $this->isXML
                ? $this->document->saveXML()
                : $this->document->saveHTML();
                if ($this->isXHTML) {
                    self::debug("Fixing XHTML");
                    $markup = self::markupFixXHTML($markup);
                }
                self::debug("Markup: ".substr($markup, 0, 250));
                return $markup;
            }
        }
    }
181256
protected function exportMarkup($filename)
    {
        $file = $this->getProject()->getProperty('project.basedir') . "/docs/" . $filename;
        file_put_contents($file, $this->markup);
    }
640033
protected function compileChild($child, $out) {
        switch ($child[0]) {
        case "import":
            list(,$rawPath) = $child;
            $rawPath = $this->reduce($rawPath);
            if (!$this->compileImport($rawPath, $out)) {
                $out->lines[] = "@import " . $this->compileValue($rawPath) . ";";
            }
            break;
        case "directive":
            list(, $directive) = $child;
            $s = "@" . $directive->name;
            if (!empty($directive->value)) {
                $s .= " " . $this->compileValue($directive->value);
            }
            $this->compileNestedBlock($directive, array($s));
            break;
        case "media":
            $this->compileMedia($child[1]);
            break;
        case "block":
            $this->compileBlock($child[1]);
            break;
        case "charset":
            $out->lines[] = "@charset ".$this->compileValue($child[1]).";";
            break;
        case "assign":
            list(,$name, $value) = $child;
            if ($name[0] == "var") {
                $isDefault = !empty($child[3]);
                if (!$isDefault || $this->get($name[1], true) === true) {
                    $this->set($name[1], $this->reduce($value));
                }
                break;
            }

            $out->lines[] = $this->formatter->property(
                $this->compileValue($child[1]),
                $this->compileValue($child[2]));
            break;
        case "comment":
            $out->lines[] = $child[1];
            break;
        case "mixin":
        case "function":
            list(,$block) = $child;
            $this->set(self::$namespaces[$block->type] . $block->name, $block);
            break;
        case "extend":
            list(, $selectors) = $child;
            foreach ($selectors as $sel) {
                // only use the first one
                $sel = current($this->evalSelector($sel));
                $this->pushExtends($sel, $out->selectors);
            }
            break;
        case "if":
            list(, $if) = $child;
            if ($this->reduce($if->cond, true) != self::$false) {
                return $this->compileChildren($if->children, $out);
            } else {
                foreach ($if->cases as $case) {
                    if ($case->type == "else" ||
                        $case->type == "elseif" && ($this->reduce($case->cond) != self::$false))
                    {
                        return $this->compileChildren($case->children, $out);
                    }
                }
            }
            break;
        case "return":
            return $this->reduce($child[1], true);
        case "each":
            list(,$each) = $child;
            $list = $this->coerceList($this->reduce($each->list));
            foreach ($list[2] as $item) {
                $this->pushEnv();
                $this->set($each->var, $item);
                // TODO: allow return from here
                $this->compileChildren($each->children, $out);
                $this->popEnv();
            }
            break;
        case "while":
            list(,$while) = $child;
            while ($this->reduce($while->cond, true) != self::$false) {
                $ret = $this->compileChildren($while->children, $out);
                if ($ret) return $ret;
            }
            break;
        case "for":
            list(,$for) = $child;
            $start = $this->reduce($for->start, true);
            $start = $start[1];
            $end = $this->reduce($for->end, true);
            $end = $end[1];
            $d = $start < $end ? 1 : -1;

            while (true) {
                if ((!$for->until && $start - $d == $end) ||
                    ($for->until && $start == $end))
                {
                    break;
                }

                $this->set($for->var, array("number", $start, ""));
                $start += $d;

                $ret = $this->compileChildren($for->children, $out);
                if ($ret) return $ret;
            }

            break;
        case "nestedprop":
            list(,$prop) = $child;
            $prefixed = array();
            $prefix = $this->compileValue($prop->prefix) . "-";
            foreach ($prop->children as $child) {
                if ($child[0] == "assign") {
                    array_unshift($child[1][2], $prefix);
                }
                if ($child[0] == "nestedprop") {
                    array_unshift($child[1]->prefix[2], $prefix);
                }
                $prefixed[] = $child;
            }
            $this->compileChildren($prefixed, $out);
            break;
        case "include": // including a mixin
            list(,$name, $argValues, $content) = $child;
            $mixin = $this->get(self::$namespaces["mixin"] . $name, false);
            if (!$mixin) {
                throw new Exception(sprintf('Undefined mixin "%s"', $name));
            }

            $callingScope = $this->env;

            // push scope, apply args
            $this->pushEnv();
            if ($this->env->depth > 0) {
                $this->env->depth--;
            }

            if (!is_null($content)) {
                $content->scope = $callingScope;
                $this->setRaw(self::$namespaces["special"] . "content", $content);
            }

            if (!is_null($mixin->args)) {
                $this->applyArguments($mixin->args, $argValues);
            }

            foreach ($mixin->children as $child) {
                $this->compileChild($child, $out);
            }

            $this->popEnv();

            break;
        case "mixin_content":
            $content = $this->get(self::$namespaces["special"] . "content");
            if (is_null($content)) {
                throw new Exception("Unexpected @content inside of mixin");
            }

            $this->storeEnv = $content->scope;

            foreach ($content->children as $child) {
                $this->compileChild($child, $out);
            }

            unset($this->storeEnv);
            break;
        case "debug":
            list(,$value, $pos) = $child;
            $line = $this->parser->getLineNo($pos);
            $value = $this->compileValue($this->reduce($value, true));
            fwrite(STDERR, "Line $line DEBUG: $value\n");
            break;
        default:
            throw new Exception("unknown child type: $child[0]");
        }
    }
1104515
public function htmlActionsPanel(DAV\INode $node, &$output)
    {
        if (!$node instanceof AddressBookHome) {
            return;
        }

        $output .= '<tr><td colspan="2"><form method="post" action="">
            <h3>Create new address book</h3>
            <input type="hidden" name="sabreAction" value="mkcol" />
            <input type="hidden" name="resourceType" value="{DAV:}collection,{'.self::NS_CARDDAV.'}addressbook" />
            <label>Name (uri):</label> <input type="text" name="name" /><br />
            <label>Display name:</label> <input type="text" name="{DAV:}displayname" /><br />
            <input type="submit" value="create" />
            </form>
            </td></tr>';

        return false;
    }
1093177
function (out) {
            var label = this._cfg.label;
            if (label && this._cfg.waiAria) {
                out.write('<span class="xSROnly">' + ariaUtilsString.escapeHTML(label) + '</span>');
            }
            this._frame.writeMarkupBegin(out);
        }
208284
private void buildDefinition(MarkupDocBuilder markupDocBuilder, String definitionName, Model model) {
        if (logger.isDebugEnabled()) {
            logger.debug("Definition processed : '{}'", definitionName);
        }
        if (config.isSeparatedDefinitionsEnabled()) {
            MarkupDocBuilder defDocBuilder = copyMarkupDocBuilder(markupDocBuilder);
            applyDefinitionComponent(defDocBuilder, definitionName, model);
            Path definitionFile = context.getOutputPath().resolve(definitionDocumentNameResolver.apply(definitionName));
            defDocBuilder.writeToFileWithoutExtension(definitionFile, StandardCharsets.UTF_8);
            if (logger.isDebugEnabled()) {
                logger.debug("Separate definition file produced : '{}'", definitionFile);
            }

            definitionRef(markupDocBuilder, definitionName);

        } else {
            applyDefinitionComponent(markupDocBuilder, definitionName, model);
        }
    }
1250296
public function setTermSpeed($in, $out) {
        $this->terminal_speed_in = $in;
        $this->terminal_speed_out = $out;

        return $this;
    }
359422
public void writeDocument(OutputStream out) {
        try {
            out.write(OPEN_GROUP);
            out.write(RtfDocument.RTF_DOCUMENT);
            this.documentHeader.writeContent(out);
            this.data.writeTo(out);
            out.write(CLOSE_GROUP);
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }
    }
1329606
protected function compileChildren($stms, OutputBlock $out)
    {
        foreach ($stms as $stm) {
            $ret = $this->compileChild($stm, $out);

            if (isset($ret)) {
                return $ret;
            }
        }

        return null;
    }
994397
public static function newDocumentXHTML($markup = null, $charset = null) 
    {
        $contentType = $charset
        ? ";charset=$charset"
        : '';
        return self::newDocument($markup, "application/xhtml+xml{$contentType}");
    }
227288
public void generate(Output out) throws IOException {
        out.output(getSelectorString());
        out.output(" {");
        out.incIndent();
        for (Attribute attr : attributes) {
            out.optionalLineBreak();
            out.output(attr);
        }
        for (Section child : subSections) {
            out.lineBreak();
            child.generate(out);
        }
        out.decIndent();
        out.optionalLineBreak();
        out.output("}");
    }
1135959
public function renderChildren($indent = 0)
    {
        if ($this->innerHtml === null) {
            $this->innerHtml = '';
            foreach ($this->children as $element) {
                $this->innerHtml .= "\n" . $element->render($indent + 1);
            }
        }

        return $this->innerHtml;
    }
1211043
public static function newDocumentHTML($markup = null, $charset = null) 
    {
        $contentType = $charset
        ? ";charset=$charset"
        : '';
        return self::newDocument($markup, "text/html{$contentType}");
    }
1266130
void writeDocument(OutputStream outStream, Document doc) {
        DOMImplementationRegistry domRegistry = null;
        try {
            domRegistry = DOMImplementationRegistry.newInstance();
        // Fortify Mod: Broaden try block to capture all potential exceptions
        // } catch (Exception e) {
        //    LOGR.warning(e.getMessage());
        // }
        DOMImplementationLS impl = (DOMImplementationLS) domRegistry
                .getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        writer.getDomConfig().setParameter("xml-declaration", false);
        writer.getDomConfig().setParameter("format-pretty-print", true);
        LSOutput output = impl.createLSOutput();
        output.setEncoding("UTF-8");
        output.setByteStream(outStream);
        writer.write(doc, output);
        } catch (Exception e) {
            LOGR.warning(e.getMessage());
        }
    }
802934
protected function execute(InputInterface $in, OutputInterface $out)
    {
        $this->in = $in;
        $this->out = $out;
        $serializer = $this->serializer;
        $namespaceResolver = $this->namespaceResolver;
        $entityClass = $this->in->getArgument('entity');
        $group = $this->in->getOption('entity-group');
        $version = $this->in->getOption('entity-version');
        $rawOutput = $this->in->getOption('raw-output');

        if (!$rawOutput) {
            $this->out->writeln('<info>####################################</info>');
            $this->out->writeln('<info>##    Random Fixture generator    ##</info>');
            $this->out->writeln('<info>####################################</info>');
            $this->out->writeln('');
        }

        $entityNamespace = $namespaceResolver->resolveNamespaceForClass($entityClass);

        $randomFixtureGenerator = $this->randomFixtureGenerator;
        $entity = $randomFixtureGenerator->generate($entityNamespace, $group, $version);
        $context = ContextFactory::createSerializationContextForFixtures($group, $version);

        $result = $serializer->serialize($entity, 'json', $context);
        if (!$rawOutput) {
            $this->out->writeln('');
            $this->out->writeln('<info>Random fixture successfully generated.</info>');
            $this->out->writeln('');
        }

        $this->out->writeln($result);
    }
572649
public function generate()
    {
        $code = array();

        if ($this->namespace !== null) {
            $code[] = $this->getIndentation() . 'namespace ' . $this->namespace;
            $code[] = '{';
            $code[] = null;

            // Temporarily add one more level of indentation.
            $this->addIndentationLevel(1);
        }

        $code = array_merge($code, $this->renderUsesLines());

        $indentation = $this->getIndentation();

        $doc = $this->generateDocumentation();
        if ($doc !== null) {
            $code[] = $doc;
        }

        $line = $indentation . 'interface ' . $this->name;
        if (count($this->extends) > 0) {
            $line .= ' extends ' . implode(', ', $this->extends);
        }

        $code[] = $line;
        $code[] = $indentation . '{';

        // Interface constants.
        $interfaceElements = $this->generateConstantsLines();

        // Interface methods.
        foreach ($this->methods as $method) {
            if ($method->getVisibility() !== Modifiers::VISIBILITY_PUBLIC) {
                throw new RuntimeException('The visibility of methods must be public.');
            }

            $method->setIndentationString($this->getIndentationString());
            $method->setIndentationLevel($this->getIndentationLevel() + 1);

            $doc = $method->generateDocumentation();
            if ($doc !== null) {
                $interfaceElements[] = $doc;
            }

            $interfaceElements[] = $method->generateSignature() . ';';
            $interfaceElements[] = null;
        }

        if (count($interfaceElements) > 0) {
            $code[] = null;
            $code = array_merge($code, $interfaceElements);
            // Remove last empty line.
            array_pop($code);
        }

        $code[] = $indentation . '}';

        if ($this->namespace !== null) {
            // Set back the indentation.
            $this->addIndentationLevel(-1);

            $code[] = $this->getIndentation() . '}';
        }

        return implode($this->getLineFeed(), $code);
    }