[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Fwd: Re: PATCH: kspread html export
From:       Kevin Krammer <kevin.krammer () gmx ! at>
Date:       2001-07-30 13:38:56
[Download RAW message or body]

forwarding the message after Nicolas told me that the devel list is open too.

----------  Forwarded Message  ----------
Subject: Re: PATCH: kspread html export
Date: Mon, 30 Jul 2001 11:47:29 +0200
From: Kevin Krammer <kevin.krammer@gmx.at>
To: Nicolas Goutte <nicog@snafu.de>


HI!

I read on the KOffive devel list that you are loking for a markup escape
function.
I use something like this to write an khtml DOM tree into a file.

See attached example prog.

Cheers,
Kevin

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Krammer <kevin.krammer@gmx.at>
Developer at the Kmud Project http://www.kmud.de/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-------------------------------------------------------

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Krammer <kevin.krammer@gmx.at>
Developer at the Kmud Project http://www.kmud.de/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
["replaceMarkup.cpp" (text/x-c)]

#include <qstring.h>
#include <iostream>

QString& escapeMarkup(QString& text)
{
	const QString amp("&amp;");
	const QString lt("&lt;");
	const QString gt("&gt;");

	int pos = 0;

	while (pos < text.length())
	{
		switch (text.at(pos).latin1())
		{
		case '&':
			text.replace(pos, 1, amp);
		  pos += 5;
			break;
		case '<':
			text.replace(pos, 1, lt);
		  pos += 4;
			break;
		case '>':
			text.replace(pos, 1, gt);
		  pos += 4;
			break;
		default:
			++pos;
			break;
		}
	}

	return text;
}

int main()
{
	QString test("this <tag> is a test&");
	cout << "test: " << test.latin1() << endl;
	cout << "function result: " << escapeMarkup(test).latin1() << endl;
	cout << "test: " << test.latin1() << endl;
}

_______________________________________________
Koffice-devel mailing list
Koffice-devel@master.kde.org
http://master.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic