コード例 #1
0
ファイル: SetPageBase.cpp プロジェクト: 20400992/CoolFormat
void CSetPageBase::InitTidyConfig()
{
	ASSERT(m_wndPropList.ValidateShort());

	SetTidyConfig(*m_strTidy);
	m_wndPropList.CommitModifiedValues(FALSE);
}
コード例 #2
0
bool HTidyInterface::formatSource( const char* textIn, CString &strTidy, CString &strMsg )
{
	TidyBuffer output;
	TidyBuffer errbuf;	
	int rc = -1;
	Bool ok = yes;

	TidyDoc tdoc = tidyCreate();                     // Initialize "document"
	tidyBufInit(&output);
	tidyBufInit(&errbuf);

	InitTidyDefault(tdoc);
	SetTidyConfig(tdoc);

	if ( ok )
		rc = tidySetErrorBuffer(tdoc, &errbuf);      // Capture diagnostics
	if ( rc >= 0 )
		rc = tidyParseString(tdoc, textIn);           // Parse the input
	if ( rc >= 0 )
		rc = tidyCleanAndRepair(tdoc);               // Tidy it up!
	if ( rc >= 0 )
		rc = tidyRunDiagnostics(tdoc);               // Kvetch
	//if ( rc > 1 )                                    // If error, force output.
	//	rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
	if ( rc >= 0 )
		rc = tidySaveBuffer(tdoc, &output);          // Pretty Print

	if ( rc >= 0 )
	{		
		strTidy = reinterpret_cast< char const* >(output.bp);
	}

	strMsg = reinterpret_cast< char const* >(errbuf.bp);
	CString strEmpty = _T("No warnings or errors were found.\r\n\r\n");
	if (0 == strEmpty.Compare(strMsg))
	{
		strMsg.Empty();
	}
	tidyBufFree(&output);
	tidyBufFree(&errbuf);
	tidyRelease(tdoc);
	return true;
}