Vorlage:Force last punctuation: Unterschied zwischen den Versionen

Aus Open Source Ecology - Germany
Zur Navigation springen Zur Suche springen
K (1 Version importiert: Import für Literatursystem von https://offene-naturfuehrer.de/web/Vorlage:Literatur)
(clean code)
Zeile 1: Zeile 1:
 
<includeonly>{{#if: {{{1|}}}<!-- (1) Parameter 1 given?
 
<includeonly>{{#if: {{{1|}}}<!-- (1) Parameter 1 given?
 
   {{{1|}}} → punctuation
 
   {{{1|}}} → punctuation
   {{{2|}}} → string
+
   {{{2|}}} → this_text
 
THEN -->|<!--
 
THEN -->|<!--
 
   CASES , ; : . ! ?
 
   CASES , ; : . ! ?
  
   -->{{#switch:{{Trim|{{{1|}}}}}<!--
+
   -->{{#vardefine: punctuation|{{#if: trim-always|{{{1|}}}}}<!-- -->}}<!--
 
+
  -->{{#vardefine: this_text|{{#if: trim-always|{{{2|}}}}}<!-- -->}}<!--
  CASE: force comma as last character
+
  -->{{#vardefine: this_text_with_forced_character|{{#sub: {{#var: this_text}}|0|-1}}<!--
  -->|,= <!--
+
     fix Wiki definition list (;) or indented text (:)
  :
+
     -->{{#ifeq: :|{{#var: punctuation}}<!--
    ;
+
       then
      .
+
     -->|<nowiki>:</nowiki><!--
        !
+
       else
          ?
+
    -->|{{#ifeq: ;|{{#var: punctuation}}<!--
            , comma
+
         then
-->{{#ifeq: : |{{#sub: {{{2|}}}|-1}}<!--
+
       -->|<nowiki>;</nowiki><!--
    yes : → remove last character + punctuation
+
         else
  -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: : | {{{allow|}}} |<nowiki>:</nowiki>|,}}<!--
+
       -->|{{#var: punctuation}}<!--
      other
 
  -->|{{#ifeq: ; |{{#sub: {{{2|}}}|-1}}<!--
 
      yes ; → remove last character + punctuation
 
    -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ; | {{{allow|}}} |<nowiki>;</nowiki>|,}}<!--
 
        other
 
    -->|{{#ifeq: . |{{#sub: {{{2|}}}|-1}}<!--
 
        yes . → remove last character + punctuation
 
      -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: . | {{{allow|}}} |.|,}}<!--
 
          other
 
      -->|{{#ifeq: ! |{{#sub: {{{2|}}}|-1}}<!--
 
          yes ! → remove last character + punctuation
 
        -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ! | {{{allow|}}} |!|,}}<!--
 
            other
 
        -->|{{#ifeq: ? |{{#sub: {{{2|}}}|-1}}<!--
 
            yes ? → remove last character + punctuation
 
          -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ? | {{{allow|}}} |?|,}}<!--
 
              other
 
          -->|{{#ifeq: , |{{#sub: {{{2|}}}|-1}}<!--
 
              yes ,
 
            -->|{{{2|}}}<!--
 
              possibly no punctuation found
 
            -->|{{{2|}}},<!--
 
          -->}}<!--
 
        -->}}<!--
 
      -->}}<!--
 
     -->}}<!--
 
  -->}}<!--
 
-->}}<!--
 
 
 
  CASE: force semicolon as last character
 
  -->|;= <!--
 
  .
 
    !
 
      ?
 
        ,
 
          :
 
            ; semicolon
 
-->{{#ifeq: . |{{#sub: {{{2|}}}|-1}}<!--
 
     yes . → remove last character + punctuation
 
  -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: . | {{{allow|}}} |.|<nowiki>;</nowiki>}}<!--
 
      other
 
  -->|{{#ifeq: ! |{{#sub: {{{2|}}}|-1}}<!--
 
       yes ! → remove last character + punctuation
 
     -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ! | {{{allow|}}} |!|<nowiki>;</nowiki>}}<!--
 
        other
 
    -->|{{#ifeq: ? |{{#sub: {{{2|}}}|-1}}<!--
 
        yes ? → remove last character + punctuation
 
      -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ? | {{{allow|}}} |?|<nowiki>;</nowiki>}}<!--
 
          other
 
       -->|{{#ifeq: , |{{#sub: {{{2|}}}|-1}}<!--
 
          yes , → remove last character + punctuation
 
        -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: , | {{{allow|}}} |,|<nowiki>;</nowiki>}}<!--
 
            other
 
        -->|{{#ifeq: : |{{#sub: {{{2|}}}|-1}}<!--
 
            yes : → remove last character + punctuation
 
          -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: : | {{{allow|}}} |<nowiki>:</nowiki>|<nowiki>;</nowiki>}}<!--
 
              other
 
          -->|{{#ifeq: ; |{{#sub: {{{2|}}}|-1}}<!--
 
              yes ;
 
            -->|{{{2|}}}<!--
 
              possibly no punctuation found
 
            -->|{{{2|}}};<!--
 
          -->}}<!--
 
         -->}}<!--
 
       -->}}<!--
 
    -->}}<!--
 
  -->}}<!--
 
-->}}<!--
 
 
 
  CASE: force colon as last character
 
  -->|:= <!--
 
  ;
 
    .
 
      !
 
        ?
 
          ,
 
            : colon → Beware! It becomes indentation if parsed through {{#if: }} etc.
 
-->{{#ifeq: ; |{{#sub: {{{2|}}}|-1}}<!--
 
    yes ; → remove last character + punctuation
 
  -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ; | {{{allow|}}} |<nowiki>;</nowiki>|<nowiki>:</nowiki>}}<!--
 
      other
 
  -->|{{#ifeq: . |{{#sub: {{{2|}}}|-1}}<!--
 
      yes . → remove last character + punctuation
 
    -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: . | {{{allow|}}} |.|<nowiki>:</nowiki>}}<!--
 
        other
 
    -->|{{#ifeq: ! |{{#sub: {{{2|}}}|-1}}<!--
 
        yes ! → remove last character + punctuation
 
      -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ! | {{{allow|}}} |!|<nowiki>:</nowiki>}}<!--
 
          other
 
      -->|{{#ifeq: ? |{{#sub: {{{2|}}}|-1}}<!--
 
          yes ? → remove last character + punctuation
 
        -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ? | {{{allow|}}} |?|<nowiki>:</nowiki>}}<!--
 
            other
 
        -->|{{#ifeq: , |{{#sub: {{{2|}}}|-1}}<!--
 
            yes , → remove last character + punctuation
 
          -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: , | {{{allow|}}} |,|<nowiki>:</nowiki>}}<!--
 
              other
 
          -->|{{#ifeq: : |{{#sub: {{{2|}}}|-1}}<!--
 
              yes :
 
            -->|{{{2|}}}<!--
 
              possibly no punctuation found
 
            -->|{{{2|}}}:<!--
 
          -->}}<!--
 
        -->}}<!--
 
      -->}}<!--
 
    -->}}<!--
 
  -->}}<!--
 
-->}}<!--
 
 
 
  CASE: force dot as last character
 
  -->|.= <!--
 
  !
 
    ?
 
      ,
 
         :
 
          ;
 
            . dot
 
-->{{#ifeq: ! |{{#sub: {{{2|}}}|-1}}<!--
 
    yes ! → remove last character + punctuation
 
  -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ! | {{{allow|}}} |!|.}}<!--
 
      other
 
  -->|{{#ifeq: ? |{{#sub: {{{2|}}}|-1}}<!--
 
      yes ? → remove last character + punctuation
 
    -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ? | {{{allow|}}} |?|.}}<!--
 
        other
 
    -->|{{#ifeq: , |{{#sub: {{{2|}}}|-1}}<!--
 
        yes , → remove last character + punctuation
 
      -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: , | {{{allow|}}} |,|.}}<!--
 
          other
 
       -->|{{#ifeq: : |{{#sub: {{{2|}}}|-1}}<!--
 
          yes : → remove last character + punctuation
 
        -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: : | {{{allow|}}} |<nowiki>:</nowiki>|.}}<!--
 
            other
 
        -->|{{#ifeq: ; |{{#sub: {{{2|}}}|-1}}<!--
 
            yes ; → remove last character + punctuation
 
          -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ; | {{{allow|}}} |<nowiki>;</nowiki>|.}}<!--
 
              other
 
          -->|{{#ifeq: . |{{#sub: {{{2|}}}|-1}}<!--
 
              yes .
 
            -->|{{{2|}}}<!--
 
              possibly no punctuation found
 
            -->|{{{2|}}}.<!--
 
          -->}}<!--
 
        -->}}<!--
 
 
       -->}}<!--
 
       -->}}<!--
 
     -->}}<!--
 
     -->}}<!--
 
   -->}}<!--
 
   -->}}<!--
