Removed module power-wiki
This commit is contained in:
parent
bd462e0450
commit
1779a964ca
2
pom.xml
2
pom.xml
@ -54,8 +54,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
<module>power-log</module>
|
<module>power-log</module>
|
||||||
<module>power-io</module>
|
<module>power-io</module>
|
||||||
<module>power-web</module>
|
<module>power-web</module>
|
||||||
|
|
||||||
<module>power-wiki</module>
|
|
||||||
|
|
||||||
<module>power-sql</module>
|
<module>power-sql</module>
|
||||||
<module>power-db</module>
|
<module>power-db</module>
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
power-framework: Java library with many purposes of usage.
|
|
||||||
Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation;
|
|
||||||
version 2.1 of the License only.
|
|
||||||
|
|
||||||
This library 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
-->
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.nanoboot.powerframework</groupId>
|
|
||||||
<artifactId>power-framework</artifactId>
|
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>power-wiki</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>Power Wiki</name>
|
|
||||||
<description>Wiki functionality for the Power library</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- Power dependencies -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.nanoboot.powerframework</groupId>
|
|
||||||
<artifactId>power-core</artifactId>
|
|
||||||
<version>${power.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.nanoboot.powerframework</groupId>
|
|
||||||
<artifactId>power-log</artifactId>
|
|
||||||
<version>${power.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Other dependencies -->
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*/
|
|
||||||
module powerframework.wiki {
|
|
||||||
requires powerframework.core;
|
|
||||||
requires powerframework.log;
|
|
||||||
requires powerframework.utils;
|
|
||||||
}
|
|
@ -1,170 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*/
|
|
||||||
public class Block {
|
|
||||||
|
|
||||||
private final ArrayList<String> lines = new ArrayList<>();
|
|
||||||
private final ArrayList<String> origLines = new ArrayList<>();
|
|
||||||
private final BlockType blockType;
|
|
||||||
|
|
||||||
public Block(BlockType lineType) {
|
|
||||||
this.blockType = lineType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addLine(String line) {
|
|
||||||
if(blockType.isOneLined() && lines.size() == 1) {
|
|
||||||
throw new WikiException(blockType.getDescription() + " is one lined. Cannot add line " + line);
|
|
||||||
}
|
|
||||||
origLines.add(line);
|
|
||||||
if(this.blockType != BlockType.PARSER) {
|
|
||||||
line = preProcessLine(line);
|
|
||||||
}
|
|
||||||
lines.add(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String preProcessLine(String lineIn) {
|
|
||||||
BlockType lineType = BlockType.getBlockType(lineIn);
|
|
||||||
if(blockType != lineType) {
|
|
||||||
throw new WikiException("Cannot add line to block. Line type is " + lineType + ", but the block type is " + blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
String line = lineIn;
|
|
||||||
switch (blockType) {
|
|
||||||
|
|
||||||
// case OL: {
|
|
||||||
// line = line.replace(WikiMarks.ORDERED_LIST, HtmlTags.LI_START);
|
|
||||||
// line = line + HtmlTags.LI_END;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case UL: {
|
|
||||||
// line = line.replace(WikiMarks.UNORDERED_LIST, HtmlTags.LI_START);
|
|
||||||
// line = line + HtmlTags.LI_END;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
case BLANK: {
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case P: {
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockType getBlockType() {
|
|
||||||
return blockType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLine(int lineNumber) {
|
|
||||||
return lines.get(lineNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toHtml() {
|
|
||||||
StringBuilder stringBuilder = new StringBuilder("<span style=\"background-color:orange\">" + this.blockType + "</span><br />");
|
|
||||||
int linesMaxIndex = lines.size() - 1;
|
|
||||||
int i = 0;
|
|
||||||
for (String line : lines) {
|
|
||||||
stringBuilder.append(line);
|
|
||||||
if(i++ < linesMaxIndex) {
|
|
||||||
stringBuilder.append('\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String string = stringBuilder.toString();
|
|
||||||
switch (blockType) {
|
|
||||||
|
|
||||||
case H1: {
|
|
||||||
string = string.replace(WikiMarks.HEADING1_START, HtmlTags.H1_START);
|
|
||||||
string = string.replace(WikiMarks.HEADING1_END, HtmlTags.H1_END);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case H2: {
|
|
||||||
string = string.replace(WikiMarks.HEADING2_START, HtmlTags.H2_START);
|
|
||||||
string = string.replace(WikiMarks.HEADING2_END, HtmlTags.H2_END);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case H3: {
|
|
||||||
string = string.replace(WikiMarks.HEADING3_START, HtmlTags.H3_START);
|
|
||||||
string = string.replace(WikiMarks.HEADING3_END, HtmlTags.H3_END);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case H4: {
|
|
||||||
string = string.replace(WikiMarks.HEADING4_START, HtmlTags.H4_START);
|
|
||||||
string = string.replace(WikiMarks.HEADING4_END, HtmlTags.H4_END);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case H5: {
|
|
||||||
string = string.replace(WikiMarks.HEADING5_START, HtmlTags.H5_START);
|
|
||||||
string = string.replace(WikiMarks.HEADING5_END, HtmlTags.H5_END);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case H6: {
|
|
||||||
string = string.replace(WikiMarks.HEADING6_START, HtmlTags.H6_START);
|
|
||||||
string = string.replace(WikiMarks.HEADING6_END, HtmlTags.H6_END);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case LIST: {
|
|
||||||
string = HtmlTags.OL_START + '\n' + string + '\n' + HtmlTags.OL_END;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// case UL: {
|
|
||||||
// string = HtmlTags.UL_START + '\n' + string + '\n' + HtmlTags.UL_END;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
case BLANK: {
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case P: {
|
|
||||||
string = HtmlTags.P_START + '\n' + string + '\n' + HtmlTags.P_END;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//s = "\n\n\n\n### ZZZZZZZZZZZZZZZZZZZ ###\n" + s + "\n---------------------\n" + string + "\n-----------------";
|
|
||||||
//System.out.println(s);
|
|
||||||
string = "<!-- Block begins- lineType=" + this.blockType.getDescription() + " -->\n" + string + "\n<!-- Block ends- lineType=" + this.blockType.getDescription() + " -->";
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
public String getOrig(){
|
|
||||||
StringBuilder stringBuilder=new StringBuilder();
|
|
||||||
for(String e:origLines){
|
|
||||||
stringBuilder.append(e).append("\n");
|
|
||||||
}
|
|
||||||
return stringBuilder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*/
|
|
||||||
class BlockList {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger for this class.
|
|
||||||
*/
|
|
||||||
private static final org.nanoboot.powerframework.log.Logger LOG = org.nanoboot.powerframework.log.Logger.getLogger(BlockList.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant description
|
|
||||||
*/
|
|
||||||
private final ArrayList<Block> blocks = new ArrayList<>();
|
|
||||||
private Block currentBlock = null;
|
|
||||||
|
|
||||||
void addLine(String lineIn) {
|
|
||||||
BlockType lineType = BlockType.getBlockType(lineIn);
|
|
||||||
if(currentBlock == null) {
|
|
||||||
currentBlock = new Block(lineType);
|
|
||||||
currentBlock.addLine(lineIn);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
currentBlock.addLine(lineIn);
|
|
||||||
} catch (WikiException e) {
|
|
||||||
blocks.add(currentBlock);
|
|
||||||
currentBlock = new Block(lineType);
|
|
||||||
currentBlock.addLine(lineIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Block> getList() {
|
|
||||||
if(currentBlock != null) {
|
|
||||||
blocks.add(currentBlock);
|
|
||||||
}
|
|
||||||
currentBlock = null;
|
|
||||||
return blocks;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,158 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum BlockType {
|
|
||||||
|
|
||||||
H1("Heading 1", true),
|
|
||||||
H2("Heading 2", true),
|
|
||||||
H3("Heading 3", true),
|
|
||||||
H4("Heading 4", true),
|
|
||||||
H5("Heading 5", true),
|
|
||||||
H6("Heading 6", true),
|
|
||||||
LIST("List", false),
|
|
||||||
BLANK("Blank line", true),
|
|
||||||
P("Paragraph", false),
|
|
||||||
TABLE("Table", false),
|
|
||||||
PARSER("Parser", false),
|
|
||||||
HR("Horizontal rule", false),
|
|
||||||
CONTENT("Content", false),
|
|
||||||
COMMENT("Comment", false);
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
private boolean oneLined;
|
|
||||||
|
|
||||||
BlockType(String string, boolean oneLined) {
|
|
||||||
this.description = string;
|
|
||||||
this.oneLined = oneLined;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BlockType getBlockType(String line) {
|
|
||||||
if(line.isEmpty()) {
|
|
||||||
return BlockType.BLANK;
|
|
||||||
}
|
|
||||||
if(lineIsH1(line)) {
|
|
||||||
return BlockType.H1;
|
|
||||||
}
|
|
||||||
if(lineIsH2(line)) {
|
|
||||||
return BlockType.H2;
|
|
||||||
}
|
|
||||||
if(lineIsH3(line)) {
|
|
||||||
return BlockType.H3;
|
|
||||||
}
|
|
||||||
if(lineIsH4(line)) {
|
|
||||||
return BlockType.H4;
|
|
||||||
}
|
|
||||||
if(lineIsH5(line)) {
|
|
||||||
return BlockType.H5;
|
|
||||||
}
|
|
||||||
if(lineIsH6(line)) {
|
|
||||||
return BlockType.H6;
|
|
||||||
}
|
|
||||||
if(lineIsList(line)) {
|
|
||||||
return BlockType.LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lineIsTable(line)) {
|
|
||||||
return BlockType.TABLE;
|
|
||||||
}
|
|
||||||
if(lineIsParser(line)) {
|
|
||||||
return BlockType.PARSER;
|
|
||||||
}
|
|
||||||
if(lineIsHR(line)) {
|
|
||||||
return BlockType.HR;
|
|
||||||
}
|
|
||||||
if(lineIsComment(line)) {
|
|
||||||
return BlockType.COMMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return BlockType.P;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsH1(String line) {
|
|
||||||
return line.startsWith(WikiMarks.HEADING1_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsH2(String line) {
|
|
||||||
return line.startsWith(WikiMarks.HEADING2_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsH3(String line) {
|
|
||||||
return line.startsWith(WikiMarks.HEADING3_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsH4(String line) {
|
|
||||||
return line.startsWith(WikiMarks.HEADING4_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsH5(String line) {
|
|
||||||
return line.startsWith(WikiMarks.HEADING5_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsH6(String line) {
|
|
||||||
return line.startsWith(WikiMarks.HEADING6_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsList(String line) {
|
|
||||||
line = " " + line.trim();
|
|
||||||
return line.startsWith(WikiMarks.UNORDERED_LIST) || line.startsWith(WikiMarks.ORDERED_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsTable(String line) {
|
|
||||||
return line.startsWith(WikiMarks.TABLE_BORDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsParser(String line) {
|
|
||||||
return line.startsWith(WikiMarks.PARSER_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsHR(String line) {
|
|
||||||
return line.startsWith(WikiMarks.HORIZONTAL_RULE_4);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean lineIsComment(String line) {
|
|
||||||
return line.startsWith(WikiMarks.COMMENT_LINE_BEGINNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOneLined() {
|
|
||||||
return this.oneLined;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isIn(BlockType blockType, BlockType... blockTypes) {
|
|
||||||
for (BlockType e : blockTypes) {
|
|
||||||
if(e == blockType) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*/
|
|
||||||
public class HtmlTags {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger for this class.
|
|
||||||
*/
|
|
||||||
private static final org.nanoboot.powerframework.log.Logger LOG = org.nanoboot.powerframework.log.Logger.getLogger(HtmlTags.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant description
|
|
||||||
*/
|
|
||||||
private static final String CONSTANT = "constant";
|
|
||||||
|
|
||||||
static final String B_START = "<b>";
|
|
||||||
public static final String B_END = "</b>";
|
|
||||||
public static final String I_START = "<i>";
|
|
||||||
public static final String I_END = "</i>";
|
|
||||||
public static final String U_START = "<u>";
|
|
||||||
public static final String U_END = "</u>";
|
|
||||||
public static final String COLOURED_START = "<span style=\"colour:%s\">";
|
|
||||||
public static final String COLOURED_END = "</span>";
|
|
||||||
public static final String BACKGROUND_HIGHLIGHTED_START = "<span style=\"background-colour:%s\">";
|
|
||||||
public static final String BACKGROUND_HIGHLIGHTED_END = "</span>";
|
|
||||||
public static final String SUPER_SCRIPT_START = "<sup>";
|
|
||||||
public static final String SUPER_SCRIPT_END = "</sup>";
|
|
||||||
public static final String SUB_SCRIPT_START = "<sub>";
|
|
||||||
public static final String SUB_SCRIPT_END = "</sub>";
|
|
||||||
public static final String MONOSPACE_START = "<span style=\"font-family: monospace, monospace;\">";
|
|
||||||
public static final String MONOSPACE_SCRIPT_END = "</span>";
|
|
||||||
public static final String STROKE_START = "<span style=\"text-decoration: line-through;\">";
|
|
||||||
public static final String STROKE_END = "</span>";
|
|
||||||
public static final String SMALLER_START = "<span style=\"font-size: 60%;\">";
|
|
||||||
public static final String SMALLER_END = "</span>";
|
|
||||||
public static final String LARGER_START = "<span style=\"font-size:140%;\">";
|
|
||||||
public static final String LARGER_END = "</span>";
|
|
||||||
public static final String LINK = "<a href=\"%s\">%s</a>";
|
|
||||||
public static final String EMBED_IMG = "<img src=\"%s\" alt=\"%s\">";
|
|
||||||
public static final String SIZE_START = "<span style=\"font-size:%s;\">";
|
|
||||||
public static final String SIZE_END = "</span>";
|
|
||||||
|
|
||||||
public static final String H1_START = "<h1>";
|
|
||||||
public static final String H1_END = "</h1>";
|
|
||||||
public static final String H2_START = "<h2>";
|
|
||||||
public static final String H2_END = "</h2>";
|
|
||||||
public static final String H3_START = "<h3>";
|
|
||||||
public static final String H3_END = "</h3>";
|
|
||||||
public static final String H4_START = "<h4>";
|
|
||||||
public static final String H4_END = "</h4>";
|
|
||||||
public static final String H5_START = "<h5>";
|
|
||||||
public static final String H5_END = "</h5>";
|
|
||||||
public static final String H6_START = "<h6>";
|
|
||||||
public static final String H6_END = "</h6>";
|
|
||||||
|
|
||||||
public static final String OL_START = "<ol>";
|
|
||||||
public static final String OL_END = "</ol>";
|
|
||||||
public static final String UL_START = "<ul>";
|
|
||||||
public static final String UL_END = "</ul>";
|
|
||||||
public static final String LI_START = "<li>";
|
|
||||||
public static final String LI_END = "</li>";
|
|
||||||
public static final String P_START = "<p>";
|
|
||||||
public static final String P_END = "</p>";
|
|
||||||
|
|
||||||
public static final String TABLE_START = "<table>";
|
|
||||||
public static final String TABLE_END = "</table>";
|
|
||||||
public static final String TR_START = "<tr>";
|
|
||||||
public static final String TR_END = "</tr>";
|
|
||||||
public static final String TH_START = "<th>";
|
|
||||||
public static final String TH_END = "</th>";
|
|
||||||
public static final String TD_START = "<td>";
|
|
||||||
public static final String TD_END = "</td>";
|
|
||||||
|
|
||||||
public static final String HR4 = "<hr style=\"height: 1px;\">";
|
|
||||||
public static final String HR5 = "<hr style=\"height: 2px;\">";
|
|
||||||
public static final String HR6 = "<hr style=\"height: 3px;\">";
|
|
||||||
public static final String HR7 = "<hr style=\"height: 4px;\">";
|
|
||||||
public static final String HR8 = "<hr style=\"height: 5px;\">";
|
|
||||||
public static final String HR9 = "<hr style=\"height: 6px;\">";
|
|
||||||
public static final String HR10 = "<hr style=\"height: 7px;\">";
|
|
||||||
|
|
||||||
public static final String COMMENT_TEMPLATE = "<!-- %s -->";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* Not meant to be instantiated.
|
|
||||||
*/
|
|
||||||
private HtmlTags() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class Macro {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger for this class.
|
|
||||||
*/
|
|
||||||
private static final org.nanoboot.powerframework.log.Logger LOG = org.nanoboot.powerframework.log.Logger.getLogger(Macro.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant description
|
|
||||||
*/
|
|
||||||
private static final String CONSTANT = "constant";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Field description
|
|
||||||
*/
|
|
||||||
private String content;
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* Constructor description
|
|
||||||
*/
|
|
||||||
public Macro(String content, TextProcessorI processor) {
|
|
||||||
this.content = content;
|
|
||||||
this.value = processor.process(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class StringSource {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger for this class.
|
|
||||||
*/
|
|
||||||
private static final org.nanoboot.powerframework.log.Logger LOG = org.nanoboot.powerframework.log.Logger.getLogger(StringSource.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant description
|
|
||||||
*/
|
|
||||||
private static final String CONSTANT = "constant";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Field description
|
|
||||||
*/
|
|
||||||
private String string;
|
|
||||||
private int position = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public StringSource(String string) {
|
|
||||||
this.string = string;
|
|
||||||
}
|
|
||||||
|
|
||||||
public char getNext() {
|
|
||||||
return string.charAt(position++);
|
|
||||||
}
|
|
||||||
|
|
||||||
public char getLast() {
|
|
||||||
if(position - 1 == 0) {
|
|
||||||
return ' ';
|
|
||||||
}
|
|
||||||
return string.charAt(position - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasNext() {
|
|
||||||
return position <= string.length() - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public char get(int number) {
|
|
||||||
return string.charAt(position + number);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TextFormatter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger for this class.
|
|
||||||
*/
|
|
||||||
private static final org.nanoboot.powerframework.log.Logger LOG = org.nanoboot.powerframework.log.Logger.getLogger(TextFormatter.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant description
|
|
||||||
*/
|
|
||||||
private static final String CONSTANT = "constant";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Field description
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* Not meant to be instantiated.
|
|
||||||
*/
|
|
||||||
private TextFormatter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String format(String text) {
|
|
||||||
StringSource stringSource = new StringSource(text);
|
|
||||||
StringBuilder out = new StringBuilder();
|
|
||||||
StringBuilder buffer = new StringBuilder();
|
|
||||||
while (stringSource.hasNext()) {
|
|
||||||
char ch = stringSource.getNext();
|
|
||||||
|
|
||||||
if(ch == '[' && stringSource.getLast() == '[') {
|
|
||||||
ch = stringSource.getNext();
|
|
||||||
while (!(ch == ']' && stringSource.get(1) == ']')) {
|
|
||||||
buffer.append(ch);
|
|
||||||
if(!stringSource.hasNext()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ch = stringSource.getNext();
|
|
||||||
}
|
|
||||||
out.append(buffer.toString());
|
|
||||||
buffer.delete(0, buffer.length());
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return out.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*/
|
|
||||||
public interface TextProcessorI {
|
|
||||||
|
|
||||||
public String process(String text);
|
|
||||||
|
|
||||||
public String getName();
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
import org.nanoboot.powerframework.core.PowerException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class WikiException extends PowerException {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger for this class.
|
|
||||||
*/
|
|
||||||
private static final org.nanoboot.powerframework.log.Logger LOG = org.nanoboot.powerframework.log.Logger.getLogger(WikiException.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant description
|
|
||||||
*/
|
|
||||||
private static final String CONSTANT = "constant";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Field description
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public WikiException(String messageIn) {
|
|
||||||
super(messageIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class WikiMarks {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger for this class.
|
|
||||||
*/
|
|
||||||
private static final org.nanoboot.powerframework.log.Logger LOG = org.nanoboot.powerframework.log.Logger.getLogger(WikiMarks.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant description
|
|
||||||
*/
|
|
||||||
private static final String CONSTANT = "constant";
|
|
||||||
|
|
||||||
public static final String BOLD = "\\*\\*";
|
|
||||||
public static final String ITALIC = "//";
|
|
||||||
public static final String UNDERLINED = "__";
|
|
||||||
public static final String COLOURED = "$$";
|
|
||||||
public static final String BACKGROUND_HIGHLIGHTED = "##";
|
|
||||||
public static final String SUPERSCRIPT = "^";
|
|
||||||
public static final String SUBSCRIPT = ",,";
|
|
||||||
public static final String MONOSPACE = "`";
|
|
||||||
public static final String STROKE = "--";
|
|
||||||
public static final String SMALLER_START = "~-";
|
|
||||||
public static final String SMALLER_END = "-~";
|
|
||||||
public static final String LARGER_START = "~+";
|
|
||||||
public static final String LARGER_END = "+~";
|
|
||||||
|
|
||||||
public static final String LINK_START = "[[";
|
|
||||||
public static final String LINK_END = "]]";
|
|
||||||
public static final String EMBED_START = "{{";
|
|
||||||
public static final String EMBED_END = "}}";
|
|
||||||
public static final String SIZE = "&&";
|
|
||||||
|
|
||||||
public static final String MACRO_START = "<<";
|
|
||||||
public static final String MACRO_END = ">>";
|
|
||||||
|
|
||||||
public static final String PARSER_START = "{{{";
|
|
||||||
public static final String PARSER_END = "}}}";
|
|
||||||
|
|
||||||
public static final String HEADING1_START = "= ";
|
|
||||||
public static final String HEADING2_START = "== ";
|
|
||||||
public static final String HEADING3_START = "=== ";
|
|
||||||
public static final String HEADING4_START = "==== ";
|
|
||||||
public static final String HEADING5_START = "===== ";
|
|
||||||
public static final String HEADING6_START = "====== ";
|
|
||||||
public static final String HEADING1_END = " =";
|
|
||||||
public static final String HEADING2_END = " ==";
|
|
||||||
public static final String HEADING3_END = " ===";
|
|
||||||
public static final String HEADING4_END = " ====";
|
|
||||||
public static final String HEADING5_END = " =====";
|
|
||||||
public static final String HEADING6_END = " ======";
|
|
||||||
public static final String UNORDERED_LIST = " *";
|
|
||||||
public static final String ORDERED_LIST = " 1.";
|
|
||||||
public static final String TABLE_BORDER = " || ";
|
|
||||||
public static final String TABLE_COLOURED = "$$$";
|
|
||||||
public static final String TABLE_BACKGROUND_HIGHLIGHTED = "###";
|
|
||||||
|
|
||||||
public static final String HORIZONTAL_RULE_4 = "----";
|
|
||||||
public static final String HORIZONTAL_RULE_5 = "-----";
|
|
||||||
public static final String HORIZONTAL_RULE_6 = "------";
|
|
||||||
public static final String HORIZONTAL_RULE_7 = "-------";
|
|
||||||
public static final String HORIZONTAL_RULE_8 = "--------";
|
|
||||||
public static final String HORIZONTAL_RULE_9 = "---------";
|
|
||||||
public static final String HORIZONTAL_RULE_10 = "----------";
|
|
||||||
public static final String COMMENT_LINE_BEGINNING = "####";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Field description
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* Not meant to be instantiated.
|
|
||||||
*/
|
|
||||||
private WikiMarks() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,192 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.nanoboot.powerframework.utils.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class WikiParser {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger for this class.
|
|
||||||
*/
|
|
||||||
//private static final org.nanoboot.powerframework.logging.Logger LOG = org.nanoboot.powerframework.logging.Logger.getLogger(WikiParser.class);
|
|
||||||
/**
|
|
||||||
* Constant description
|
|
||||||
*/
|
|
||||||
private static final String CONSTANT = "constant";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Field description
|
|
||||||
*/
|
|
||||||
private static TextProcessorI linkProcessor;
|
|
||||||
private static final Map<String, TextProcessorI> macroProcessorsList = new HashMap<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* Not meant to be instantiated.
|
|
||||||
*/
|
|
||||||
public static void setLinkProcessor(TextProcessorI linkProcessorIn) {
|
|
||||||
linkProcessor = linkProcessorIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String convertWiki(String wikiText) {
|
|
||||||
System.out.println("Converting wiki text:\n\n"+wikiText);
|
|
||||||
ArrayList<Block> blocks = splitWikiTextToBlocks(wikiText);
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
for (Block block : blocks) {
|
|
||||||
System.out.println("\n====================\n"+block.getBlockType()+"\n\n");
|
|
||||||
String html = block.toHtml();
|
|
||||||
System.out.println(block.getOrig());
|
|
||||||
System.out.println("VVVVVVVVVVVVVVVVVVVV");
|
|
||||||
System.out.println(html);
|
|
||||||
stringBuilder.append(html).append('\n').append('\n');
|
|
||||||
}
|
|
||||||
String string = stringBuilder.toString();
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStyle(String string) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMacroProcessor(TextProcessorI macroProcessor) {
|
|
||||||
macroProcessorsList.put(macroProcessor.getName(), macroProcessor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextProcessorI getMacroProcessor(String macroName) {
|
|
||||||
return macroProcessorsList.get(macroName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String convert(String wikiText) {
|
|
||||||
|
|
||||||
//System.err.println("\n\n\nWIKI" + "\n{\n" + wikiText + "\n}######$$$");
|
|
||||||
while (true) {
|
|
||||||
if(wikiText.contains(WikiMarks.BOLD)) {
|
|
||||||
wikiText = wikiText.replaceFirst(WikiMarks.BOLD, HtmlTags.B_START);
|
|
||||||
//System.err.println(String.format("Replacing %s by %s", BOLD, B_START));
|
|
||||||
}
|
|
||||||
if(wikiText.contains(WikiMarks.BOLD)) {
|
|
||||||
wikiText = wikiText.replaceFirst(WikiMarks.BOLD, HtmlTags.B_END);
|
|
||||||
//System.err.println(String.format("Replacing %s by %s", BOLD, B_END));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!wikiText.contains(WikiMarks.BOLD)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
|
|
||||||
if(wikiText.contains(WikiMarks.ITALIC)) {
|
|
||||||
wikiText = wikiText.replaceFirst(WikiMarks.ITALIC, HtmlTags.I_START);
|
|
||||||
//System.err.println(String.format("Replacing %s by %s", ITALIC, I_START));
|
|
||||||
}
|
|
||||||
if(wikiText.contains(WikiMarks.ITALIC)) {
|
|
||||||
wikiText = wikiText.replaceFirst(WikiMarks.ITALIC, HtmlTags.I_END);
|
|
||||||
//System.err.println(String.format("Replacing %s by %s", ITALIC, I_END));
|
|
||||||
}
|
|
||||||
if(!wikiText.contains(WikiMarks.ITALIC)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
ArrayList<Block> blocks = splitWikiTextToBlocks(wikiText);
|
|
||||||
|
|
||||||
// StringBuilder stringBuilder2 = new StringBuilder("Adding block\n\n");
|
|
||||||
// for (Block block : blocks) {
|
|
||||||
// stringBuilder2.append("\n###{\n").append(block.toHtml()).append("\n}\n");
|
|
||||||
// }
|
|
||||||
//System.err.println(stringBuilder2);
|
|
||||||
// try {
|
|
||||||
// Thread.sleep(10000);
|
|
||||||
// } catch (InterruptedException ex) {
|
|
||||||
// Logger.getLogger(WikiParser.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
// }
|
|
||||||
for (Block block : blocks) {
|
|
||||||
String html = block.toHtml();
|
|
||||||
|
|
||||||
stringBuilder.append(html).append('\n').append('\n');
|
|
||||||
}
|
|
||||||
String string = stringBuilder.toString();
|
|
||||||
//System.out.println("Wiki convertor returned\n\n\n{\n" + string + "\n}\n\n\n");
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private String processText(String text) {
|
|
||||||
StringSource stringSource = new StringSource(text);
|
|
||||||
StringBuilder out = new StringBuilder();
|
|
||||||
StringBuilder buffer = new StringBuilder();
|
|
||||||
while (stringSource.hasNext()) {
|
|
||||||
char ch = stringSource.getNext();
|
|
||||||
|
|
||||||
if(ch == '[' && stringSource.getLast() == '[') {
|
|
||||||
ch = stringSource.getNext();
|
|
||||||
while (!(ch == ']' && stringSource.get(1) == ']')) {
|
|
||||||
buffer.append(ch);
|
|
||||||
if(!stringSource.hasNext()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ch = stringSource.getNext();
|
|
||||||
}
|
|
||||||
out.append(buffer.toString());
|
|
||||||
buffer.delete(0, buffer.length());
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return out.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static void replaceOccurences(StringBuilder stringBuilder, String what, String replacement) {
|
|
||||||
Pattern.compile(what).matcher(stringBuilder).replaceAll(replacement);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<Block> splitWikiTextToBlocks(String wikiText) {
|
|
||||||
BlockList blockList = new BlockList();
|
|
||||||
|
|
||||||
ArrayList<Block> blocks;
|
|
||||||
String[] lines = StringUtils.toLines(wikiText);
|
|
||||||
|
|
||||||
for (String line : lines) {
|
|
||||||
blockList.addLine(line);
|
|
||||||
}
|
|
||||||
blocks = blockList.getList();
|
|
||||||
|
|
||||||
return blocks;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// power-framework: Java library with many purposes of usage.
|
|
||||||
// Copyright (C) 2016-2022 the original author or authors.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation;
|
|
||||||
// version 2.1 of the License only.
|
|
||||||
//
|
|
||||||
// This library 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
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package org.nanoboot.powerframework.wiki.convertors;
|
|
||||||
|
|
||||||
import org.nanoboot.powerframework.core.PowerObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here goes the description of this class.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
|
||||||
* @since 0.0.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ListConvertor extends PowerObject {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logger for this class.
|
|
||||||
*/
|
|
||||||
private static final org.nanoboot.powerframework.log.Logger LOG = org.nanoboot.powerframework.log.Logger.getLogger(ListConvertor.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant description
|
|
||||||
*/
|
|
||||||
private static final String CONSTANT = "constant";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Field description
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* Not meant to be instantiated.
|
|
||||||
*/
|
|
||||||
private ListConvertor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* Constructor description
|
|
||||||
*
|
|
||||||
* @param nameIn
|
|
||||||
*/
|
|
||||||
public ListConvertor(String nameIn) {
|
|
||||||
this.name = nameIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter for name.
|
|
||||||
*
|
|
||||||
* @param nameIn
|
|
||||||
*/
|
|
||||||
public void setName(String nameIn) {
|
|
||||||
LOG.traceStartOfMethod(this, "setName", "name", name);
|
|
||||||
this.name = nameIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for name.
|
|
||||||
*
|
|
||||||
* @return name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
LOG.traceStartOfMethod(this, "getName");
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user