Beispiel #1
0
docstring InsetListings::getCaption(OutputParams const & runparams) const
{
	if (paragraphs().empty())
		return docstring();

	InsetCaption const * ins = getCaptionInset();
	if (ins == 0)
		return docstring();

	TexRow texrow;
	odocstringstream ods;
	otexstream os(ods, texrow);
	ins->getOptArg(os, runparams);
	ins->getArgument(os, runparams);
	// the caption may contain \label{} but the listings
	// package prefer caption={}, label={}
	docstring cap = ods.str();
	if (!contains(to_utf8(cap), "\\label{"))
		return cap;
	// convert from
	//     blah1\label{blah2} blah3
	// to
	//     blah1 blah3},label={blah2
	// to form options
	//     caption={blah1 blah3},label={blah2}
	//
	// NOTE that } is not allowed in blah2.
	regex const reg("(.*)\\\\label\\{(.*?)\\}(.*)");
	string const new_cap("\\1\\3},label={\\2");
	return from_utf8(regex_replace(to_utf8(cap), reg, new_cap));
}
Beispiel #2
0
docstring InsetCaptionable::getCaptionText(OutputParams const & runparams) const
{
	InsetCaption const * ins = getCaptionInset();
	if (ins == 0)
		return docstring();

	odocstringstream ods;
	ins->getCaptionAsPlaintext(ods, runparams);
	return ods.str();
}
Beispiel #3
0
docstring InsetCaptionable::getCaptionHTML(OutputParams const & runparams) const
{
	InsetCaption const * ins = getCaptionInset();
	if (ins == 0)
		return docstring();

	odocstringstream ods;
	XHTMLStream xs(ods);
	docstring def = ins->getCaptionAsHTML(xs, runparams);
	if (!def.empty())
		// should already have been escaped
		xs << XHTMLStream::ESCAPE_NONE << def << '\n';
	return ods.str();
}