Generate the theme roller sample markdown
344807
def make_sample():
    
    if md_sample:
        # user has set another:
        return md_sample
    _md = []
    for hl in range(1, 7): _md.append('#' * hl + ' ' + 'Header %s' % hl)
    this = open(__file__).read().split('"""', 3)[2].splitlines()[:10]
    _md.append('```python\n""" Test """\n%s\n```' % '\n'.join(this).strip())
    _md.append("""
| Tables        | Fmt |
| -- | -- |
| !!! hint: wrapped | 0.1 **strong** |
    """)
    for ad in admons.keys()[:1]:
        _md.append('!!! %s: title\n    this is a %s\n' % (ad, ad.capitalize()))
    # 'this theme' replaced in the roller (but not at mdv w/o args):
    globals()['md_sample'] = \
            '\n'.join(_md) + '\n----\n!!! question: %s' % you_like
1123734
function getHtmlFromMarkedMarkdown(srcStr) {
	var result = parseSource(srcStr);
	var html = md.render(result);
	return html;
}
918650
function dummyMarkdown() {
    var codeBlock = /^```/;
    var quoteBlock = /^>/;
    var listBlock = /^\* /;

    var commentInline = '<!--.*-->';
    var codeInline = '`.+`';

    function split(content) {
        var pattern = new RegExp([commentInline, codeInline].join('|'), 'g');
        var result = null;
        var last = 0;
        var output = [];

        while ((result = pattern.exec(content)) !== null) {
            output.push({ transform: true, content: content.slice(last, result.index)});
            output.push({ transform: false, content: result[0]});
            last = pattern.lastIndex;
        }

        output.push({ transform: true, content: content.slice(last)});

        return output;
    }

    return function (input) {
        var output = [];
        var lines = input.split('\n');

        for (var l = 0; l < lines.length; l++) {
            var line = lines[l];
            var e;
            var content;

            if (codeBlock.test(line)) {
                e = l + 1;
                while (!codeBlock.test(lines[e])) {
                    e++;
                }

                output.push({ transform: false, content: lines.slice(l, e + 1).join('\n') + '\n\n' });
                l = e;
            } else if (quoteBlock.test(line)) {
                e = l + 1;
                while (quoteBlock.test(lines[e])) {
                    e++;
                }

                content = [line].concat(lines.slice(l + 1, e).map(function (nextLine) {
                    return nextLine.slice(2);
                })).join(' ') + '\n\n';

                output = output.concat(split(content));
                l = e - 1;
            } else if (listBlock.test(line)) {
                e = l + 1;
                while (lines[e] !== '') {
                    if (!listBlock.test(lines[e])) {
                        lines[e - 1] += ' ' + lines[e];
                        lines[e] = '';
                    }
                    e++;
                }

                content = lines.slice(l, e).filter(function (line) {
                    return line !== '';
                }).join('\n') + '\n';

                output = output.concat(split(content));
                l = e - 1;
            } else if (line !== '') {
                e = l + 1;
                while (lines[e] !== '') {
                    e++;
                }

                content = lines.slice(l, e).join(' ') + '\n\n';

                output = output.concat(split(content));
                l = e - 1;
            }
        }

        return output;
    };
}
872436
public static Object generateExample(Property property, MarkupDocBuilder markupDocBuilder) {

        if (property.getType() == null) {
            return "untyped";
        }

        switch (property.getType()) {
            case "integer":
                return ExamplesUtil.generateIntegerExample(property instanceof IntegerProperty ? ((IntegerProperty) property).getEnum() : null);
            case "number":
                return 0.0;
            case "boolean":
                return true;
            case "string":
                return ExamplesUtil.generateStringExample(property.getFormat(), property instanceof StringProperty ? ((StringProperty) property).getEnum() : null);
            case "ref":
                if (property instanceof RefProperty) {
                    if (logger.isDebugEnabled()) logger.debug("generateExample RefProperty for " + property.getName());
                    return markupDocBuilder.copy(false).crossReference(((RefProperty) property).getSimpleRef()).toString();
                } else {
                    if (logger.isDebugEnabled()) logger.debug("generateExample for ref not RefProperty");
                }
            case "array":
                if (property instanceof ArrayProperty) {
                    return generateArrayExample((ArrayProperty) property, markupDocBuilder);
                }
            default:
                return property.getType();
        }
    }
149322
def generate_example_rst(app):
    
    root_dir = os.path.join(app.builder.srcdir, 'auto_examples')
    example_dir = os.path.abspath(app.builder.srcdir + '/../' + 'examples')
    try:
        plot_gallery = eval(app.builder.config.plot_gallery)
    except TypeError:
        plot_gallery = bool(app.builder.config.plot_gallery)
    if not os.path.exists(example_dir):
        os.makedirs(example_dir)
    if not os.path.exists(root_dir):
        os.makedirs(root_dir)

    # we create an index.rst with all examples
    fhindex = file(os.path.join(root_dir, 'index.rst'), 'w')
    #Note: The sidebar button has been removed from the examples page for now
    #      due to how it messes up the layout. Will be fixed at a later point
    fhindex.write("""\

.. raw:: html


    <style type="text/css">

    div#sidebarbutton {
        display: none;
    }

    .figure {
        float: left;
        margin: 10px;
        width: auto;
        height: 200px;
        width: 180px;
    }

    .figure img {
        display: inline;
        }

    .figure .caption {
        width: 170px;
        text-align: center !important;
    }
    </style>

.. _examples-index:

Examples
========

""")
    # Here we don't use an os.walk, but we recurse only twice: flat is
    # better than nested.
    generate_dir_rst('.', fhindex, example_dir, root_dir, plot_gallery)
    for dir in sorted(os.listdir(example_dir)):
        if os.path.isdir(os.path.join(example_dir, dir)):
            generate_dir_rst(dir, fhindex, example_dir, root_dir, plot_gallery)
    fhindex.flush()
377595
def apply(self):
        """"""
        source = self.document['source']

        self.reporter.info('AutoStructify: %s' % source)

        # only transform markdowns
        if not source.endswith(tuple(self.config['commonmark_suffixes'])):
            return

        self.url_resolver = self.config['url_resolver']
        assert callable(self.url_resolver)

        self.state_machine = DummyStateMachine()
        self.current_level = 0
        self.file_dir = os.path.abspath(os.path.dirname(self.document['source']))
        self.root_dir = os.path.abspath(self.document.settings.env.srcdir)
        self.traverse(self.document)
1013916
def render(self, text, auth=None):
        
        if markdown is None:
            import markdown
        if UrlizeExtension is None:
            from .mdx_urlize import UrlizeExtension
        return markdown.markdown(text, extensions=[
            'fenced_code',
            'codehilite(css_class=highlight)',
            'toc',
            'tables',
            'sane_lists',
            UrlizeExtension(),
        ])
872060
def on_page_markdown(self, markdown, page, config,
                          site_navigation=None, **kwargs):
        ""

        # the site_navigation argument has been made optional
        # (deleted in post 1.0 mkdocs, but maintained here
        # for backward compatibility)

        if not self.variables:
            return markdown

        else:

            # Create templae and get the variables
            md_template = Template(markdown)

            # Execute the jinja2 template and return
            return md_template.render(**self.variables)
688965
def createRPYText(self):
        ''''''
        self.rollText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0),'Roll:   %.2f' % self.roll,color='w',size=self.fontSize)
        self.pitchText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97+self.vertSize-(0.5*self.vertSize/10.0),'Pitch: %.2f' % self.pitch,color='w',size=self.fontSize)
        self.yawText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97,'Yaw:   %.2f' % self.yaw,color='w',size=self.fontSize)
        self.rollText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')])
        self.pitchText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')])
        self.yawText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')])
434406
function show() {
    var parsed = ensureConfig();
    function showRollbacks() {
        var rollbacks = mu.getRollbacks();
        var keys = Object.keys(rollbacks);
        var padBtm = [0, 0, 1, 0];
        var ui = pargv.ui(105);
        var i = keys.length;
        var hdrNo = { text: " ", width: 5 };
        var hdrId = { text: "" + chalk.underline.gray('ID'), width: 20 };
        var hdrTs = { text: "" + chalk.underline.gray('Timestamp'), width: 30 };
        var hdrCt = { text: "" + chalk.underline.gray('Count'), width: 10 };
        var hdrTpl = { text: "" + chalk.underline.gray('Templates'), width: 35, padding: padBtm };
        ui.div(hdrNo, hdrId, hdrTs, hdrCt, hdrTpl);
        while (i--) {
            var key = keys[i];
            var rb = rollbacks[key];
            var no = { text: i + 1 + ")", width: 5 };
            var id = { text: "" + chalk.cyan(rb.id), width: 20 };
            var ts = { text: "" + chalk.yellow(rb.timestamp), width: 30 };
            var ct = { text: "" + chalk.green(rb.count + ''), width: 10 };
            var tpl = { text: "" + chalk.magenta(rb.templates.join(', ')), width: 35 };
            ui.div(no, id, ts, ct, tpl);
        }
        ui.show();
    }
    switch (parsed.name) {
        case 'r':
            showRollbacks();
            break;
        case 'rollbacks':
            showRollbacks();
            break;
        default:
            break;
    }
}
614813
def generate_srcset(piece)
        piece.styles.map do |name, width|
          if piece.image.attachment.exists?(computed_style(piece, name).to_sym)
            "#{piece.image.attachment.url(computed_style(piece, name).to_sym)} #{width}w"
          else
            "#{piece.image.attachment.url(:original)} #{width}w"
          end
        end.join(', ')
      end
1107111
def markdown(iterable, renderer=HTMLRenderer):
    
    with renderer() as renderer:
        return renderer.render(Document(iterable))
280100
function CreateMarkdownGrammar(myna)
{
    let m = myna;

    let g = new function()
    {        
        // Allows the "inline" to be referenced before it is defined. 
        // This enables recursive definitions. 
        let _this = this;
        this.inlineDelayed = m.delay(function() { return _this.inline; });            
        
        this.boundedInline = function(begin, end) {
            if (end == undefined) end = begin;
            return m.seq(begin, this.inlineDelayed.unless(end).zeroOrMore, end);
        }
        
        // Plain text
        this.specialCharSet = '[]()*~`@#\\_!';
        this.escaped = m.seq('\\', m.advance).ast;
        this.ws = m.char(' \t').oneOrMore;
        this.optWs = this.ws.opt;
        this.wsOrNewLine = this.ws.or(m.newLine);
        this.nonSpecialChar = m.notChar(this.specialCharSet).unless(m.newLine);
        this.specialChar = m.char(this.specialCharSet).ast;
        this.plainText = m.choice(m.digits, m.letters, this.ws, this.nonSpecialChar).oneOrMore.ast;

        // Styling instructions 
        this.bold = m.choice(this.boundedInline('**'), this.boundedInline('__')).ast;
        this.boldItalic = m.choice(this.boundedInline('*_', '_*'), this.boundedInline('_*', '*_')).ast;
        this.italic = m.choice(this.boundedInline('*'), this.boundedInline('_')).ast;
        this.strike = this.boundedInline('~~').ast;
        this.code = m.not('```').then(this.boundedInline('`')).ast;
        this.styledText = m.choice(this.bold, this.italic, this.strike);

        // Image instructions 
        this.linkedUrl = m.choice(this.escaped, m.notChar(')')).zeroOrMore.ast;
        this.altText =  m.choice(this.escaped, m.notChar(']')).zeroOrMore.ast;
        this.image = m.seq('![', this.altText, ']', m.ws, '(', this.linkedUrl, ')').ast;

        // Linked text
        this.linkedText = this.inlineDelayed.unless(']').zeroOrMore.ast;
        this.linkText = m.seq('[', this.linkedText, ']');
        this.linkUrl = m.seq('(', this.linkedUrl, ')');
        this.link = m.seq(this.linkText, m.ws, this.linkUrl).ast;        

        // Mention
        this.reference = m.choice(m.char('/-'), m.identifierNext).oneOrMore.ast;
        this.mention = m.seq('@', this.reference).ast;    

        // Comment
        this.comment = m.seq("<!--", m.advanceUntilPast("-->")).ast;

        // Beginning of sections 
        this.indent = m.zeroOrMore('  ').ast;
        this.inlineUrl = m.seq(m.choice("http://", "https://", "mailto:"), m.advanceWhileNot(this.wsOrNewLine)).ast;
        this.numListStart = m.seq(this.indent, m.digit.oneOrMore, '.', m.ws);
        this.quotedLineStart = m.seq(this.indent, '>');
        this.listStart = m.seq(this.indent, m.char('-').or(m.seq('*', m.not('*'))), m.ws);
        this.headingLineStart = m.quantified('#', 1, 6).ast;
        this.codeBlockDelim = m.text("```");
        this.specialLineStart = this.optWs.then(m.choice(this.listStart, this.headingLineStart, this.quotedLineStart, this.numListStart, this.codeBlockDelim));

        // Inline content 
        this.any = m.advance.ast;
        this.inline = m.choice(this.comment, this.image, this.link, this.mention, this.styledText, this.code, this.escaped, this.inlineUrl, this.plainText, this.any).unless(m.newLine);
        this.lineEnd = m.newLine.or(m.assert(m.end));
        this.emptyLine = m.char(' \t').zeroOrMore.then(m.newLine).ast;
        this.restOfLine = m.seq(this.inline.zeroOrMore).then(this.lineEnd).ast;
        this.simpleLine = m.seq(this.emptyLine.not, this.specialLineStart.not, m.notEnd, this.restOfLine).ast;
        this.paragraph = this.simpleLine.oneOrMore.ast;
        
        // Lists
        this.orderedListItem = m.seq(this.numListStart, this.optWs, this.restOfLine).ast;
        this.unorderedListItem = m.seq(this.listStart, this.optWs, this.restOfLine).ast;
        this.orderedList = this.orderedListItem.oneOrMore.ast;
        this.unorderedList = this.unorderedListItem.oneOrMore.ast;
        this.list = m.choice(this.orderedList, this.unorderedList);
        
        // Quotes
        this.quotedLine = m.seq('>', this.optWs, this.restOfLine).ast;
        this.quote = this.quotedLine.oneOrMore.ast;    

        // Code blocks        
        this.codeBlockContent = m.advanceWhileNot(this.codeBlockDelim).ast;
        this.codeBlockHint = m.advanceWhileNot(m.choice(m.newLine, this.codeBlockDelim)).ast;
        this.codeBlock = m.guardedSeq(this.codeBlockDelim, this.codeBlockHint, m.newLine.opt, this.codeBlockContent, this.codeBlockDelim).ast;

        // Heading 
        this.heading = this.headingLineStart.then(this.optWs).then(this.restOfLine).ast;

        // A section 
        this.content = m.choice(this.heading, this.list, this.quote, this.codeBlock, this.paragraph, this.emptyLine); 
        this.document = this.content.zeroOrMore;
    }

    // Register the grammar, providing a name and the default parse rule
    return m.registerGrammar("markdown", g, g.document);
}
286772
function generateClasses(_ref){var clrs=_ref.clrs;var scale=_ref.scale;var typeScale=_ref.typeScale;var rem=_ref.rem;var borderWidth=_ref.borderWidth;
return _extends({},
(0,_colors2.default)(clrs),
(0,_whitespace2.default)(scale),
(0,_typography2.default)(typeScale),_flexbox2.default,

(0,_dimensions2.default)(rem),
(0,_border2.default)(rem,borderWidth),
(0,_absolute2.default)(rem));

}
144279
function render() {
		var labels = options.labels,
			credits = options.credits,
			creditsHref;

		// Title
		setTitle();


		// Legend
		legend = chart.legend = new Legend();

		// Get margins by pre-rendering axes
		getMargins();
		each(axes, function (axis) {
			axis.setTickPositions(true); // update to reflect the new margins
		});
		adjustTickAmounts();
		getMargins(); // second pass to check for new labels


		// Draw the borders and backgrounds
		drawChartBox();

		// Axes
		if (hasCartesianSeries) {
			each(axes, function (axis) {
				axis.render();
			});
		}


		// The series
		if (!chart.seriesGroup) {
			chart.seriesGroup = renderer.g('series-group')
				.attr({ zIndex: 3 })
				.add();
		}
		each(series, function (serie) {
			serie.translate();
			serie.setTooltipPoints();
			serie.render();
		});


		// Labels
		if (labels.items) {
			each(labels.items, function () {
				var style = extend(labels.style, this.style),
					x = pInt(style.left) + plotLeft,
					y = pInt(style.top) + plotTop + 12;

				// delete to prevent rewriting in IE
				delete style.left;
				delete style.top;

				renderer.text(
					this.html,
					x,
					y
				)
				.attr({ zIndex: 2 })
				.css(style)
				.add();

			});
		}

		// Toolbar (don't redraw)
		if (!chart.toolbar) {
			chart.toolbar = Toolbar();
		}

		// Credits
		if (credits.enabled && !chart.credits) {
			creditsHref = credits.href;
			chart.credits = renderer.text(
				credits.text,
				0,
				0
			)
			.on('click', function () {
				if (creditsHref) {
					location.href = creditsHref;
				}
			})
			.attr({
				align: credits.position.align,
				zIndex: 8
			})
			.css(credits.style)
			.add()
			.align(credits.position);
		}

		placeTrackerGroup();

		// Set flag
		chart.hasRendered = true;

		// If the chart was rendered outside the top container, put it back in
		if (renderToClone) {
			renderTo.appendChild(container);
			discardElement(renderToClone);
			//updatePosition(container);
		}
	}
328218
private function themes(): Generator
    {
        $themes = $this->module_service->findByInterface(ModuleThemeInterface::class);

        // Last theme used
        yield $themes->get(Session::get('theme', ''));

        // Default for tree
        $tree = app(Tree::class);

        if ($tree instanceof Tree) {
            yield $themes->get($tree->getPreference('THEME_DIR'));
        }

        // Default for site
        yield $themes->get(Site::getPreference('THEME_DIR'));

        // Default for application
        yield app(WebtreesTheme::class);
    }
460033
protected function renderMarkdown()
    {
        $markdownFileBuilder = new MarkdownFileBuilder($this->filesystem, $this->viewFactory, $this->file, $this->viewsData);

        return $markdownFileBuilder->render();
    }