Index: jrst2/src/java/org/codelutin/jrst/JRSTLexer.java diff -u jrst2/src/java/org/codelutin/jrst/JRSTLexer.java:1.30 jrst2/src/java/org/codelutin/jrst/JRSTLexer.java:1.31 --- jrst2/src/java/org/codelutin/jrst/JRSTLexer.java:1.30 Wed Jun 6 12:20:36 2007 +++ jrst2/src/java/org/codelutin/jrst/JRSTLexer.java Wed Jun 20 14:04:23 2007 @@ -23,9 +23,9 @@ * Created: 28 oct. 06 00:44:20 * * @author poussin - * @version $Revision: 1.30 $ + * @version $Revision: 1.31 $ * - * Last update: $Date: 2007/06/06 12:20:36 $ + * Last update: $Date: 2007/06/20 14:04:23 $ * by : $Author: sletellier $ */ @@ -43,7 +43,6 @@ import org.dom4j.DocumentHelper; import org.dom4j.Element; - /** * Le principe est de positionner la mark du {@link AdvancedReader} lors du * debut d'une methode peek*, puis a la fin de la methode de regarder le nombre @@ -56,112 +55,150 @@ *
* Pour mettre en place ce mecanisme le plus simple est d'utiliser les methodes * {@link JRSTLexer#beginPeek()} et {@link JRSTLexer#endPeek()} - * - * - * + * + * + * * @author poussin, letellier */ public class JRSTLexer { - + /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(JRSTLexer.class); - static final public String BULLET_CHAR = "*" + "+" + "-"/* + "\u2022" + "\u2023" + "\u2043"*/; + + static final public String BULLET_CHAR = "*" + "+" + "-"/* + * + "\u2022" + + * "\u2023" + + * "\u2043" + */; + static final public String TITLE_CHAR = "-=-~'`^+:!\"#$%&*,./;|?@\\_[\\]{}<>()"; - static final public String DOCINFO_ITEM = - "author|authors|organization|address|contact|version|revision|status|date|copyright"; + + static final public String DOCINFO_ITEM = "author|authors|organization|address|contact|version|revision|status|date|copyright"; + public static final String ADMONITION_PATTERN = "admonition|attention|caution|danger|error|hint|important|note|tip|warning"; - - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Title Elements - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + static final public String TITLE = "title"; - - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Bibliographic Elements - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + static final public String DOCINFO = "docinfo"; - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Decoration Elements - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + public static final String DECORATION = "decoration"; + public static final String HEADER = "header"; + public static final String FOOTER = "footer"; - - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Structural Elements - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + static final public String TRANSITION = "transition"; + public static final String SIDEBAR = "sidebar"; + public static final String TOPIC = "topic"; - - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Body Elements - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + static final public String LITERAL_BLOCK = "literal_block"; + static final public String PARAGRAPH = "paragraph"; + static final public String BLANK_LINE = "blankLine"; + static final public String SUBSTITUTION_DEFINITION = "substitution_definition"; + static final public String BULLET_LIST = "bullet_list"; + static final public String FIELD_LIST = "field_list"; + static final public String DEFINITION_LIST = "definition_list"; + static final public String ENUMERATED_LIST = "enumerated_list"; + static final public String OPTION_LIST = "option_list"; + public static final String LINE_BLOCK = "line_block"; + public static final String LINE = "line"; + public static final String BLOCK_QUOTE = "block_quote"; + public static final String ATTRIBUTION = "attribution"; + public static final String DOCTEST_BLOCK = "doctest_block"; + public static final String ADMONITION = "admonition"; + public static final String TARGET = "target"; + public static final String FOOTNOTE = "footnote"; - - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Table Elements - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + static final public String TABLE = "table"; + static final public String ROW = "row"; + static final public String CELL = "cell"; + static final public String TABLE_HEADER = "header"; + static final public String TABLE_WIDTH = "width"; + static final public String ROW_END_HEADER = "endHeader"; + static final public String CELL_INDEX_START = "indexStart"; + static final public String CELL_INDEX_END = "indexEnd"; + static final public String CELL_BEGIN = "begin"; + static final public String CELL_END = "end"; - - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Directive Elements - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + static final public String DIRECTIVE = "directive"; + static final public String DIRECTIVE_TYPE = "type"; + static final public String DIRECTIVE_VALUE = "value"; - - + /** - * retient le niveau du titre, pour un titre de type double, on met - * deux fois le caratere dans la chaine, sinon on le met une seul fois. - * + * retient le niveau du titre, pour un titre de type double, on met deux + * fois le caratere dans la chaine, sinon on le met une seul fois. + * *
* =====
* Super
* =====
- *
* titre
* -----
*
- *
+ *
* donnera dans la liste ["==", "-"]
*/
private List
* .. header:: This space for rent. aaaa **aaaa**
*
- *
+ *
* @return Element
* @throws IOException
*/
public Element peekHeader() throws IOException {
- beginPeek();
- Element result = null;
- String[] line = in.readAll();
- if (line != null){
- int i=0;
- for (String l : line){
- i++;
- if (l.matches("^\\s*.. "+HEADER+":: .*")){
- int level = level(l);
- l=l.replaceAll("^\\s*.. "+HEADER+":: ", "");
- result = DocumentHelper.createElement(HEADER).addAttribute("level", String.valueOf(level));
- result.addAttribute("line", ""+i);
- result.setText(l);
- }
-
- }
- }
- endPeek();
- return result;
-
+ beginPeek();
+ Element result = null;
+ String[] line = in.readAll();
+ if (line != null) {
+ int i = 0;
+ for (String l : line) {
+ i++;
+ if (l.matches("^\\s*.. " + HEADER + ":: .*")) {
+ int level = level(l);
+ l = l.replaceAll("^\\s*.. " + HEADER + ":: ", "");
+ result = DocumentHelper.createElement(HEADER).addAttribute(
+ "level", String.valueOf(level));
+ result.addAttribute("line", "" + i);
+ result.setText(l);
+ }
+
+ }
+ }
+ endPeek();
+ return result;
+
}
+
/**
* search if the doc have an header
+ *
*
* .. footer:: design by **LETELLIER Sylvain**
*
- *
+ *
* @return Element
* @throws IOException
*/
@@ -307,53 +359,60 @@
beginPeek();
Element result = null;
String[] line = in.readAll();
- if (line != null){
- int i=0;
- for (String l : line){
+ if (line != null) {
+ int i = 0;
+ for (String l : line) {
i++;
-
- if (l.matches("^\\s*.. "+FOOTER+":: .*")){
+
+ if (l.matches("^\\s*.. " + FOOTER + ":: .*")) {
int level = level(l);
- l=l.replaceAll("^\\s*.. "+FOOTER+":: ", "");
- result = DocumentHelper.createElement(FOOTER).addAttribute("level", String.valueOf(level));
- result.addAttribute("line", ""+i);
+ l = l.replaceAll("^\\s*.. " + FOOTER + ":: ", "");
+ result = DocumentHelper.createElement(FOOTER).addAttribute(
+ "level", String.valueOf(level));
+ result.addAttribute("line", "" + i);
result.setText(l);
}
}
}
endPeek();
return result;
-
+
}
+
/**
+ *
* .. __: http://www.python.org
+ *
* @return Element
- * @throws IOException
+ * @throws IOException
*/
- public LinkedList
* :author: Benjamin Poussin
* :address:
* Quelque part
* Dans le monde
*
- *
+ *
* @return Element
* @throws IOException
*/
@@ -388,13 +448,11 @@
Element result = null;
if (result == null) {
result = peekDocInfoItem();
-
+
}
if (result == null) {
result = peekFieldList();
}
-
-
return result;
@@ -402,6 +460,7 @@
/**
* Return para
+ *
* @return Element
* @throws IOException
*/
@@ -414,19 +473,19 @@
result = peekComment();
}
if (result == null) {
- result = peekDoctestBlock();
+ result = peekDoctestBlock();
}
if (result == null) {
result = peekAdmonition();
}
if (result == null) {
- result = peekSidebar();
+ result = peekSidebar();
}
if (result == null) {
- result = peekTopic();
+ result = peekTopic();
}
if (result == null) {
- result = peekRemove();
+ result = peekRemove();
}
if (result == null) {
result = peekDirectiveOrReference();
@@ -468,7 +527,7 @@
result = peekLiteralBlock();
}
if (result == null) {
- result = peekBlockQuote();
+ result = peekBlockQuote();
}
if (result == null) {
result = peekBlankLine();
@@ -476,36 +535,40 @@
if (result == null) {
result = peekPara();
}
-
-
return result;
}
+
/**
- * Elements already read
+ * Remove already read elements
*
* @return Element
* @throws IOException
*/
public Element peekRemove() throws IOException {
- beginPeek();
- Element result = null;
- String line = in.readLine();
- if (line != null){
- // Le header est parse des le debut
- if (line.matches("^\\s*.. "+HEADER+":: .*")){
- result= DocumentHelper.createElement("remove").addAttribute("level", ""+level(line));
- }
- if (line.matches("^\\s*.. "+FOOTER+":: .*")){
- result= DocumentHelper.createElement("remove").addAttribute("level", ""+level(line));
+ beginPeek();
+ Element result = null;
+ String line = in.readLine();
+ if (line != null) {
+ // Le header est parse des le debut
+ if (line.matches("^\\s*.. " + HEADER + ":: .*")) {
+ result = DocumentHelper.createElement("remove").addAttribute(
+ "level", "" + level(line));
+ }
+ // Le footer
+ if (line.matches("^\\s*.. " + FOOTER + ":: .*")) {
+ result = DocumentHelper.createElement("remove").addAttribute(
+ "level", "" + level(line));
}
- }
- endPeek();
- return result;
- }
+ }
+ endPeek();
+ return result;
+ }
+
/**
* read include
+ *
*
* .. include:: text.txt
* or
@@ -513,204 +576,220 @@
* text.txt
*
*
- *
+ *
* @return Element
- * @throws IOException
+ * @throws IOException
*/
- private Element peekInclude() throws IOException{
+ private Element peekInclude() throws IOException {
beginPeek();
Element result = null;
String line = in.readLine();
- if (line != null){
- if (line.matches("^\\s*\\.\\.\\sinclude\\:\\:.+$")){
+ if (line != null) {
+ if (line.matches("^\\s*\\.\\.\\sinclude\\:\\:.+$")) {
result = DocumentHelper.createElement("include");
- result.addAttribute("level",""+level(line));
- String option = line.substring(line.indexOf("::")+2).trim();
+ result.addAttribute("level", "" + level(line));
+ String option = line.substring(line.indexOf("::") + 2).trim();
result.addAttribute("option", "");
- if (option.trim().equalsIgnoreCase("literal")){
+ if (option.trim().equalsIgnoreCase("literal")) {
result.addAttribute("option", "literal");
line = in.readLine();
result.setText(line.trim());
- }
- else
+ } else
result.setText(option);
-
+
}
}
endPeek();
return result;
}
+
/**
* read options
+ *
* - * -a command-line option "a" - * -1 file, --one=file, --two file - * Multiple options with arguments. - *+ * Ex : -a command-line option "a" + * -1 file, --one=file, --two file + * Multiple options with arguments. + * + * Schéma : ________________________________ + * v | | + * -{1,2}\w+ ->|',' | + * |'='-----|-> \w+ --->|',' + * |' '-----| |' '---+ + * |" " -----> \w+ ---> end | + * ^ | + * |_________________________| * + * Légende : + * + * -{1,2} --> 1 or 2 tirets + * \w+ -----> word characters one or more times + * + * * @return Element - * @throws IOException + * @throws IOException */ - public Element peekOption() throws IOException { - /* - -a command-line option "a" - -1 file, --one=file, --two file - Multiple options with arguments. - - ________________________________ - v | | - -{1,2}\w+ ->|',' | - |'='-----|-> \w+ --->|',' - |' '-----| |' '---+ - |" " -----> \w+ ---> end | - ^ | - |_________________________| - - -{1,2} --> 1 or 2 tirets - \w+ ------> word characters one or more times - - */ - beginPeek(); - Element result = null; - String line = in.readLine(); - if (line != null){ - if (line.matches("^(\\s*-{1,2}.+\\s+.*)+\\s+.+$")){ - result = DocumentHelper.createElement(OPTION_LIST).addAttribute("level", ""+level(line)); - char delimiter; - do{ - Matcher matcher = Pattern.compile("-{1,2}.+").matcher(line); - matcher.find(); - Element option=result.addElement("option"); - String option_stringTmp=matcher.group(); - matcher = Pattern.compile("^-{1,2}\\w+").matcher(option_stringTmp); - matcher.find(); - String option_string=matcher.group(); - option.addAttribute("option_string", option_string); - delimiter=option_stringTmp.charAt(matcher.end()); - option_stringTmp=option_stringTmp.substring(matcher.end(), option_stringTmp.length()); + public Element peekOption() throws IOException { + + beginPeek(); + Element result = null; + String line = in.readLine(); + if (line != null) { + if (line.matches("^(\\s*-{1,2}[^\\s-].+\\s+.*)+\\s+.+$")) { + result = DocumentHelper.createElement(OPTION_LIST) + .addAttribute("level", "" + level(line)); + char delimiter; + do { + Matcher matcher = Pattern.compile("-{1,2}.+").matcher(line); + matcher.find(); + Element option = result.addElement("option"); + String option_stringTmp = matcher.group(); + matcher = Pattern.compile("^-{1,2}\\w+").matcher( + option_stringTmp); + matcher.find(); + String option_string = matcher.group(); + option.addAttribute("option_string", option_string); + delimiter = option_stringTmp.charAt(matcher.end()); + option_stringTmp = option_stringTmp.substring( + matcher.end(), option_stringTmp.length()); option.addAttribute("delimiterExiste", "false"); - boolean done=false; - if (delimiter==' '){ // S'il ya 2 espace a suivre, l'option est finit - if (option_stringTmp.charAt(1)==' '){ - done=true; - } - } - if ((delimiter=='=' || delimiter==' ')&&!done){ - option.addAttribute("delimiterExiste", "true"); - option.addAttribute("delimiter", ""+delimiter); - matcher = Pattern.compile(delimiter+"\\w+").matcher(option_stringTmp); - String option_argument; - if (matcher.find()){ - option_argument= matcher.group().substring(1, matcher.group().length()); - option.addAttribute("option_argument", option_argument); - if (option_stringTmp.charAt(option_argument.length()+1)==','){ - delimiter = ','; - line=line.substring(option_string.length()+option_argument.length()+3,line.length()); - } - else - done=true; - } - else{ // Si la description n'est pas sur la meme ligne - option_argument=option_stringTmp; - option.addAttribute("option_argument", option_argument); - line = in.readLine(); - result.setText(line.trim()); - } - } - if (done) - result.setText(option_stringTmp.substring(matcher.end(),option_stringTmp.length()).trim()); - }while (delimiter==','); - } - } - endPeek(); - return result; - } - /** + boolean done = false; + if (delimiter == ' ') { // S'il ya 2 espace a suivre, + // l'option est finit + if (option_stringTmp.charAt(1) == ' ') { + done = true; + } + } + if ((delimiter == '=' || delimiter == ' ') && !done) { + option.addAttribute("delimiterExiste", "true"); + option.addAttribute("delimiter", "" + delimiter); + matcher = Pattern.compile(delimiter + "\\w+").matcher( + option_stringTmp); + String option_argument; + if (matcher.find()) { + option_argument = matcher.group().substring(1, + matcher.group().length()); + option.addAttribute("option_argument", + option_argument); + if (option_stringTmp.charAt(option_argument + .length() + 1) == ',') { + delimiter = ','; + line = line.substring(option_string.length() + + option_argument.length() + 3, line + .length()); + } else + done = true; + } else { // Si la description n'est pas sur la meme + // ligne + option_argument = option_stringTmp; + option.addAttribute("option_argument", + option_argument); + line = in.readLine(); + result.setText(line.trim()); + } + } + if (done) + result.setText(option_stringTmp.substring( + matcher.end(), option_stringTmp.length()) + .trim()); + } while (delimiter == ','); + } + } + endPeek(); + return result; + } + + /** * read topic + * *
* -.. topic:: Title
- *
* Body.
*
- *
+ *
* @return Element
* @throws IOException
*/
- private Element peekTopic() throws IOException {
- beginPeek();
- Element result = null;
- String line = in.readLine();
- if (line != null){
- if (line.matches("^\\.\\.\\s*("+TOPIC+")::\\s*(.*)$")){
- Matcher matcher = Pattern.compile(TOPIC+"::").matcher(line);
+ private Element peekTopic() throws IOException {
+ beginPeek();
+ Element result = null;
+ String line = in.readLine();
+ if (line != null) {
+ if (line.matches("^\\.\\.\\s*(" + TOPIC + ")::\\s*(.*)$")) {
+ Matcher matcher = Pattern.compile(TOPIC + "::").matcher(line);
matcher.find();
- result = DocumentHelper.createElement(TOPIC).addAttribute("level", ""+level(line));
- String title = line.substring(matcher.end(),line.length());
- result.addAttribute(TITLE,title);
+ result = DocumentHelper.createElement(TOPIC).addAttribute(
+ "level", "" + level(line));
+ String title = line.substring(matcher.end(), line.length());
+ result.addAttribute(TITLE, title);
line = in.readLine();
if (line.matches("\\s*"))
line = in.readLine();
int level = level(line);
- String [] lines=null;
- if (level!=0) {
- lines=in.readWhile("(^ {"+level+"}.*)|(\\s*)");
- String txt=line;
+ String[] lines = null;
+ if (level != 0) {
+ lines = in.readWhile("(^ {" + level + "}.*)|(\\s*)");
+ String txt = line;
for (String txtTmp : lines)
- txt += "\n"+txtTmp.trim();
- result.setText(txt);
+ txt += "\n" + txtTmp.trim();
+ result.setText(txt);
}
-
- }
- }
-
- endPeek();
- return result;
- }
- /**
+
+ }
+ }
+
+ endPeek();
+ return result;
+ }
+
+ /**
* read sidebar
+ *
*
* .. sidebar:: Title
* :subtitle: If Desired
- *
* Body.
*
- *
+ *
* @return Element
* @throws IOException
*/
- private Element peekSidebar() throws IOException {
- beginPeek();
- Element result = null;
- String line = in.readLine();
- if (line != null){
- if (line.matches("^\\.\\.\\s*("+SIDEBAR+")::\\s*(.*)$")){
- Matcher matcher = Pattern.compile(SIDEBAR+"::").matcher(line);
+ private Element peekSidebar() throws IOException {
+ beginPeek();
+ Element result = null;
+ String line = in.readLine();
+ if (line != null) {
+ if (line.matches("^\\.\\.\\s*(" + SIDEBAR + ")::\\s*(.*)$")) {
+ Matcher matcher = Pattern.compile(SIDEBAR + "::").matcher(line);
matcher.find();
- result = DocumentHelper.createElement(SIDEBAR).addAttribute("level", ""+level(line));
- String title = line.substring(matcher.end(),line.length());
- result.addAttribute(TITLE,title);
+ result = DocumentHelper.createElement(SIDEBAR).addAttribute(
+ "level", "" + level(line));
+ String title = line.substring(matcher.end(), line.length());
+ result.addAttribute(TITLE, title);
line = in.readLine();
- if (line.matches("^\\s+:subtitle:\\s*(.*)$*")){
- matcher = Pattern.compile(":subtitle:\\s*").matcher(line);
- matcher.find();
- String subTitle=line.substring(matcher.end(),line.length());
- result.addAttribute("subExiste", "true");
- result.addAttribute("subtitle",subTitle);
- line = in.readLine();
- }
- else
- result.addAttribute("subExiste", "false");
- String txt = joinBlock(readBlock(level(line)));
- result.setText(txt);
-
- }
- }
-
- endPeek();
- return result;
- }
- /**
+ if (line.matches("^\\s+:subtitle:\\s*(.*)$*")) {
+ matcher = Pattern.compile(":subtitle:\\s*").matcher(line);
+ matcher.find();
+ String subTitle = line.substring(matcher.end(), line
+ .length());
+ result.addAttribute("subExiste", "true");
+ result.addAttribute("subtitle", subTitle);
+ line = in.readLine();
+ } else
+ result.addAttribute("subExiste", "false");
+ String txt = joinBlock(readBlock(level(line)));
+ result.setText(txt);
+
+ }
+ }
+
+ endPeek();
+ return result;
+ }
+
+ /**
* read line block
+ *
*
* | A one, two, a one two three four
* |
@@ -719,108 +798,117 @@
* | But half the bee has got to be,
* | *vis a vis* its entity. D'you see?
*
- *
+ *
* @return Element
* @throws IOException
*/
- private Element peekLineBlock() throws IOException {
- beginPeek();
- Element result = null;
- String line = in.readLine();
- if (line != null){
- if (line.matches("\\|\\s.*")){
- String[] linesTmp = readBlock(0);
- String[] lines = new String[linesTmp.length+1];
- lines[0]=line;
- for (int i=0;i
* As a great paleontologist once said,
*
@@ -828,134 +916,139 @@
*
* -- Anne Elk (Miss)
*
- *
+ *
* @return Element
* @throws IOException
*/
private Element peekBlockQuote() throws IOException {
- beginPeek();
- Element result = null;
- String line = in.readLine();
- if (line != null){
- if (line.matches("\\s*")){
- line=in.readLine();
- if (line!=null){
+ beginPeek();
+ Element result = null;
+ String line = in.readLine();
+ if (line != null) {
+ if (line.matches("\\s*")) {
+ line = in.readLine();
+ if (line != null) {
int level = level(line);
String blockQuote = null;
- if (!(level==0)){
- String txt=line;
- String [] lines=in.readWhile("(^ {"+level+"}.*)|(\\s*)");
- for (String l : lines){
- if (l.matches("^ {"+level+"}--\\s*.*")){
- blockQuote=l;
- blockQuote = blockQuote.replaceAll("--","").trim();
- }
- else
+ if (!(level == 0)) {
+ String txt = line;
+ String[] lines = in.readWhile("(^ {" + level
+ + "}.*)|(\\s*)");
+ for (String l : lines) {
+ if (l.matches("^ {" + level + "}--\\s*.*")) {
+ blockQuote = l;
+ blockQuote = blockQuote.replaceAll("--", "")
+ .trim();
+ } else
txt += "\n" + l;
}
- result = DocumentHelper.createElement(BLOCK_QUOTE).addAttribute("level", String.valueOf(level));
- if (blockQuote!=null)
+ result = DocumentHelper.createElement(BLOCK_QUOTE)
+ .addAttribute("level", String.valueOf(level));
+ if (blockQuote != null)
result.addAttribute(ATTRIBUTION, blockQuote);
result.setText(txt);
}
}
}
- }
- endPeek();
- return result;
- }
+ }
+ endPeek();
+ return result;
+ }
+
/**
- * read admonitions : admonition|attention|caution|danger|error|hint|important|note|tip|warning
+ * read admonitions :
+ * admonition|attention|caution|danger|error|hint|important|note|tip|warning
+ *
*
* .. Attention:: All your base are belong to us.
* .. admonition:: And, by the way...
*
* You can make up your own admonition too.
*
- *
+ *
* @return Element
* @throws IOException
*/
- private Element peekAdmonition() throws IOException {
- beginPeek();
- Element result = null;
+ private Element peekAdmonition() throws IOException {
+ beginPeek();
+ Element result = null;
String line = in.readLine();
if (line != null) {
String lineTest = line.toLowerCase();
- Pattern pAdmonition = Pattern.compile("^\\.\\.\\s*("+ADMONITION_PATTERN+")::\\s*(.*)$");
+ Pattern pAdmonition = Pattern.compile("^\\.\\.\\s*("
+ + ADMONITION_PATTERN + ")::\\s*(.*)$");
Matcher matcher = pAdmonition.matcher(lineTest);
-
+
if (matcher.matches()) {
-
- boolean admonition=false;
- matcher = Pattern.compile(ADMONITION_PATTERN).matcher(lineTest);
- matcher.find();
- int level=level(line);
- result = DocumentHelper.createElement(ADMONITION).addAttribute("level", ""+level);
-
- if (matcher.group().equals(ADMONITION)){ // Il y a un titre pour un admonition general
- admonition=true;
- result.addAttribute("type", ADMONITION);
- String title=line.substring(matcher.end()+2,line.length());
- String tmp=in.readLine();
- if (!tmp.matches("\\s*")){
- title += " "+tmp;
- level = level(title);
- title += "\n"+joinBlock(readBlock(level));
- }
- result.addAttribute("title", title);
- }
- else
- result.addAttribute("type",matcher.group());
- matcher = Pattern.compile(ADMONITION_PATTERN).matcher(lineTest);
+
+ boolean admonition = false;
+ matcher = Pattern.compile(ADMONITION_PATTERN).matcher(lineTest);
matcher.find();
- line=line.trim();
- String firstLine="";
- if (!admonition && matcher.end()+2 < line.length())
- firstLine =line.substring(matcher.end()+2,line.length());
- line = in.readLine();
- if (line!=null){
+ int level = level(line);
+ result = DocumentHelper.createElement(ADMONITION).addAttribute(
+ "level", "" + level);
+
+ if (matcher.group().equals(ADMONITION)) { // Il y a un titre
+ // pour un
+ // admonition
+ // general
+ admonition = true;
+ result.addAttribute("type", ADMONITION);
+ String title = line.substring(matcher.end() + 2, line
+ .length());
+
+ result.addAttribute("title", title);
+ } else
+ result.addAttribute("type", matcher.group());
+
+ String firstLine = "";
+ if (!admonition && matcher.end() + 2 < line.length())
+ firstLine = line
+ .substring(matcher.end() + 2, line.length());
+ line = in.readLine();
+ if (line != null) {
if (line.matches("\\s*"))
- line = "\n\n"+in.readLine();
- if (line!=null){
- level = level(line);
- String txt = firstLine.trim() + "\n" + line + "\n";
- txt += "\n" + readBlockWithBlankLine(level);
- result.setText(txt);
-
- }
- else
+ line = in.readLine();
+ if (line != null) {
+ if (!line.matches("\\s*")) {
+ level = level(line);
+ String txt = firstLine.trim() + "\n" + line + "\n";
+ txt += "\n" + readBlockWithBlankLine(level);
+ result.setText(txt);
+ }
+
+ } else
result.setText(firstLine);
- }
- else
+ } else
result.setText(firstLine);
}
}
endPeek();
return result;
- }
+ }
+
/**
- * read blank line
- *
+ * read blank line
+ *
* @return Element
* @throws IOException
*/
public Element peekBlankLine() throws IOException {
beginPeek();
Element result = null;
-
+
// must have one blank line before
String line = in.readLine();
if (line != null && line.matches("\\s*")) {
int level = level(line);
- result = DocumentHelper.createElement(BLANK_LINE)
- .addAttribute("level", String.valueOf(level));
+ result = DocumentHelper.createElement(BLANK_LINE).addAttribute(
+ "level", String.valueOf(level));
}
-
+
endPeek();
return result;
}
-
+
/**
* read directive or reference
*
@@ -964,10 +1057,11 @@
*/
public Element peekDirectiveOrReference() throws IOException {
beginPeek();
- Element result = null;
- String line = in.readLine();
+ Element result = null;
+ String line = in.readLine();
if (line != null) {
- Pattern pImage = Pattern.compile("^\\.\\.\\s*(?:\\|([^|]+)\\|)?\\s*(\\w+)::\\s*(.*)$");
+ Pattern pImage = Pattern
+ .compile("^\\.\\.\\s*(?:\\|([^|]+)\\|)?\\s*(\\w+)::\\s*(.*)$");
Matcher matcher = pImage.matcher(line);
if (matcher.matches()) {
String ref = matcher.group(1);
@@ -975,7 +1069,8 @@
String directiveValue = matcher.group(3);
Element directive = null;
if (ref != null && !"".equals(ref)) {
- result = DocumentHelper.createElement(SUBSTITUTION_DEFINITION);
+ result = DocumentHelper
+ .createElement(SUBSTITUTION_DEFINITION);
result.addAttribute("name", ref);
directive = result.addElement(DIRECTIVE);
} else {
@@ -983,19 +1078,20 @@
directive = result;
}
result.addAttribute("level", "0");
-
+
directive.addAttribute(DIRECTIVE_TYPE, directiveType);
directive.addAttribute(DIRECTIVE_VALUE, directiveValue);
-
- String [] lines = readBlock(2);
+
+ String[] lines = readBlock(2);
String text = joinBlock(lines, "\n", false);
-
+
directive.setText(text);
}
}
endPeek();
return result;
}
+
/**
* read transition
*
@@ -1007,28 +1103,29 @@
Element result = null;
// no eat blank line, see next comment
-
+
// must have one blank line before
String line = in.readLine();
if (line != null && line.matches("\\s*")) {
-// in.skipBlankLines();
+ // in.skipBlankLines();
line = in.readLine();
if (line != null && line.matches("-{3,}\\s*")) {
line = in.readLine();
// must have one blank line after
if (line != null && line.matches("\\s*")) {
result = DocumentHelper.createElement(TRANSITION)
- .addAttribute("level", String.valueOf(0));
+ .addAttribute("level", String.valueOf(0));
}
}
}
endPeek();
return result;
}
+
/**
- * read paragraph with attribut level that represente the space numbers
- * at left side
- *
+ * read paragraph with attribut level that represente the space numbers at
+ * left side
+ *
* @return <paragraph level="[int]">[text]</paragraph>
* @throws IOException
*/
@@ -1036,44 +1133,46 @@
beginPeek();
Element result = null;
-// in.skipBlankLines();
-
- String [] lines;
+ // in.skipBlankLines();
+
+ String[] lines;
do {
lines = readBlock(0);
if (lines.length > 0) {
int level = level(lines[0]);
String para = joinBlock(lines);
-
+
boolean literal = false;
if (para.endsWith(": ::")) {
para = para.substring(0, para.length() - " ::".length());
in.unread("::", true);
literal = true;
} else if (para.endsWith("::")) {
- para = para.substring(0, para.length() - ":".length()); // keep one :
+ para = para.substring(0, para.length() - ":".length()); // keep
+ // one
+ // :
in.unread("::", true);
literal = true;
}
-
+
if (para.length() == 0 || ":".equals(para)) {
if (literal) {
in.readLine(); // eat "::"
}
} else {
- // if para is empty, there are error and possible
+ // if para is empty, there are error and possible
// infiny loop on para, force read next line
result = DocumentHelper.createElement(PARAGRAPH)
- .addAttribute("level", String.valueOf(level))
- .addText(para);
+ .addAttribute("level", String.valueOf(level))
+ .addText(para);
}
}
} while (result == null && lines.length > 0);
-
endPeek();
return result;
}
+
/**
* read literal block
*
@@ -1090,11 +1189,11 @@
beginPeek();
Element result = null;
-// in.skipBlankLines();
+ // in.skipBlankLines();
- String [] prefix = in.readLines(2);
- if (prefix.length == 2 &&
- prefix[0].matches("\\s*::\\s*") && prefix[1].matches("\\s*")) {
+ String[] prefix = in.readLines(2);
+ if (prefix.length == 2 && prefix[0].matches("\\s*::\\s*")
+ && prefix[1].matches("\\s*")) {
String para = in.readLine();
if (para != null) {
@@ -1102,7 +1201,7 @@
para = para.substring(level) + "\n";
// it's literal block until level is down
- String [] lines = in.readWhile("(^ {"+level+"}.*|\\s*)");
+ String[] lines = in.readWhile("(^ {" + level + "}.*|\\s*)");
while (lines.length > 0) {
for (String line : lines) {
if (!line.matches("\\s*"))
@@ -1110,12 +1209,12 @@
else
para += "\n";
}
- lines = in.readWhile("(^ {"+level+"}.*|\\s*)");
+ lines = in.readWhile("(^ {" + level + "}.*|\\s*)");
}
result = DocumentHelper.createElement(LITERAL_BLOCK)
- .addAttribute("level", String.valueOf(level))
- .addText(para);
+ .addAttribute("level", String.valueOf(level)).addText(
+ para);
}
}
@@ -1125,13 +1224,14 @@
/**
* read doc info author, date, version, ...
+ *
*
* :author: Benjamin Poussin
* :address:
* Quelque part
* Dans le monde
*
- *
+ *
* @return Element
* @throws IOException
*/
@@ -1139,27 +1239,27 @@
beginPeek();
Element result = null;
-// in.skipBlankLines();
+ // in.skipBlankLines();
String line = in.readLine();
// (?i) case inensitive on docinfo item
- if (line != null && line.matches("^:((?i)"+DOCINFO_ITEM+"):.*$")) {
-
- result = DocumentHelper.createElement(DOCINFO);
+ if (line != null && line.matches("^:((?i)" + DOCINFO_ITEM + "):.*$")) {
+
+ result = DocumentHelper.createElement(DOCINFO);
result.addAttribute("level", "0");
String infotype = line.substring(1, line.indexOf(":", 1));
- /*if (!in.eof()) {
- String [] content = readBlock(1);
- line += joinBlock(content);
- }*/
+ /*
+ * if (!in.eof()) { String [] content = readBlock(1); line +=
+ * joinBlock(content); }
+ */
String text = line.substring(line.indexOf(":", 1) + 1).trim();
String[] textTmp = in.readWhile("^\\s+.*");
- if (textTmp.length!=0)
+ if (textTmp.length != 0)
in.mark();
-
+
for (String txt : textTmp)
- text+="\n"+txt.trim();
-
+ text += "\n" + txt.trim();
+
// CVS, RCS support
text = text.replaceAll("\\$\\w+: (.+?)\\$", "$1");
@@ -1168,8 +1268,10 @@
endPeek();
return result;
}
+
/**
* read table simple and complexe
+ *
*
* +------------------------+------------+----------+----------+
* | Header row, column 1 | Header 2 | Header 3 | Header 4 |
@@ -1180,7 +1282,7 @@
* | body row 2 | Cells may span columns. |
* +------------------------+------------+---------------------+
*
- *
+ *
* @return Element
* @throws IOException
*/
@@ -1189,85 +1291,95 @@
beginPeek();
Element result = null;
-// in.skipBlankLines();
+ // in.skipBlankLines();
String line = in.readLine();
if (line != null) {
Pattern pTableBegin = Pattern.compile("^\\s*(\\+-+)+\\+\\s*$");
Matcher matcher = null;
-
+
matcher = pTableBegin.matcher(line);
if (matcher.matches()) { // complexe table
result = DocumentHelper.createElement(TABLE);
result.addAttribute(TABLE_HEADER, "false");
int level = level(line);
- result.addAttribute("level", String.valueOf(level));
+ result.addAttribute("level", String.valueOf(level));
line = line.trim();
int tableWidth = line.length();
result.addAttribute(TABLE_WIDTH, String.valueOf(tableWidth));
-
- Pattern pCellEnd = Pattern.compile("^\\s{"+level+"}(\\+-+\\+|\\|(?:[^+]+))([^+]+(?:\\+|\\|\\s*$)|-+\\+)*\\s*"); // fin de ligne
- Pattern pCell = Pattern.compile("^\\s{"+level+"}(\\|[^|]+)+\\|\\s*$"); // une ligne
- Pattern pHeader = Pattern.compile("^\\s{"+level+"}(\\+=+)+\\+\\s*$"); // fin du header
- Pattern pEnd = Pattern.compile("^\\s{"+level+"}(\\+-+)+\\+\\s*$"); // fin de table
-
+
+ Pattern pCellEnd = Pattern
+ .compile("^\\s{"
+ + level
+ + "}(\\+-+\\+|\\|(?:[^+]+))([^+]+(?:\\+|\\|\\s*$)|-+\\+)*\\s*"); // fin
+ // de
+ // ligne
+ Pattern pCell = Pattern.compile("^\\s{" + level
+ + "}(\\|[^|]+)+\\|\\s*$"); // une ligne
+ Pattern pHeader = Pattern.compile("^\\s{" + level
+ + "}(\\+=+)+\\+\\s*$"); // fin du header
+ Pattern pEnd = Pattern.compile("^\\s{" + level
+ + "}(\\+-+)+\\+\\s*$"); // fin de table
+
// used to know if | is cell separator or not
String lastSeparationLine = line;
String lastLine = line;
-
+
Element row = DocumentHelper.createElement(ROW);
- String [] table = in.readUntilBlank();
-
+ String[] table = in.readUntilBlank();
+
boolean done = false;
for (String l : table) {
- done =false;
+ done = false;
l = l.trim();
if (l.length() != tableWidth) {
// Erreur dans la table, peut-etre lever une exception ?
result = null;
break;
- }
+ }
matcher = pEnd.matcher(l);
if (!done && matcher.matches()) {
// fin normale de ligne, on peut directement l'assigner
lastSeparationLine = l;
- for (Element cell : (List
* :first: text
* :second: text
* and other text
* :last empty:
*
- *
- * @return <field_list level="[int]" name="[text]">[text]</field_list>
+ *
+ * @return <field_list level="[int]"
+ * name="[text]">[text]</field_list>
* @throws IOException
*/
public Element peekFieldList() throws IOException {
beginPeek();
Element result = null;
-// in.skipBlankLines();
+ // in.skipBlankLines();
String line = in.readLine();
if (line != null) {
Pattern pattern = Pattern.compile("^\\s*:([^:]+): [^\\s].*");
@@ -1604,12 +1771,12 @@
String name = matcher.group(1);
int begin = matcher.end(1) + 1;
- result = DocumentHelper.createElement(FIELD_LIST)
- .addAttribute("level", String.valueOf(level))
- .addAttribute("name", name);
+ result = DocumentHelper.createElement(FIELD_LIST).addAttribute(
+ "level", String.valueOf(level)).addAttribute("name",
+ name);
if (!in.eof()) {
- String [] content = readBlock(level + 1);
+ String[] content = readBlock(level + 1);
line += " " + joinBlock(content);
}
String text = line.substring(begin).trim();
@@ -1624,26 +1791,26 @@
/**
* read definition list
+ *
*
* un autre mot
* une autre definition
- *
* le mot : la classe
* la definition
- *
* le mot : la classe 1 : la classe 2
* la definition
*
- *
- * @return <definition_list level="[int]" term="[text]" classifiers="[text]">[text]</definition_list>
+ *
+ * @return <definition_list level="[int]" term="[text]"
+ * classifiers="[text]">[text]</definition_list>
* @throws IOException
*/
public Element peekDefinitionList() throws IOException {
beginPeek();
Element result = null;
-// in.skipBlankLines();
- String [] lines = in.readLines(2);
+ // in.skipBlankLines();
+ String[] lines = in.readLines(2);
if (lines.length == 2) {
int level = level(lines[0]);
int levelDef = level(lines[1]);
@@ -1656,17 +1823,17 @@
String classifiers = matcher.group(2);
result = DocumentHelper.createElement(DEFINITION_LIST)
- .addAttribute("level", String.valueOf(level))
- .addAttribute("term", term)
- .addAttribute("classifiers", classifiers);
+ .addAttribute("level", String.valueOf(level))
+ .addAttribute("term", term).addAttribute(
+ "classifiers", classifiers);
- // poussin 20070207 don't read block here because can't
+ // poussin 20070207 don't read block here because can't
// interpret it correctly in JRSTReader
-// if (!in.eof()) {
-// String [] content = readBlock(level + 1);
-// String text = joinBlock(content);
-// result.addText(text);
-// }
+ // if (!in.eof()) {
+ // String [] content = readBlock(level + 1);
+ // String text = joinBlock(content);
+ // result.addText(text);
+ // }
}
}
}
@@ -1677,33 +1844,36 @@
/**
* read enumarted list
- *
+ *
* can be:
*
* 1. next line
* 1) next line
* (1) first line
*
- *
- * @return <enumerated_list level="[int]" start="[number]" prefix="[char]" suffix="[char]" enumtype="[(arabic|loweralpha|upperalpha|lowerroman|upperroman]">[text]</enumerated_list>
+ *
+ * @return <enumerated_list level="[int]" start="[number]"
+ * prefix="[char]" suffix="[char]"
+ * enumtype="[(arabic|loweralpha|upperalpha|lowerroman|upperroman]">[text]</enumerated_list>
* @throws IOException
*/
public Element peekEnumeratedList() throws IOException {
beginPeek();
Element result = null;
-// in.skipBlankLines();
+ // in.skipBlankLines();
String line = in.readLine();
if (line != null) {
- Pattern pattern = Pattern.compile("^\\s*(\\(?)(#|\\d+|[a-z]|[A-Z]|[ivxlcdm]+|[IVXLCDM]+)([\\.)]) [^\\s].*");
+ Pattern pattern = Pattern
+ .compile("^\\s*(\\(?)(#|\\d+|[a-z]|[A-Z]|[ivxlcdm]+|[IVXLCDM]+)([\\.)]) [^\\s].*");
Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
int level = level(line);
@@ -1724,21 +1894,20 @@
start = "1"; // TODO transform romain to arabic
} else if (start.matches("[a-z]+")) {
enumtype = "loweralpha";
- start = String.valueOf((int)start.charAt(0) -(int)'a');
+ start = String.valueOf((int) start.charAt(0) - (int) 'a');
} else if (start.matches("[A-Z]+")) {
enumtype = "upperalpha";
- start = String.valueOf((int)start.charAt(0) -(int)'A');
+ start = String.valueOf((int) start.charAt(0) - (int) 'A');
}
result = DocumentHelper.createElement(ENUMERATED_LIST)
- .addAttribute("level", String.valueOf(level))
- .addAttribute("start", start)
- .addAttribute("prefix", prefix)
- .addAttribute("suffix", suffix)
- .addAttribute("enumtype", enumtype);
+ .addAttribute("level", String.valueOf(level))
+ .addAttribute("start", start).addAttribute("prefix",
+ prefix).addAttribute("suffix", suffix)
+ .addAttribute("enumtype", enumtype);
if (!in.eof()) {
- String [] content = readBlock(level + 1);
+ String[] content = readBlock(level + 1);
line += " " + joinBlock(content);
}
String text = line.substring(begin).trim();
@@ -1754,52 +1923,51 @@
/**
* Parse un titre simple ou double
- *
+ *
* simple:
+ *
*
* Le titre
* ========
*
- *
+ *
* double:
+ *
*
* ============
* le titre
* ============
*
- *
- * @return <title level="[int]" type="[simple|double]" char="[underline char]">
+ *
+ * @return <title level="[int]" type="[simple|double]" char="[underline
+ * char]">
* @throws IOException
*/
public Element peekTitle() throws IOException {
beginPeek();
Element result = null;
-// in.skipBlankLines();
+ // in.skipBlankLines();
String line = in.readLine();
-
+
if (line != null) {
if (startsWithTitleChar(line)) {
- String [] titles = in.readLines(2);
- if (titles.length == 2
- && line.length() >= titles[0].length()
+ String[] titles = in.readLines(2);
+ if (titles.length == 2 && line.length() >= titles[0].length()
&& line.length() == titles[1].length()
&& line.equals(titles[1])) {
- result = DocumentHelper.createElement(TITLE)
- .addAttribute("type", "double")
- .addAttribute("char", titles[1].substring(0, 1))
- .addText(titles[0]);
+ result = DocumentHelper.createElement(TITLE).addAttribute(
+ "type", "double").addAttribute("char",
+ titles[1].substring(0, 1)).addText(titles[0]);
}
} else {
String title = in.readLine();
- if (title != null &&
- startsWithTitleChar(title) &&
- line.length() == title.length()) {
-
- result = DocumentHelper.createElement(TITLE)
- .addAttribute("type", "simple")
- .addAttribute("char", title.substring(0, 1))
- .addText(line);
+ if (title != null && startsWithTitleChar(title)
+ && line.length() == title.length()) {
+
+ result = DocumentHelper.createElement(TITLE).addAttribute(
+ "type", "simple").addAttribute("char",
+ title.substring(0, 1)).addText(line);
}
}
}
@@ -1816,81 +1984,117 @@
level = titleLevels.size();
titleLevels.add(titleLevel);
}
- result.addAttribute("level", String.valueOf(JRSTReader.MAX_SECTION_DEPTH + level));
+ result.addAttribute("level", String
+ .valueOf(JRSTReader.MAX_SECTION_DEPTH + level));
}
endPeek();
return result;
}
+
+ public Element peekTarget() throws IOException {
+ beginPeek();
+
+ String line = in.readLine();
+ Element result = null;
+ if (line != null) {
+ if (line.matches("^\\s*\\.\\.\\s_[^_:].+:.*")) {
+ result = DocumentHelper.createElement(TARGET);
+ Matcher matcher = Pattern.compile("\\.\\.\\s_").matcher(line);
+ if (matcher.find()) {
+ int i = line.indexOf(':');
+ result.addAttribute("id", line.substring(matcher.end(), i)
+ .replaceAll("\\W", "-").toLowerCase());
+ result.addAttribute("level", ""+level(line));
+ }
+ }
+ }
+ endPeek();
+ return result;
+ }
+
/**
* .. _frungible doodads: http://www.example.org/
- *
+ *
* @return Element
- * @throws IOException
+ * @throws IOException
*/
- private Element peekTarget() throws IOException {
+ public LinkedList