-->}}<!--
+
   -->{{#vardefine: this_text_last_character|{{#sub: {{#var: this_text}}|-1|1}}<!-- -->}}<!--
 
+
 
  CASE: force exclamation mark as last character
+
  -->{{#switch: {{#if: trim-always|{{{1|}}}}}
   -->|!=  <!--
+
  |delete=<!--
  ?
+
-->{{#if:{{#pos: .;:?!|{{#var: this_text_last_character}} }}<!--
    ,
+
     then
      :
+
   -->|{{#sub: {{#var: this_text}}|0|-1}}<!--
        ;
+
   -->|{{#var: this_text}}<!--
          .
+
-->}}  
            ! exclamation mark
+
  |#default=<!--
-->{{#ifeq: ? |{{#sub: {{{2|}}}|-1}}<!--
+
  -->{{#ifeq: {{#var: this_text_last_character}}<!-- last character in 2:text -->|<!-- same as 1:punctuation -->{{#var: punctuation}}<!--
    yes ? → remove last character + punctuation
+
  THEN
  -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ? | {{{allow|}}} |?|!}}<!--
+
  -->|{{#var: this_text}}<!--
      other
+
   ELSE: force last punctuation
  -->|{{#ifeq: , |{{#sub: {{{2|}}}|-1}}<!--
+
   -->|{{#if: {{{allow|}}}<!--  
      yes , → remove last character + punctuation
+
     Then
    -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: , | {{{allow|}}} |,|!}}<!--
+
    -->|{{#if: {{#pos:{{{allow|}}}|{{#var: this_text_last_character}} }}<!--
        other
+
       then
    -->|{{#ifeq: : |{{#sub: {{{2|}}}|-1}}<!--
+
      -->|{{#var: this_text}}<!--
        yes : → remove last character + punctuation
+
       else
      -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: : | {{{allow|}}} |<nowiki>:</nowiki>|!}}<!--
+
       -->|{{#var: this_text_with_forced_character}}<!--
          other
+
    -->}}<!--
      -->|{{#ifeq: ; |{{#sub: {{{2|}}}|-1}}<!--
+
    Else
          yes ; → remove last character + punctuation
+
    -->|<!--
        -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ; | {{{allow|}}} |<nowiki>;</nowiki>|!}}<!--
+
      -->{{#var: this_text_with_forced_character}}<!--
            other
+
  -->}}<!-- Ende if:allow
        -->|{{#ifeq: . |{{#sub: {{{2|}}}|-1}}<!--
+
   -->}}<!-- ifeq
            yes . → remove last character + punctuation
+
-->}}<!-- switch
          -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: . | {{{allow|}}} |.|!}}<!--
+
    
              other
 
          -->|{{#ifeq: ! |{{#sub: {{{2|}}}|-1}}<!--
 
              yes !
 
            -->|{{{2|}}}<!--
 
              possibly no punctuation found
 
            -->|{{{2|}}}!<!--
 
          -->}}<!--
 
        -->}}<!--
 
      -->}}<!--
 
     -->}}<!--
 
  -->}}<!--
 
-->}}<!--
 
 
 
  CASE: force question mark as last character
 
  -->|?=  <!--
 
   ,
 
    :
 
      ;
 
        .
 
          !
 
            ? question mark
 
-->{{#ifeq: , |{{#sub: {{{2|}}}|-1}}<!--
 
    yes , → remove last character + punctuation
 
  -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: , | {{{allow|}}} | ,|?}}<!--
 
      other
 
   -->|{{#ifeq: : |{{#sub: {{{2|}}}|-1}}<!--
 
      yes : → remove last character + punctuation
 
    -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: : | {{{allow|}}} |<nowiki>:</nowiki>|?}}<!--
 
        other
 
    -->|{{#ifeq: ; |{{#sub: {{{2|}}}|-1}}<!--
 
        yes ; → remove last character + punctuation
 
      -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ; | {{{allow|}}} |<nowiki>;</nowiki>|?}}<!--
 
          other
 
      -->|{{#ifeq: . |{{#sub: {{{2|}}}|-1}}<!--
 
          yes . → remove last character + punctuation
 
        -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: . | {{{allow|}}} |.|?}}<!--
 
            other
 
        -->|{{#ifeq: ! |{{#sub: {{{2|}}}|-1}}<!--
 
            yes ! → remove last character + punctuation
 
          -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ! | {{{allow|}}} |!|?}}<!--
 
              other
 
          -->|{{#ifeq: ? |{{#sub: {{{2|}}}|-1}}<!--
 
              yes ?
 
            -->|{{{2|}}}<!--
 
              possibly no punctuation found
 
            -->|{{{2|}}}?<!--
 
          -->}}<!--
 
        -->}}<!--
 
      -->}}<!--
 
    -->}}<!--
 
   -->}}<!--
 
