User:Wikid77/Test lua
Perhaps putsep function to avoid double-dot
[edit]When a trailing-dot item has the dot embedded inside a wikilink, then perhaps there could be a status switch, "hasdot=true
" where a special function, putsep(hasdot, sepc), could check the status of the prior data item's dot. The embedded trailing dot (detected as ".]]" in x:sub(-3,-1) substring) would suppress the double-dot cases. The following are some special cases:
Wikitext | {{cite book
|
---|---|
Live | John Doe (1 June 2000). The Rise of Dotcom, Inc. London: Acme Inc. {{cite book}} : Unknown parameter |sandbox= ignored (help)
|
Sandbox | John Doe (1 June 2000). The Rise of Dotcom, Inc. London: Acme Inc. {{cite book}} : Unknown parameter |sandbox= ignored (help)
|
Wikitext | {{cite book
|
---|---|
Live | Doe, John Q. The Rise of Dotcom, Inc. Acme Inc. {{cite book}} : Unknown parameter |Series= ignored (|series= suggested) (help); Unknown parameter |sandbox= ignored (help)
|
Sandbox | Doe, John Q. The Rise of Dotcom, Inc. Acme Inc. {{cite book}} : Unknown parameter |Series= ignored (|series= suggested) (help); Unknown parameter |sandbox= ignored (help)
|
Wikitext | {{cite book
|
---|---|
Live | Doe, John Q. The Rise of Dotcom, Inc. Acme Inc. {{cite book}} : Unknown parameter |Series= ignored (|series= suggested) (help)
|
Sandbox | Doe, John Q. The Rise of Dotcom, Inc. Acme Inc. {{cite book}} : Unknown parameter |Series= ignored (|series= suggested) (help)
|
The embedded trailing dots are rare, but the use of putsep(hasdot, sepc) could provide a simple method to track the pending double-dot error, omit the sepc separator when also a dot (not sepc=','), then reset as hasdot=false
so the next item would continue to put the typical sepc separator character. Any data item which has a trailing dot, would again set hasdot=true
, while parameters shown in "(___)" would set hasdot=false
, and the remainder of the data items would use the function putsep() to avoid double-dot cases, no matter where the extra dot was embedded. This simple, almost error-proof tactic was not practical in markup due to the lack of local status variables to remember whether the prior data item had a trailing dot.
However, for now, we can just check the title for a wikilink ending in ".]]" as a common case of an embedded trailing dot. -Wikid77 (talk) 00:01, 3 April 2013 (UTC)
- Updated function safejoin() in Lua script: I see the whole logic had been changed to use function safejoin() to check for duplicate characters everywhere, and so, I added a quick extra comparison to detect a trailing dot in either a wikilink "[[xx.]]" or in an external link "[http__xx.]". The added check, with wikilinks or external links, will fix the double-dot problem for almost every case. -Wikid77 (talk) 01:36, 3 April 2013 (UTC)