diff options
Diffstat (limited to 'gnu/javax/swing/text/html/parser')
-rw-r--r-- | gnu/javax/swing/text/html/parser/HTML_401F.java | 4 | ||||
-rw-r--r-- | gnu/javax/swing/text/html/parser/support/textPreProcessor.java | 30 |
2 files changed, 20 insertions, 14 deletions
diff --git a/gnu/javax/swing/text/html/parser/HTML_401F.java b/gnu/javax/swing/text/html/parser/HTML_401F.java index c3c347e36..1894b6a1a 100644 --- a/gnu/javax/swing/text/html/parser/HTML_401F.java +++ b/gnu/javax/swing/text/html/parser/HTML_401F.java @@ -2445,8 +2445,10 @@ public class HTML_401F attr(VALUE, null, null, 0, IMPLIED) } ); + + // Headers in the paragraph are not allowed. defElement(P, 0, false, true, new ContentModel( 0, - new noTagModel(P), null), + new noTagModel(new String[] { P, H1, H2, H3, H4, H5, H6 }), null), NONE , new String[] { diff --git a/gnu/javax/swing/text/html/parser/support/textPreProcessor.java b/gnu/javax/swing/text/html/parser/support/textPreProcessor.java index cc1610585..b81275b1f 100644 --- a/gnu/javax/swing/text/html/parser/support/textPreProcessor.java +++ b/gnu/javax/swing/text/html/parser/support/textPreProcessor.java @@ -42,17 +42,17 @@ import gnu.javax.swing.text.html.parser.support.low.Constants; /** * Pre - processes text in text parts of the html document. - * Not thread - safe. + * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public class textPreProcessor { /** - * Pre - process non-preformatted text. - * \t, \r and \n mutate into spaces, then multiple spaces mutate - * into single one, all whitespace around tags is consumed. - * The content of the passed buffer is destroyed. - * @param text A text to pre-process. + * Pre - process non-preformatted text. \t, \r and \n mutate into spaces, then + * multiple spaces mutate into single one, all whitespace around tags is + * consumed. The content of the passed buffer is destroyed. + * + * @param a_text A text to pre-process. */ public char[] preprocess(StringBuffer a_text) { @@ -64,17 +64,22 @@ public class textPreProcessor int a = 0; int b = text.length - 1; + // Remove leading/trailing whitespace, leaving at most one character try { - while (Constants.bWHITESPACE.get(text [ a ])) + while (Constants.bWHITESPACE.get(text[a]) + && Constants.bWHITESPACE.get(text[a + 1])) a++; - while (Constants.bWHITESPACE.get(text [ b ])) + + while (b > a && Constants.bWHITESPACE.get(text[b]) + && Constants.bWHITESPACE.get(text[b - 1])) b--; } catch (ArrayIndexOutOfBoundsException sx) { - // A text fragment, consisting from line breaks only. - return null; + // A text fragment, consisting from spaces and line breaks only, + // mutates into single space. + return new char[] { ' ' }; } a_text.setLength(0); @@ -83,10 +88,9 @@ public class textPreProcessor boolean spaceNow; char c; - chars: - for (int i = a; i <= b; i++) + chars: for (int i = a; i <= b; i++) { - c = text [ i ]; + c = text[i]; spaceNow = Constants.bWHITESPACE.get(c); if (spacesWere && spaceNow) continue chars; |