-->}}<!--
 
 
 
  CASE: force no punctuation
 
   -->| delete = <!--
 
  ;
 
    .
 
      !
 
        ?
 
          ,
 
            :
 
              no punctuation
 
-->{{#ifeq: ; |{{#sub: {{{2|}}}|-1}}<!--
 
     yes ; → remove last character + punctuation
 
  -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}<!--
 
      other
 
  -->|{{#ifeq: . |{{#sub: {{{2|}}}|-1}}<!--
 
       yes . → remove last character + punctuation
 
    -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}<!--
 
        other
 
    -->|{{#ifeq: ! |{{#sub: {{{2|}}}|-1}}<!--
 
        yes ! → remove last character + punctuation
 
       -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}<!--
 
          other
 
       -->|{{#ifeq: ? |{{#sub: {{{2|}}}|-1}}<!--
 
          yes ? → remove last character + punctuation
 
        -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}<!--
 
            other
 
        -->|{{#ifeq: , |{{#sub: {{{2|}}}|-1}}<!--
 
            yes , → remove last character + punctuation
 
          -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}<!--
 
              other
 
          -->|{{#ifeq: : |{{#sub: {{{2|}}}|-1}}<!--
 
              yes : → remove just last character
 
            -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}<!--
 
                possibly no punctuation found
 
            -->|{{{2|}}}<!--
 
          -->}}<!--
 
        -->}}<!--
 
      -->}}<!--
 
    -->}}<!--
 
   -->}}<!--
 
-->}}<!--
 
 
 
   TODO something other to implement?
 
  -->| #default = {{{2|}}}<!--
 
-->}}<!--
 
 
ELSE  -->|<!--
 
ELSE  -->|<!--
  
Zeile 297: Zeile 56:
 
//////////////////////////
 
//////////////////////////
  
  -->{{TemplateError | text = <!--
+
  --><div class="error"><!--
 
  (3) Examples here  -->
 
  (3) Examples here  -->
 
This template checks for the last punctuation character and removes it if there should be comma (,) colon (:) semicolon (;) exclamation mark (!) question mark (?) or a dot (.). So it forces to be there one of these characters. But it can also remove the last character. Examples:
 
This template checks for the last punctuation character and removes it if there should be comma (,) colon (:) semicolon (;) exclamation mark (!) question mark (?) or a dot (.). So it forces to be there one of these characters. But it can also remove the last character. Examples:
 
# <code><nowiki>{{force last punctuation | : |Text had a dot.}}</nowiki></code> → Text had a dot:
 
# <code><nowiki>{{force last punctuation | : |Text had a dot.}}</nowiki></code> → Text had a dot:
# <code><nowiki>{{force last punctuation | . |Text and question mark remains? | allow = ? }}</nowiki></code> → Text and question mark remains? (force a dot if no question mark)
+
# <code><nowiki>{{force last punctuation | . |Text and question mark remains? | allow = ?! }}</nowiki></code> → Text and question mark remains? (force a dot if no question mark or exclamation mark)
 
# <code><nowiki>{{force last punctuation | delete |Text had a question mark?}}</nowiki></code> → Text had a question mark
 
# <code><nowiki>{{force last punctuation | delete |Text had a question mark?}}</nowiki></code> → Text had a question mark
  
 
There exist also the [[template: remove last punctuation]], which is just a wrapper to <code><nowiki>{{force last punctuation | delete |Text had a question mark?}}</nowiki></code>.
 
There exist also the [[template: remove last punctuation]], which is just a wrapper to <code><nowiki>{{force last punctuation | delete |Text had a question mark?}}</nowiki></code>.
 
<!--
 
<!--
  -->}}<!-- end error handling -->
