Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Commend and CDATA cause display of double end tag which causes distortion #17

Open
stoecker opened this issue Apr 24, 2017 · 2 comments
Assignees
Labels

Comments

@stoecker
Copy link

stoecker commented Apr 24, 2017

When HTML contains CDATA or comments the display is wrong. Reason is that in this case the ">" is handled twice. Following patch solves the issues.

@stoecker
Copy link
Author

Index: src/net/boplicity/xmleditor/XmlView.java
===================================================================
--- src/net/boplicity/xmleditor/XmlView.java (Revision 33275)
+++ src/net/boplicity/xmleditor/XmlView.java (Arbeitskopie)
@@ -17,6 +17,7 @@

import java.awt.Color;
import java.awt.Graphics;
+import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.SortedMap;
@@ -62,8 +63,6 @@
patternColors.put(Pattern.compile(TAG_CDATA), Color.GRAY);
patternColors.put(Pattern.compile(TAG_ATTRIBUTE_PATTERN), new Color(
127, 0, 127));
- patternColors.put(Pattern.compile(TAG_END_PATTERN), new Color(63, 127,
- 127));
patternColors.put(Pattern.compile(TAG_ATTRIBUTE_VALUE), new Color(42,
0, 255));
patternColors.put(Pattern.compile(TAG_COMMENT), Color.BLUE);
@@ -103,7 +102,18 @@
colorMap.put(matcher.start(1), entry.getValue());
}
}
+ /* Fix end tag duplication for CDATA and comments */
+ Matcher matcher = Pattern.compile(TAG_END_PATTERN).matcher(text);
+ Color c = new Color(63, 127, 127);
+ Collection<Integer> ends = startMap.values();

+ while (matcher.find()) {
+ if(!ends.contains(matcher.end())) {
+ startMap.put(matcher.start(1), matcher.end());
+ colorMap.put(matcher.start(1), c);
+ }
+ }
+
// TODO: check the map for overlapping parts

int i = 0;

@stoecker
Copy link
Author

Aaargh. This Ticket interface is awful, here is a link: https://trac.openstreetmap.org/changeset/33276/subversion?format=diff&new=33276

@kdekooter kdekooter self-assigned this Apr 25, 2017
@kdekooter kdekooter added the bug label Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants