parent
b615364cba
commit
d8a29a35c7
@ -0,0 +1,89 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* plainhtml.cpp - description
|
||||||
|
* -------------------
|
||||||
|
* begin : Thu Jun 24 1999
|
||||||
|
* copyright : (C) 1999 by Torsten Uhlmann
|
||||||
|
* email : TUhlmann@gmx.de
|
||||||
|
*
|
||||||
|
* Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
|
||||||
|
* CrossWire Bible Society
|
||||||
|
* P. O. Box 2528
|
||||||
|
* Tempe, AZ 85280-2528
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation version 2.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <plainhtml.h>
|
||||||
|
#include <swbuf.h>
|
||||||
|
|
||||||
|
SWORD_NAMESPACE_START
|
||||||
|
|
||||||
|
PLAINHTML::PLAINHTML()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char PLAINHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
SWBuf orig = text;
|
||||||
|
const char *from = orig.c_str();
|
||||||
|
for (text = ""; *from; from++)
|
||||||
|
{
|
||||||
|
if ((*from == '\n') && (from[1] == '\n')) // two newlinea are a paragraph
|
||||||
|
{
|
||||||
|
text += "<P>";
|
||||||
|
from++;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
if ((*from == '\n')) // && (from[1] != '\n')) // only one new line
|
||||||
|
{
|
||||||
|
text += "<BR>";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*from == '{') { //footnote start
|
||||||
|
text += "<FONT COLOR=\"#80000\"><SMALL> (";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (*from == '}') //footnote end
|
||||||
|
{
|
||||||
|
text += ") </SMALL></FONT>";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (*from == '<') {
|
||||||
|
text += "<";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (*from == '>') {
|
||||||
|
text += ">";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (*from == '&') {
|
||||||
|
text += "&";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if ((*from == ' ') && (count > 5000))
|
||||||
|
{
|
||||||
|
text += "<WBR>";
|
||||||
|
count = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
text += *from;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SWORD_NAMESPACE_END
|
@ -0,0 +1,38 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* $Id: plainhtml.h 1688 2005-01-01 04:42:26Z scribe $
|
||||||
|
*
|
||||||
|
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
|
||||||
|
* CrossWire Bible Society
|
||||||
|
* P. O. Box 2528
|
||||||
|
* Tempe, AZ 85280-2528
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation version 2.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PLAINHTML_H
|
||||||
|
#define PLAINHTML_H
|
||||||
|
|
||||||
|
#include <swfilter.h>
|
||||||
|
|
||||||
|
SWORD_NAMESPACE_START
|
||||||
|
|
||||||
|
/** this filter converts plain text to HTML text
|
||||||
|
* @author Torsten Uhlmann, begin : Tue Jun 15 15:34:26 CEST 1999
|
||||||
|
*/
|
||||||
|
class SWDLLEXPORT PLAINHTML : public SWFilter {
|
||||||
|
public:
|
||||||
|
PLAINHTML();
|
||||||
|
virtual char processText(SWBuf &text, const SWKey *key = 0, const SWModule *module = 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
SWORD_NAMESPACE_END
|
||||||
|
#endif
|
Loading…
Reference in new issue