+
  --></div><!-- end error handling -->
}}<!-- if {{{1|}}} end --><!--
+
}}<!-- if {{{1|}}} end
 
  --></includeonly><noinclude><!--
 
  --></includeonly><noinclude><!--
 
  (4) Short documentation here.
 
  (4) Short documentation here.
Zeile 315: Zeile 74:
 
-->
 
-->
 
This template checks for the last punctuation character and removes it if there should be comma (,) colon (:) semicolon (;) exclamation mark (!) question mark (?) or a dot (.). So it forces to be there one of these characters. But it can also remove the last character. Examples:
 
This template checks for the last punctuation character and removes it if there should be comma (,) colon (:) semicolon (;) exclamation mark (!) question mark (?) or a dot (.). So it forces to be there one of these characters. But it can also remove the last character. Examples:
# <code><nowiki>{{force last punctuation | : |Text had a dot.}}</nowiki></code> → Text had a dot:
+
{| class="wikitable"
# <code><nowiki>{{force last punctuation | . |Text and question mark remains? | allow = ? }}</nowiki></code> → Text and question mark remains? (force a dot if no question mark)
+
|-
# <code><nowiki>{{force last punctuation | delete |Text had a question mark?}}</nowiki></code> Text had a question mark
+
! Code !! Result
 +
|-
 +
|
 +
<nowiki>{{</nowiki>{{PAGENAME}}<nowiki>| : |Text had a dot.}}</nowiki>
 +
| {{ {{PAGENAME}}| : |Text had a dot.}}
 +
|-
 +
|
 +
<nowiki>{{</nowiki>{{PAGENAME}}<nowiki>| . |Text and question mark remains? | allow = ?! }}</nowiki>
 +
| {{ {{PAGENAME}}| . |Text and question mark remains? | allow = ?! }}
 +
|-
 +
|
 +
<nowiki>{{</nowiki>{{PAGENAME}}<nowiki>| delete |Text had a question mark? }}</nowiki>
 +
| {{ {{PAGENAME}}| delete |Text had a question mark? }}
 +
|-
 +
|
 +
<nowiki>{{</nowiki>{{PAGENAME}}<nowiki>| delete |Text had no final .;:!? or so … }}</nowiki>
 +
| {{ {{PAGENAME}}| delete |Text had no final .;:!? or so … }}
 +
|}
  
 
There exist also the [[template: remove last punctuation]], which is just a wrapper to <code><nowiki>{{force last punctuation | delete |Text had a question mark?}}</nowiki></code>.
 
There exist also the [[template: remove last punctuation]], which is just a wrapper to <code><nowiki>{{force last punctuation | delete |Text had a question mark?}}</nowiki></code>.
 +
 +
== Dependencies ==
 +
 +
* [[mediawikiwiki: Extension:Variables|Extension:Variables]]
 +
 
[[Category: {{#switch: {{CONTENTLANGUAGE}}
 
[[Category: {{#switch: {{CONTENTLANGUAGE}}
 
| de = Vorlagenprogrammierung
 
| de = Vorlagenprogrammierung
 +
| de-formal = Vorlagenprogrammierung
 
| en = Template programming
 
| en = Template programming
 
| #default = Template programming
 
| #default = Template programming

Version vom 3. April 2020, 14:38 Uhr

This template checks for the last punctuation character and removes it if there should be comma (,) colon (:) semicolon (;) exclamation mark (!) question mark (?) or a dot (.). So it forces to be there one of these characters. But it can also remove the last character. Examples:

Code Result
{{Force last punctuation| : |Text had a dot.}}
Text had a dot:
{{Force last punctuation| . |Text and question mark remains? | allow = ?! }}
Text and question mark remains?
{{Force last punctuation| delete |Text had a question mark? }}
Text had a question mark
{{Force last punctuation| delete |Text had no final .;:!? or so … }}
Text had no final .;:!? or so …

There exist also the template: remove last punctuation, which is just a wrapper to {{force last punctuation | delete |Text had a question mark?}}.

Dependencies