예제 #1
0
void CCFHtmlTidy::SetTidyProp(const std::string& strParam, int nNumValue, const std::string& /*strNumValue*/, const std::string& strTextValue)
{
	TidyDoc formatter = tidyImplToDoc(tidy);
	if ("axd" == strParam)
	{
		tidyOptSetBool(formatter, TidyXmlDecl, yes);
	}
	else if ("axs" == strParam)
	{
		tidyOptSetBool(formatter, TidyXmlSpace, yes);
	}
	else if ("aan" == strParam)
	{
		tidyOptSetBool(formatter, TidyAnchorAsName, yes);
	}
	else if ("axp" == strParam)
	{
		tidyOptSetBool(formatter, TidyXmlPIs, yes);
	}
	else if ("b" == strParam)
	{
		tidyOptSetBool(formatter, TidyMakeBare, yes);
	}
	else if ("c" == strParam)
	{
		tidyOptSetBool(formatter, TidyMakeClean, yes);
	}
	else if ("diu" == strParam)
	{
		tidyOptSetBool(formatter, TidyDecorateInferredUL, yes);
	}
	else if ("dep" == strParam)
	{
		tidyOptSetBool(formatter, TidyDropEmptyParas, yes);
	}
	else if ("dft" == strParam)
	{
		tidyOptSetBool(formatter, TidyDropFontTags, yes);
	}
	else if ("dpa" == strParam)
	{
		tidyOptSetBool(formatter, TidyDropPropAttrs, yes);
	}
	else if ("ebt" == strParam)
	{
		tidyOptSetBool(formatter, TidyEncloseBlockText, yes);
	}
	else if ("et" == strParam)
	{
		tidyOptSetBool(formatter, TidyEncloseBodyText, yes);
	}
	else if ("ec" == strParam)
	{
		tidyOptSetBool(formatter, TidyEscapeCdata, yes);
	}
	else if ("fb" == strParam)
	{
		tidyOptSetBool(formatter, TidyFixBackslash, yes);
	}
	else if ("fbc" == strParam)
	{
		tidyOptSetBool(formatter, TidyFixComments, yes);
	}
	else if ("fu" == strParam)
	{
		tidyOptSetBool(formatter, TidyFixUri, yes);
	}
	else if ("hc" == strParam)
	{
		tidyOptSetBool(formatter, TidyHideComments, yes);
	}
	else if ("he" == strParam)
	{
		tidyOptSetBool(formatter, TidyHideEndTags, yes);
	}
	else if ("ic" == strParam)
	{
		tidyOptSetBool(formatter, TidyIndentCdata, yes);
	}
	else if ("ix" == strParam)
	{
		tidyOptSetBool(formatter, TidyXmlTags, yes);
	}
	else if ("jc" == strParam)
	{
		tidyOptSetBool(formatter, TidyJoinClasses, yes);
	}
	else if ("js" == strParam)
	{
		tidyOptSetBool(formatter, TidyJoinStyles, yes);
	}
	else if ("la" == strParam)
	{
		tidyOptSetBool(formatter, TidyLiteralAttribs, yes);
	}
	else if ("le" == strParam)
	{
		tidyOptSetBool(formatter, TidyLogicalEmphasis, yes);
	}
	else if ("ll" == strParam)
	{
		tidyOptSetBool(formatter, TidyLowerLiterals, yes);
	}
	else if ("n" == strParam)
	{
		tidyOptSetBool(formatter, TidyNCR, yes);
	}
	else if ("ne" == strParam)
	{
		tidyOptSetBool(formatter, TidyNumEntities, yes);
	}
	else if ("oh" == strParam)
	{
		tidyOptSetBool(formatter, TidyHtmlOut, yes);
	}
	else if ("ox" == strParam)
	{
		tidyOptSetBool(formatter, TidyXhtmlOut, yes);
	}
	else if ("oxm" == strParam)
	{
		tidyOptSetBool(formatter, TidyXmlOut, yes);
	}
	else if ("pe" == strParam)
	{
		tidyOptSetBool(formatter, TidyPreserveEntities, yes);
	}
	else if ("qa" == strParam)
	{
		tidyOptSetBool(formatter, TidyQuoteAmpersand, yes);
	}
	else if ("qm" == strParam)
	{
		tidyOptSetBool(formatter, TidyQuoteMarks, yes);
	}
	else if ("qn" == strParam)
	{
		tidyOptSetBool(formatter, TidyQuoteNbsp, yes);
	}
	else if ("rc" == strParam)
	{
		tidyOptSetBool(formatter, TidyReplaceColor, yes);
	}
	else if ("ua" == strParam)
	{
		tidyOptSetBool(formatter, TidyUpperCaseAttrs, yes);
	}
	else if ("ut" == strParam)
	{
		tidyOptSetBool(formatter, TidyUpperCaseTags, yes);
	}
	else if ("wo" == strParam)
	{
		tidyOptSetBool(formatter, TidyWord2000, yes);
	}
	else if ("bbb" == strParam)
	{
		tidyOptSetBool(formatter, TidyBreakBeforeBR, yes);
	}
	else if ("ia" == strParam)
	{
		tidyOptSetBool(formatter, TidyIndentAttributes, yes);
	}
	else if ("m" == strParam)
	{
		tidyOptSetBool(formatter, TidyShowMarkup, yes);
	}
	else if ("pw" == strParam)
	{
		tidyOptSetBool(formatter, TidyPunctWrap, yes);
	}
	else if ("vs" == strParam)
	{
		tidyOptSetBool(formatter, TidyVertSpace, yes);
	}
	else if ("wa" == strParam)
	{
		tidyOptSetBool(formatter, TidyWrapAsp, yes);
	}
	else if ("wat" == strParam)
	{
		tidyOptSetBool(formatter, TidyWrapAttVals, yes);
	}
	else if ("wj" == strParam)
	{
		tidyOptSetBool(formatter, TidyWrapJste, yes);
	}
	else if ("wp" == strParam)
	{
		tidyOptSetBool(formatter, TidyWrapPhp, yes);
	}
	else if ("wsl" == strParam)
	{
		tidyOptSetBool(formatter, TidyWrapScriptlets, yes);
	}
	else if ("ws" == strParam)
	{
		tidyOptSetBool(formatter, TidyWrapSection, yes);
	}
	else if ("ac" == strParam)
	{
		tidyOptSetBool(formatter, TidyAsciiChars, yes);
	}
	else if ("sw" == strParam)
	{
		tidyOptSetBool(formatter, TidyShowWarnings, yes);
	}
	else if ("fo" == strParam)
	{
		tidyOptSetBool(formatter, TidyForceOutput, yes);
	}
	else if ("i" == strParam)
	{
		tidyOptSetInt(formatter, TidyIndentContent, abs(nNumValue - 2) % 3);
	}
	else if ("md" == strParam)
	{
		tidyOptSetInt(formatter, TidyMergeDivs, abs(nNumValue - 2) % 3);
	}
	else if ("ms" == strParam)
	{
		tidyOptSetInt(formatter, TidyMergeSpans, abs(nNumValue - 2) % 3);
	}
	else if ("sbo" == strParam)
	{
		tidyOptSetInt(formatter, TidyBodyOnly, abs(nNumValue - 2) % 3);
	}
	else if ("d" == strParam)
	{
		tidyOptSetInt(formatter, TidyDoctypeMode, nNumValue % 5);
	}
	else if ("du" == strParam)
	{
		tidyOptSetValue(formatter, TidyDoctype, strTextValue.c_str());
	}
	else if ("ra" == strParam)
	{
		tidyOptSetInt(formatter, TidyDuplicateAttrs, nNumValue % 2);
	}
	else if ("sa" == strParam)
	{
		tidyOptSetInt(formatter, TidySortAttributes, nNumValue % 2);
	}
	else if ("ce" == strParam)
	{
		tidySetCharEncoding(formatter, TY_(GetEncodingOptNameFromTidyId)(nNumValue));
	}
	else if ("ie" == strParam)
	{
		tidySetInCharEncoding(formatter, TY_(GetEncodingOptNameFromTidyId)(nNumValue));
	}
	else if ("oe" == strParam)
	{
		tidySetOutCharEncoding(formatter, TY_(GetEncodingOptNameFromTidyId)(nNumValue));
	}
	else if ("se" == strParam)
	{
		tidyOptSetInt(formatter, TidyShowErrors, nNumValue);
	}
	else if ("is" == strParam)
	{
		tidyOptSetInt(formatter, TidyIndentSpaces, nNumValue);
	}
	else if ("ts" == strParam)
	{
		tidyOptSetInt(formatter, TidyTabSize, nNumValue);
	}
	else if ("w" == strParam)
	{
		tidyOptSetInt(formatter, TidyWrapLen, nNumValue);
	}
	else if ("at" == strParam)
	{
		tidyOptSetValue(formatter, TidyAltText, strTextValue.c_str());
	}
	else if ("cp" == strParam)
	{
		tidyOptSetValue(formatter, TidyCSSPrefix, strTextValue.c_str());
	}
	else if ("nbt" == strParam)
	{
		tidyOptSetValue(formatter, TidyBlockTags, strTextValue.c_str());
	}
	else if ("net" == strParam)
	{
		tidyOptSetValue(formatter, TidyEmptyTags, strTextValue.c_str());
	}
	else if ("nit" == strParam)
	{
		tidyOptSetValue(formatter, TidyInlineTags, strTextValue.c_str());
	}
	else if ("npt" == strParam)
	{
		tidyOptSetValue(formatter, TidyPreTags, strTextValue.c_str());
	}
}
예제 #2
0
void HTidyInterface::SetTidyControl( TidyDoc tdoc, LPCTSTR lpszTidy, int nPos, int nSize )
{
	if (lpszTidy[nPos] != '-' || nSize < 2)
	{
		return;
	}

	int nNumValue = nSize;
	for (int i = nPos + 1; i < nPos + nSize; ++i)
	{
		if (!_istalpha(lpszTidy[i]))
		{
			nNumValue = i - nPos;
			break;
		}
	}
	CString strParam(lpszTidy + nPos + 1, nNumValue - 1);
	if (nNumValue != nSize)
	{
		CString strNum(lpszTidy + nPos + nNumValue, nSize - nNumValue);
		nNumValue = _ttoi(strNum);
	}
	else
	{
		nNumValue = 0;
	}
	CString strNumValue;
	strNumValue.Format(_T("%d"), nNumValue);

	CString strNothing;
	strNothing.Empty();
	if (_T("axd") == strParam)
	{
		tidyOptSetBool(tdoc, TidyXmlDecl, yes);
	} 
	else if (_T("axs") == strParam)
	{
		tidyOptSetBool(tdoc, TidyXmlSpace, yes);
	}
	else if (_T("aan") == strParam)
	{
		tidyOptSetBool(tdoc, TidyAnchorAsName, yes);
	}
	else if (_T("axp") == strParam)
	{
		tidyOptSetBool(tdoc, TidyXmlPIs, yes);
	}
	else if (_T("b") == strParam)
	{
		tidyOptSetBool(tdoc, TidyMakeBare, yes);
	}
	else if (_T("c") == strParam)
	{
		tidyOptSetBool(tdoc, TidyMakeClean, yes);
	}
	else if (_T("diu") == strParam)
	{
		tidyOptSetBool(tdoc, TidyDecorateInferredUL, yes);
	}
	else if (_T("dep") == strParam)
	{
		tidyOptSetBool(tdoc, TidyDropEmptyParas, yes);
	}
	else if (_T("dft") == strParam)
	{
		tidyOptSetBool(tdoc, TidyDropFontTags, yes);
	}
	else if (_T("dpa") == strParam)
	{
		tidyOptSetBool(tdoc, TidyDropPropAttrs, yes);
	}
	else if (_T("ebt") == strParam)
	{
		tidyOptSetBool(tdoc, TidyEncloseBlockText, yes);
	}
	else if (_T("et") == strParam)
	{
		tidyOptSetBool(tdoc, TidyEncloseBodyText, yes);
	}
	else if (_T("ec") == strParam)
	{
		tidyOptSetBool(tdoc, TidyEscapeCdata, yes);
	}
	else if (_T("fb") == strParam)
	{
		tidyOptSetBool(tdoc, TidyFixBackslash, yes);
	}
	else if (_T("fbc") == strParam)
	{
		tidyOptSetBool(tdoc, TidyFixComments, yes);
	}
	else if (_T("fu") == strParam)
	{
		tidyOptSetBool(tdoc, TidyFixUri, yes);
	}
	else if (_T("hc") == strParam)
	{
		tidyOptSetBool(tdoc, TidyHideComments, yes);
	}
	else if (_T("he") == strParam)
	{
		tidyOptSetBool(tdoc, TidyHideEndTags, yes);
	}
	else if (_T("ic") == strParam)
	{
		tidyOptSetBool(tdoc, TidyIndentCdata, yes);
	}
	else if (_T("ix") == strParam)
	{
		tidyOptSetBool(tdoc, TidyXmlTags, yes);
	}
	else if (_T("jc") == strParam)
	{
		tidyOptSetBool(tdoc, TidyJoinClasses, yes);
	}
	else if (_T("js") == strParam)
	{
		tidyOptSetBool(tdoc, TidyJoinStyles, yes);
	}
	else if (_T("la") == strParam)
	{
		tidyOptSetBool(tdoc, TidyLiteralAttribs, yes);
	}
	else if (_T("le") == strParam)
	{
		tidyOptSetBool(tdoc, TidyLogicalEmphasis, yes);
	}
	else if (_T("ll") == strParam)
	{
		tidyOptSetBool(tdoc, TidyLowerLiterals, yes);
	}
	else if (_T("n") == strParam)
	{
		tidyOptSetBool(tdoc, TidyNCR, yes);
	}
	else if (_T("ne") == strParam)
	{
		tidyOptSetBool(tdoc, TidyNumEntities, yes);
	}
	else if (_T("oh") == strParam)
	{
		tidyOptSetBool(tdoc, TidyHtmlOut, yes);
	}
	else if (_T("ox") == strParam)
	{
		tidyOptSetBool(tdoc, TidyXhtmlOut, yes);
	}
	else if (_T("oxm") == strParam)
	{
		tidyOptSetBool(tdoc, TidyXmlOut, yes);
	}
	else if (_T("pe") == strParam)
	{
		tidyOptSetBool(tdoc, TidyPreserveEntities, yes);
	}
	else if (_T("qa") == strParam)
	{
		tidyOptSetBool(tdoc, TidyQuoteAmpersand, yes);
	}
	else if (_T("qm") == strParam)
	{
		tidyOptSetBool(tdoc, TidyQuoteMarks, yes);
	}
	else if (_T("qn") == strParam)
	{
		tidyOptSetBool(tdoc, TidyQuoteNbsp, yes);
	}
	else if (_T("rc") == strParam)
	{
		tidyOptSetBool(tdoc, TidyReplaceColor, yes);
	}
	else if (_T("ua") == strParam)
	{
		tidyOptSetBool(tdoc, TidyUpperCaseAttrs, yes);
	}
	else if (_T("ut") == strParam)
	{
		tidyOptSetBool(tdoc, TidyUpperCaseTags, yes);
	}
	else if (_T("wo") == strParam)
	{
		tidyOptSetBool(tdoc, TidyWord2000, yes);
	}
	else if (_T("bbb") == strParam)
	{
		tidyOptSetBool(tdoc, TidyBreakBeforeBR, yes);
	} 
	else if (_T("ia") == strParam)
	{
		tidyOptSetBool(tdoc, TidyIndentAttributes, yes);
	}
	else if (_T("m") == strParam)
	{
		tidyOptSetBool(tdoc, TidyShowMarkup, yes);
	}
	else if (_T("pw") == strParam)
	{
		tidyOptSetBool(tdoc, TidyPunctWrap, yes);
	}
	else if (_T("vs") == strParam)
	{
		tidyOptSetBool(tdoc, TidyVertSpace, yes);
	}
	else if (_T("wa") == strParam)
	{
		tidyOptSetBool(tdoc, TidyWrapAsp, yes);
	}
	else if (_T("wat") == strParam)
	{
		tidyOptSetBool(tdoc, TidyWrapAttVals, yes);
	}
	else if (_T("wj") == strParam)
	{
		tidyOptSetBool(tdoc, TidyWrapJste, yes);
	}
	else if (_T("wp") == strParam)
	{
		tidyOptSetBool(tdoc, TidyWrapPhp, yes);
	}
	else if (_T("wsl") == strParam)
	{
		tidyOptSetBool(tdoc, TidyWrapScriptlets, yes);
	}
	else if (_T("ws") == strParam)
	{
		tidyOptSetBool(tdoc, TidyWrapSection, yes);
	}
	else if (_T("ac") == strParam)
	{
		tidyOptSetBool(tdoc, TidyAsciiChars, yes);
	}
	else if (_T("sw") == strParam)
	{
		tidyOptSetBool(tdoc, TidyShowWarnings, yes);
	}
	else if (_T("fo") == strParam)
	{
		tidyOptSetBool(tdoc, TidyForceOutput, yes);
	}
	else if (_T("i") == strParam)
	{
		tidyOptSetInt(tdoc, TidyIndentContent, abs(nNumValue - 2) % 3);
	}
	else if (_T("md") == strParam)
	{
		tidyOptSetInt(tdoc, TidyMergeDivs, abs(nNumValue - 2) % 3);
	}
	else if (_T("ms") == strParam)
	{
		tidyOptSetInt(tdoc, TidyMergeSpans, abs(nNumValue - 2) % 3);
	}
	else if (_T("sbo") == strParam)
	{
		tidyOptSetInt(tdoc, TidyBodyOnly, abs(nNumValue - 2) % 3);
	}
	else if (_T("d") == strParam)
	{
		tidyOptSetInt(tdoc, TidyDoctypeMode, nNumValue % 5);
	}
	else if (_T("ra") == strParam)
	{
		tidyOptSetInt(tdoc, TidyDuplicateAttrs, nNumValue % 2);
	}
	else if (_T("sa") == strParam)
	{
		tidyOptSetInt(tdoc, TidySortAttributes, nNumValue % 2);
	}
	else if (_T("ce") == strParam)
	{		
		tidySetCharEncoding(tdoc, GetEncodeByIndex(nNumValue));
	}
	else if (_T("ie") == strParam)
	{
		tidySetInCharEncoding(tdoc, GetEncodeByIndex(nNumValue));
	}
	else if (_T("oe") == strParam)
	{
		tidySetOutCharEncoding(tdoc, GetEncodeByIndex(nNumValue));
	}
	else if (_T("se") == strParam)
	{
		tidyOptSetInt(tdoc, TidyShowErrors, nNumValue);
	}
	else if (_T("is") == strParam)
	{
		tidyOptSetInt(tdoc, TidyIndentSpaces, nNumValue);
	}
	else if (_T("ts") == strParam)
	{
		tidyOptSetInt(tdoc, TidyTabSize, nNumValue);
	}
	else if (_T("w") == strParam)
	{
		tidyOptSetInt(tdoc, TidyWrapLen, nNumValue);
	}
	else if (_T("at") == strParam)
	{
		tidyOptSetValue(tdoc, TidyAltText, CT2A(m_onlyHtmlXml == SYN_HTML?g_GlobalTidy.m_TidyHtml_at:strNothing));
	}
	else if (_T("cp") == strParam)
	{
		tidyOptSetValue(tdoc, TidyCSSPrefix, CT2A(m_onlyHtmlXml == SYN_HTML?g_GlobalTidy.m_TidyHtml_cp:strNothing));
	}
	else if (_T("nbt") == strParam)
	{
		tidyOptSetValue(tdoc, TidyBlockTags, CT2A(m_onlyHtmlXml == SYN_HTML?g_GlobalTidy.m_TidyHtml_nbt:strNothing));
	}
	else if (_T("net") == strParam)
	{
		tidyOptSetValue(tdoc, TidyEmptyTags, CT2A(m_onlyHtmlXml == SYN_HTML?g_GlobalTidy.m_TidyHtml_net:strNothing));
	}
	else if (_T("nit") == strParam)
	{
		tidyOptSetValue(tdoc, TidyInlineTags, CT2A(m_onlyHtmlXml == SYN_HTML?g_GlobalTidy.m_TidyHtml_nit:strNothing));
	}
	else if (_T("npt") == strParam)
	{
		tidyOptSetValue(tdoc, TidyPreTags, CT2A(m_onlyHtmlXml == SYN_HTML?g_GlobalTidy.m_TidyHtml_npt:strNothing));
	}
}