Exemplo n.º 1
0
std::wstring::size_type OMLItem::extract(const std::wstring& text, const std::wstring& textLower, std::wstring::size_type posStart, std::wstring::size_type posEnd)
{
	std::wstring::size_type pos = extract2(text, textLower, posStart, posEnd);

	// Gestione del 'noparse'.
	// Gestione dei tag ad hoc 'code', 'parse', '?', e 'url'.
	// da sistemare...
	if(!m_directClose)
	{
		bool noparse = false;

		if(m_tagName == _S("noparse")) noparse = true;
		if(m_tagName == _S("code")) noparse = true;
		if(m_tagName == _S("codebox")) noparse = true;
		if(m_tagName == _S("?")) noparse = true;
		if( (m_tagName == _S("url")) && (!hasParam(OMLItem::ITEM_PARAM_DEFAULT)) && (!hasParam(_S("href")))) noparse = true;
		if( (m_tagName == _S("iurl")) && (!hasParam(OMLItem::ITEM_PARAM_DEFAULT)) && (!hasParam(_S("href")))) noparse = true;

		if(noparse)
		{
			// Cerco direttamente la chiusura, e considero come testo tutto quello tra l'apertura e la chiusura del tag.
			std::wstring::size_type posEnd = textLower.find(_W("[/") + getTagName().to_wide() + _W("]"), pos);
			if(posEnd == std::wstring::npos)
				return posEnd;

			//String insideText = text.substr(pos,posEnd-pos);
			shared_ptr<OMLItem> t = shared_ptr<OMLItem>(OS_NEW OMLItem());
			t->extract(text, textLower, pos, posEnd);
			add(t);
			pos = posEnd;
		}
	}

	return pos;
}
Exemplo n.º 2
0
String IOMLCode::encodeOML(shared_ptr<OMLContext> context, const String& text)
{
	String html = _S("{oml_error}");

	if(context->incrementAndCheckRecursive())
	{
		shared_ptr<OMLItem> root = shared_ptr<OMLItem>(OS_NEW OMLItem());
		context->generateItems(root, text.to_wide());
		html = root->getHtmlChilds(context);
	}

	context->decrementRecursive();
	
	return html;
}