Patch: XHTML importer PRE tag support


Subject: Patch: XHTML importer PRE tag support
From: Andrew Dunbar (hippietrail@yahoo.com)
Date: Sun May 20 2001 - 10:34:54 CDT


This patch adds support for the <PRE> HTML tag.
Please check that I haven't made incorrect assumptions
about the XHTML or XML importers.

If the patch is ok it fixes Bug 1459.

Andrew Dunbar.

-- 
http://linguaphile.sourceforge.net

Index: src/wp/impexp/xp/ie_imp_XHTML.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_XHTML.cpp,v retrieving revision 1.17 diff -u -r1.17 ie_imp_XHTML.cpp --- src/wp/impexp/xp/ie_imp_XHTML.cpp 2001/05/19 16:31:51 1.17 +++ src/wp/impexp/xp/ie_imp_XHTML.cpp 2001/05/20 15:23:56 @@ -283,6 +283,8 @@ #define TT_TITLE 38 // title tag #define TT_STYLE 39 // style tag +#define TT_PRE 40 // preformatted tag + // This certainly leaves off lots of tags, but with HTML, this is inevitable - samth static struct xmlToIdMapping s_Tokens[] = @@ -312,6 +314,7 @@ { "meta", TT_META }, { "ol", TT_OL }, { "p", TT_P }, + { "pre", TT_PRE }, { "q", TT_Q }, { "s", TT_S }, { "samp", TT_SAMP }, @@ -826,6 +829,11 @@ // these tags are ignored for the time being return; + case TT_PRE: + X_VerifyParseState(_PS_Block); + m_bWhiteSignificant = true; + return; + case TT_OTHER: default: UT_DEBUGMSG(("Unknown tag [%s]\n",name)); @@ -935,6 +943,13 @@ case TT_META: case TT_STYLE: return; + + case TT_PRE: + UT_ASSERT(m_lenCharDataSeen==0); + X_VerifyParseState(_PS_Block); + X_CheckDocument(_getInlineDepth()==0); + m_bWhiteSignificant = false; + return; case TT_OTHER: default: Index: src/wp/impexp/xp/ie_imp_XML.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_XML.cpp,v retrieving revision 1.17 diff -u -r1.17 ie_imp_XML.cpp --- src/wp/impexp/xp/ie_imp_XML.cpp 2001/05/16 20:31:01 1.17 +++ src/wp/impexp/xp/ie_imp_XML.cpp 2001/05/20 15:24:00 @@ -244,6 +244,7 @@ // TODO XML_Char is defined in the xml parser // TODO as a 'char' not as a 'unsigned char'. // TODO does this cause any problems ?? + // TODO Needs to handle preformatted text X_EatIfAlreadyError(); // xml parser keeps running until buffer consumed @@ -313,9 +314,13 @@ X_CheckError(0); } + // TODO Needs to handle preformatted text if (currentChar == UCS_CR) { - buf[bufLen++] = UCS_SPACE; // substitute a SPACE + if (!m_bWhiteSignificant) + buf[bufLen++] = UCS_SPACE; // substitute a SPACE + else + buf[bufLen++] = UCS_LF; m_bSeenCR = true; continue; } @@ -326,6 +331,7 @@ // (ABW) if (!m_bWhiteSignificant) { + // TODO Needs to handle preformatted text if(UT_UCS_isspace(currentChar)) { if(!m_bWasSpace) @@ -341,10 +347,14 @@ } } + // TODO Needs to handle preformatted text if (currentChar == UCS_LF) // LF { if (!m_bSeenCR) // if not immediately after a CR, - buf[bufLen++] = UCS_SPACE; // substitute a SPACE. otherwise, eat. + if (!m_bWhiteSignificant) + buf[bufLen++] = UCS_SPACE; // substitute a SPACE. otherwise, eat. + else + buf[bufLen++] = UCS_LF; m_bSeenCR = false; continue; }

_________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com



This archive was generated by hypermail 2b25 : Sat May 26 2001 - 03:51:05 CDT