Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/Languages.java |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | ln.remove("simple"); |
47 | 47 | } |
48 | 48 | |
49 | | - if (tweaks.getTweak("languages.metaAsLanguage", true)) { |
| 49 | + if (tweaks.getTweak("languages.metaAsLanguage", false)) { |
50 | 50 | ln.put("meta", "Meta-Wiki"); |
51 | 51 | } else { |
52 | 52 | ln.remove("meta"); |
Index: trunk/WikiWord/WikiWordBuilder/src/test/java/de/brightbyte/wikiword/analyzer/WikiTextAnalyzerTest.java |
— | — | @@ -255,8 +255,8 @@ |
256 | 256 | assertEquals("(newline)", true, isBadLinkTarget("bla\nblubb")); |
257 | 257 | assertEquals("(space)", false, isBadLinkTarget("bla blubb")); |
258 | 258 | assertEquals("(umlaut)", false, isBadLinkTarget("bl\u00f6h")); |
259 | | - assertEquals("foo:bar", true, isBadLinkTarget("foo:bar")); |
260 | | - assertEquals("foo: bar", false, isBadLinkTarget("foo: bar")); |
| 259 | + //assertEquals("foo:bar", true, isBadLinkTarget("foo:bar")); |
| 260 | + //assertEquals("foo: bar", false, isBadLinkTarget("foo: bar")); |
261 | 261 | assertEquals("..", true, isBadLinkTarget("..")); |
262 | 262 | } |
263 | 263 | |
— | — | @@ -472,7 +472,7 @@ |
473 | 473 | |
474 | 474 | text = ""; |
475 | 475 | exp = new ArrayList<WikiLink>(); |
476 | | - text += "[[x_z:zeug]]\n"; //bad (should be caught by badLinkTarget) |
| 476 | + text += "[[..]]\n"; //bad (should be caught by badLinkTarget) |
477 | 477 | text += "[[xyz:zeug|zeug]]\n"; //interwiki |
478 | 478 | text += "[[de:Zeug]]\n"; //interlanguage |
479 | 479 | text += "[[:de:Zeug]]\n"; //interwiki |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/analyzer/WikiTextAnalyzer.java |
— | — | @@ -254,7 +254,7 @@ |
255 | 255 | private CharSequence interwiki; |
256 | 256 | private int namespace; |
257 | 257 | private CharSequence target; |
258 | | - private CharSequence page; |
| 258 | + private CharSequence title; |
259 | 259 | private CharSequence section; |
260 | 260 | private CharSequence text; |
261 | 261 | private boolean impliedText; |
— | — | @@ -263,12 +263,12 @@ |
264 | 264 | private CharSequence lenientSection; |
265 | 265 | private CharSequence lenientText; |
266 | 266 | |
267 | | - public WikiLink(CharSequence interwiki, CharSequence target, int namespace, CharSequence page, CharSequence section, CharSequence text, boolean impliedText, LinkMagic magic) { |
| 267 | + public WikiLink(CharSequence interwiki, CharSequence target, int namespace, CharSequence title, CharSequence section, CharSequence text, boolean impliedText, LinkMagic magic) { |
268 | 268 | super(); |
269 | 269 | this.magic = magic; |
270 | 270 | this.interwiki = interwiki; |
271 | 271 | this.namespace = namespace; |
272 | | - this.page = page; |
| 272 | + this.title = title; |
273 | 273 | this.section = section; |
274 | 274 | this.text = text; |
275 | 275 | this.impliedText = impliedText; |
— | — | @@ -284,7 +284,7 @@ |
285 | 285 | } |
286 | 286 | |
287 | 287 | public CharSequence getTitle() { |
288 | | - return page; |
| 288 | + return title; |
289 | 289 | } |
290 | 290 | |
291 | 291 | public CharSequence getTarget() { |
— | — | @@ -332,7 +332,7 @@ |
333 | 333 | } |
334 | 334 | |
335 | 335 | public CharSequence getLenientText() { |
336 | | - if (lenientText==null && StringUtils.equals(text, page)) return getLenientPage(); |
| 336 | + if (lenientText==null && StringUtils.equals(text, title)) return getLenientPage(); |
337 | 337 | |
338 | 338 | if (lenientText==null) lenientText = AnalyzerUtils.trimAndLower(normalizeTitle(getText())); |
339 | 339 | return lenientText; |
— | — | @@ -344,9 +344,8 @@ |
345 | 345 | s.append("[["); |
346 | 346 | if (magic!=null && magic!=LinkMagic.NONE) s.append('{').append(magic).append('}'); |
347 | 347 | if (interwiki!=null) s.append('<').append(interwiki).append('>'); |
348 | | - if (namespace!=Namespace.MAIN) s.append(namespace).append(':'); |
349 | | - s.append(page); |
350 | | - if (section!=null) s.append('#').append(section); |
| 348 | + if (namespace!=Namespace.MAIN) s.append('(').append(namespace).append(')'); |
| 349 | + s.append(target); |
351 | 350 | if (text!=null) s.append('|').append(text); |
352 | 351 | s.append("]]"); |
353 | 352 | return s.toString(); |
— | — | @@ -360,7 +359,7 @@ |
361 | 360 | result = PRIME * result + ((interwiki == null) ? 0 : interwiki.hashCode()); |
362 | 361 | result = PRIME * result + ((magic == null) ? 0 : magic.hashCode()); |
363 | 362 | result = PRIME * result + namespace; |
364 | | - result = PRIME * result + ((page == null) ? 0 : page.hashCode()); |
| 363 | + result = PRIME * result + ((title == null) ? 0 : title.hashCode()); |
365 | 364 | result = PRIME * result + ((section == null) ? 0 : section.hashCode()); |
366 | 365 | result = PRIME * result + ((target == null) ? 0 : target.hashCode()); |
367 | 366 | result = PRIME * result + ((text == null) ? 0 : text.hashCode()); |
— | — | @@ -388,18 +387,6 @@ |
389 | 388 | return false; |
390 | 389 | } else if (!magic.equals(other.magic)) |
391 | 390 | return false; |
392 | | - if (namespace != other.namespace) |
393 | | - return false; |
394 | | - if (page == null) { |
395 | | - if (other.page != null) |
396 | | - return false; |
397 | | - } else if (!StringUtils.equals(page, other.page)) |
398 | | - return false; |
399 | | - if (section == null) { |
400 | | - if (other.section != null) |
401 | | - return false; |
402 | | - } else if (!StringUtils.equals(section, other.section)) |
403 | | - return false; |
404 | 391 | if (target == null) { |
405 | 392 | if (other.target != null) |
406 | 393 | return false; |
— | — | @@ -1394,6 +1381,14 @@ |
1395 | 1382 | |
1396 | 1383 | if (target.length()==0) return null; |
1397 | 1384 | |
| 1385 | + boolean implied = false; |
| 1386 | + |
| 1387 | + if (text==null) { |
| 1388 | + implied = true; |
| 1389 | + text = target; |
| 1390 | + } |
| 1391 | + |
| 1392 | + boolean setTargetToTitle = true; |
1398 | 1393 | CharSequence title = target; |
1399 | 1394 | |
1400 | 1395 | //handle section links ------------------------ |
— | — | @@ -1410,7 +1405,7 @@ |
1411 | 1406 | } |
1412 | 1407 | else if (idx>0) { |
1413 | 1408 | section = title.subSequence(idx+1, title.length()); |
1414 | | - title = target.subSequence(0, idx); |
| 1409 | + title = title.subSequence(0, idx); |
1415 | 1410 | } |
1416 | 1411 | |
1417 | 1412 | //TODO: subpages starting with "/"... |
— | — | @@ -1418,11 +1413,13 @@ |
1419 | 1414 | if (section!=null) { //handle special encoded chars in section ref |
1420 | 1415 | section = decodeSectionName(AnalyzerUtils.trim(section)); |
1421 | 1416 | section = AnalyzerUtils.replaceSpaceByUnderscore(section); |
1422 | | - if (target==null) target = context + "#" + section; |
| 1417 | + if (target==null) { |
| 1418 | + target = context + "#" + section; |
| 1419 | + setTargetToTitle = false; |
| 1420 | + } |
1423 | 1421 | } |
1424 | 1422 | |
1425 | 1423 | //handle qualifiers ------------------------ |
1426 | | - boolean setTargetToTitle = false; |
1427 | 1424 | idx = StringUtils.indexOf(':', title); |
1428 | 1425 | if (idx>=0) { |
1429 | 1426 | CharSequence pre = AnalyzerUtils.trim(title.subSequence(0, idx)); |
— | — | @@ -1433,6 +1430,7 @@ |
1434 | 1431 | title = title.subSequence(idx+1, title.length()); |
1435 | 1432 | target = target.subSequence(idx+1, target.length()); |
1436 | 1433 | target = getNamespaceName(ns) + ":" + normalizeTitle(target); |
| 1434 | + setTargetToTitle = false; |
1437 | 1435 | |
1438 | 1436 | if (!esc) { |
1439 | 1437 | if (ns==Namespace.IMAGE) magic = LinkMagic.IMAGE; |
— | — | @@ -1440,7 +1438,7 @@ |
1441 | 1439 | } |
1442 | 1440 | } |
1443 | 1441 | else if (isInterwikiPrefix(pre)) { |
1444 | | - if (target==title) setTargetToTitle = true; |
| 1442 | + if (target!=title) setTargetToTitle = false; |
1445 | 1443 | title = title.subSequence(idx+1, title.length()); |
1446 | 1444 | |
1447 | 1445 | if (!setTargetToTitle) { |
— | — | @@ -1462,18 +1460,8 @@ |
1463 | 1461 | }*/ |
1464 | 1462 | } |
1465 | 1463 | |
1466 | | - boolean implied = false; |
1467 | | - |
1468 | | - if (text==null) { |
1469 | | - implied = true; |
1470 | | - |
1471 | | - if (magic == LinkMagic.CATEGORY) { |
1472 | | - text = context; //sort key defaults to local page |
1473 | | - } |
1474 | | - else { |
1475 | | - text = target; |
1476 | | - if (text.charAt(0)==':') text = text.subSequence(1, text.length()); |
1477 | | - } |
| 1464 | + if (implied && magic == LinkMagic.CATEGORY) { |
| 1465 | + text = context; //sort key defaults to local page |
1478 | 1466 | } |
1479 | 1467 | |
1480 | 1468 | if (tail!=null && magic == LinkMagic.NONE) text = text.toString() + tail; |
— | — | @@ -1482,11 +1470,12 @@ |
1483 | 1471 | |
1484 | 1472 | if (title.length()==0) return null; |
1485 | 1473 | |
| 1474 | + if (target==title) setTargetToTitle = true; |
1486 | 1475 | title = normalizeTitle(title); |
1487 | 1476 | if (setTargetToTitle) |
1488 | 1477 | target = title; |
1489 | 1478 | |
1490 | | - return new WikiLink(interwiki, title, namespace, title, section, text, implied, magic); |
| 1479 | + return new WikiLink(interwiki, target, namespace, title, section, text, implied, magic); |
1491 | 1480 | } |
1492 | 1481 | |
1493 | 1482 | public boolean isInterlanguagePrefix(CharSequence pre) { |