User:Retro/Footnotes

Category:Author–date citation templates
The row format could probably be turned into a template on its own merit. It would either be one of the two (or perhaps it could function as both, with parameter conditions):

Cref and cnotes
I previously tried to replace some and  templates, but it turned out poorly because I didn't understand all the technical details. I will want to ensure I understand all the technical details before embarking upon such a quest again.

That this regex is placed higher than all regex in notes is incidental; the quality may vary. Regex is actually suboptimal because of its relative inclarity, so I will probably transition to custom AWB C#.

.*? \{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}
 * Find: {{pre| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\}
 * Replace: \2

Pages with complex footnotesComplex footnote cases

 * Super Bowl
 * Group (mathematics)

Pages with footnote mistakes cases

 * Schleswig-Holstein
 * Jonathan Demme
 * Micronesia
 * Whig Party (United States)
 * CERN
 * Sui dynasty
 * Democratic-Republican Party: suggests a missing one b/c numbering started from 2.
 * Photios I of Constantinople: Reverse problem; note which is missing the inline reference.
 * Potomac River: Notes which are missing inline references

Miscellaneous notes

 * {{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\}(?=(?:[^{]*(?:(?!\{\{\s*(?:[Tt]emplate:)?[cC]note\s*\|\s*\1).)?)*\{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}
 * {{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\}(?=(?>.*?\{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1)\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}
 * {{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\}(?=(?>.*?\{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1)\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}

{{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\} (?= (?> [^{]*(?:.?[^{]*)*? \{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1) \s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}


 * Find: {{code| (?:[^{]*.??)*? }}
 * Replace: {{code| [^{]*(?:.?[^{]*)*? }}


 * {{code| [^{}]*(\{(?(\{)[^{}]*(?1)?\}|(?!)[^{}]*)* }}

Needs a subroutine, not a backreference.


 * {{code| (\(((?>[^]+)|(?1))*\))* }}

[Old note:] I'm just not going to get recursion today, and I'm fine with that; there are two many possible confusing variables.


 * {{code| (\{[^{]*\2[^}]*}\) }}

{{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\} ((?:[^{]*(?:(?!\{\{\s*(?:[Tt]emplate:)?[cC]note\s*\|\s*\1).)?)* \{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}
 * Find:
 * Replace: {{code| {{efn|\3}}\2 }}

Iteration 2: Lookahead time!:

{{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\} (?!((?:[^{]*(?:(?!\{\{\s*(?:[Tt]emplate:)?[cC]note\s*\|\s*\1).)?)* \{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\})) }}
 * Find:

{{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\}(?=(?:[^{]*(?:(?!\{\{\s*(?:[Tt]emplate:)?[cC]note\s*\|\s*\1).)?)*\{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}
 * Find 2:


 * Replace: {{code| {{efn|\2}}

Efficiency tweaking :-p:


 * {{code| (?:[^{}]*(?:\{\{[^}]*\}\})?)+ }}
 * {{code| (\{\{[Rr]efbegin\}\})?((?:[\s*]*?\{\{\s*?(?:[Tt]emplate:)?[E]fn\s*?((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\})*)\s*(?(1)\{\{[Rr]efend\}\}) }}
 * {{code| (\{{2})([Rr]efbegin\}{2}\s*)?((?:\{{2}\s*?(?:[Tt]emplate:)??[E]fn\s*?(?:[^{}]*(?:\{{2}[^}]*\}{2})?)+\}{2}[\s*]*?)+)\s*(?(1)\{{2}[Rr]efend\}{2}) }}

List of {{tl|efn}} -> {{tl|notelist}}:
 * {{code| (\{\{[Rr]efbegin\}\})?((?:[\s*]*?\{\{\s*?(?:[Tt]emplate:)?[E]fn\s*?((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\})*)\s*(?(1)\{\{[Rr]efend\}\}|(?!)) }}
 * {{code| \{{2}([Rr]efbegin\}{2}\s*)?((?:\{{2}\s*?(?:[Tt]emplate:)??[E]fn\s*?(?:[^{}]*(?:(?(1)\{{2)[^}]*\}{2})?)+\}{2}[\s*]*?)+)\s*(?(1)\{{2}[Rr]efend\}{2}) }}
 * {{code| \{{2}([Rr]efbegin\}{2}\s*)?((?:\{{2}\s*?(?:[Tt]emplate:)??[E]fn\s*?(?:[^{}]*(?:(?(1)\{{2})[^}]*\}{2})?)+\}{2}[\s*]*?)+)\s*(?(1)\{{2}[Rr]efend\}{2}) }}

{{code| \{{2} ([Rr]efbegin\}{2}\s*)? ((?: \{{2}\s*?(?:[Tt]emplate:)??[eE]fn\s*?(?:[^{}]*(?:(?(1)\{{2})[^}]*\}{2})?)+\}{2}[\s*]*? )+) \s* (?(1)\{{2}[Rr]efend\}{2}) }}

Substitution:

Unique {{tl|cref}} -> inline {{tl|efn}}:
 * {{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\}(?=(?:[^{]*(?:(?!\{\{\s*(?:[Tt]emplate:)?[cC]note\s*\|\s*\1).)?)*\{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}
 * {{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}]*)\s*?\}\}(?=(?>[^{]*(?:.?[^{]*)*?\{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1)\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}
 * {{code| \{\{\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}\s]*)\s*?\}\}(?=(?>[^{]*(?:.?[^{]*)*?\{\{\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1)\s*?\|((?:[^{}]*(?:\{\{[^}]*\}\})?)+)\}\}) }}
 * {{code| \{{2}\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}\s]*)\s*?\}{2}(?=(?>[^{]*(?:.?[^{]*)*?\{{2}\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1)\s*?\|((?:[^{}]*(?:\{{2}[^}]*\}{2})?)+)\}{2}) }}

{{code| \{{2}\s*?(?:[Tt]emplate:)?[cC]ref\s*?\|\s*?([^}\s]*)\s*?\}{2} (?= (?>[^{]*(?:.?[^{]*)*? \{{2}\s*?(?:[Tt]emplate:)?[cC]note\s*?\|\s*?\1) \s*?\|((?:[^{}]*(?:\{{2}[^}]*\}{2})?)+)\}{2} ) }}

Midstage templates
I assume these were part of an idea to have a middle transition stage between notes templates. But I want to avoid doing that if possible. I only thought of this because it was done previously, I wonder where it was done previously.


 * efn-pre
 * notelist-pre