Skip to content

Commit

Permalink
Allow dots in attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
appml committed Sep 6, 2023
1 parent 5133335 commit a0785c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/appmindlab/nano/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ public class Const {
protected final static String TAG_CONTENT_CLOSE_SYM = "}";
protected final static String TAG_MULTI_SYM = "*";
protected final static String TAG_PLACEHOLDER_SYM = "???";
protected final static String TAG_CLASS_PLACEHOLDER_SYM = "---";
protected final static String TAG_CLASS_SYM = ".";
protected final static String TAG_ID_SYM = "#";
protected final static String TAG_NUM_SYM = "$";
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/appmindlab/nano/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,18 @@ private static String[] makeTagPair(String tag) {

if (tag.length() > 0) {
if (tag.contains(Const.TAG_CLASS_SYM)) {
// Prepare attributes containing dots
if (tag.contains(Const.TAG_ATTR_OPEN_SYM)) {
parts = tag.split("\\" + Const.TAG_ATTR_OPEN_SYM);
for (int i=0; i < parts.length; i++) {
if (parts[i].indexOf(Const.TAG_CLASS_SYM) < parts[i].indexOf(Const.TAG_ATTR_CLOSE_SYM))
parts[i] = parts[i].replace(Const.TAG_CLASS_SYM, Const.TAG_CLASS_PLACEHOLDER_SYM);
}

// Reconstruct the tag
tag = String.join(Const.TAG_ATTR_OPEN_SYM, parts);
}

parts = tag.split("\\" + Const.TAG_CLASS_SYM);
if (parts.length > 1) {
// Check if id exists
Expand Down Expand Up @@ -840,6 +852,7 @@ else if (tag.contains(Const.TAG_ID_SYM)) { // Only id, no class

// Handle attributes
opening_tag = opening_tag.replaceAll("\\" + Const.TAG_ATTR_OPEN_SYM, Const.EMPTY_SYM). replaceAll("\\" + Const.TAG_ATTR_CLOSE_SYM,Const.NULL_SYM);
opening_tag = opening_tag.replace(Const.TAG_CLASS_PLACEHOLDER_SYM, Const.TAG_CLASS_SYM);
closing_tag = closing_tag.replaceAll("\\[.*?\\]", "");
}

Expand Down

0 comments on commit a0785c1

Please sign in to comment.