Moxkiriyaプロジェクト事前開発用の作業部屋
Revisão | 6fdbb9035a145682d848f15a12331b99b02892b0 (tree) |
---|---|
Hora | 2018-08-21 06:40:32 |
Autor | Harold_Andoh <andolloyd@gmai...> |
Commiter | Harold_Andoh |
[Moxkiriya7]
@@ -41,6 +41,8 @@ public class WikiInternalLinkInlineParser extends WikiInlineParserBase { | ||
41 | 41 | |
42 | 42 | private static final String PANGENAME_PREFIX_COLONFILE = ":File:"; |
43 | 43 | |
44 | + private static final String PAGENAME_HASH_TITLE = "#title"; | |
45 | + | |
44 | 46 | /** リンク先のページ名 */ |
45 | 47 | private String pagename_; |
46 | 48 |
@@ -98,7 +100,13 @@ public class WikiInternalLinkInlineParser extends WikiInlineParserBase { | ||
98 | 100 | buf.append(IMAGE_START_TAG); |
99 | 101 | buf.append("\""); |
100 | 102 | buf.append(file.toURI().toURL()); |
101 | - buf.append("\">"); | |
103 | + buf.append("\""); | |
104 | + buf.append(" alt=\""); | |
105 | + buf.append(textNode); | |
106 | + buf.append("\""); | |
107 | + buf.append(" title=\""); | |
108 | + buf.append(textNode); | |
109 | + buf.append("\" >"); | |
102 | 110 | buf.append(IMAGE_END_TAG); |
103 | 111 | } catch (Exception e) { |
104 | 112 | e.printStackTrace(); |
@@ -159,9 +167,23 @@ public class WikiInternalLinkInlineParser extends WikiInlineParserBase { | ||
159 | 167 | |
160 | 168 | @Override |
161 | 169 | public String deleteWikiToken(String line) { |
162 | - String deleteTop = line.replaceFirst(Pattern.quote(WIKI_TOKEN_START), ""); | |
163 | - pagename_ = deleteTop.substring(0, deleteTop.lastIndexOf(WIKI_TOKEN_END)); | |
164 | - return pagename_; | |
170 | + String deleteTop = line.replaceFirst(Pattern.quote(WIKI_TOKEN_START), ""); | |
171 | + String deleteToken = deleteTop.substring(0, deleteTop.lastIndexOf(WIKI_TOKEN_END)); | |
172 | + String textNode = deleteToken; | |
173 | + | |
174 | + if(deleteToken.contains("|") == true) { | |
175 | + pagename_ = deleteToken.substring(0, deleteToken.indexOf("|")); | |
176 | + textNode = deleteToken.substring(deleteToken.indexOf("|") + "|".length()); | |
177 | + | |
178 | + if(textNode.equals(PAGENAME_HASH_TITLE) == true) { | |
179 | + textNode = pagename_.substring(pagename_.lastIndexOf(".") + ".".length()); | |
180 | + } | |
181 | + } | |
182 | + else { | |
183 | + pagename_ = deleteToken; | |
184 | + } | |
185 | + | |
186 | + return textNode; | |
165 | 187 | } |
166 | 188 | |
167 | 189 | @Override |