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)
(+delete)
 
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
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|{{#switch: {{{1|}}}<!--
 
+
       -->| delete=<!--
  CASE: force comma as last character
+
       -->| #default={{{1|}}}<!--
  -->|,= <!--
+
       -->}}<!-- switch end
  :
 
    ;
 
      .
 
        !
 
          ?
 
            , comma
 
-->{{#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 ? → 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|{{#if: trim-always|{{{2|}}}}}<!-- -->}}<!--
 +
  -->{{#vardefine: this_text_last_character|{{#sub: {{#var: this_text}}|-1|1}}<!-- -->}}<!--
  
   CASE: force exclamation mark as last character
+
   -->{{#vardefine: this_text_with_forced_character|<!--
  -->|!=  <!--
+
     -->{{#if:{{#pos: .;:?!{{#var: punctuation}}|{{#var: this_text_last_character}} }}<!--
  ?
+
       then
    ,
+
      -->|{{#sub: {{#var: this_text}}|0|-1}}<!--
      :
+
       -->|{{#var: this_text}}<!--
        ;
+
    -->}}<!-- if
          .
+
 
            ! exclamation mark
+
    fix Wiki definition list (;) or indented text (:)
-->{{#ifeq: ? |{{#sub: {{{2|}}}|-1}}<!--
+
     -->{{#ifeq: :|{{#var: punctuation}}<!--
     yes ? → remove last character + punctuation
+
      then
  -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ? | {{{allow|}}} |?|!}}<!--
+
    -->|<nowiki>:</nowiki><!--
       other
+
      else
  -->|{{#ifeq: , |{{#sub: {{{2|}}}|-1}}<!--
+
    -->|{{#ifeq: ;|{{#var: punctuation}}<!--
       yes , → remove last character + punctuation
+
        then
    -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: , | {{{allow|}}} |,|!}}<!--
+
      -->|<nowiki>;</nowiki><!--
        other
+
         else
     -->|{{#ifeq: : |{{#sub: {{{2|}}}|-1}}<!--
+
      -->|{{#var: punctuation}}<!--
        yes : → remove last character + punctuation
+
       -->}}<!-- ifeq
      -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: : | {{{allow|}}} |<nowiki>:</nowiki>|!}}<!--
+
     -->}}<!-- ifeq
          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 !
 
            -->|{{{2|}}}<!--
 
              possibly no punctuation found
 
            -->|{{{2|}}}!<!--
 
          -->}}<!--
 
        -->}}<!--
 
       -->}}<!--
 
     -->}}<!--
 
 
   -->}}<!--
 
   -->}}<!--
-->}}<!--
+
    
 
+
   -->{{#switch: {{#if: trim-always|{{{1|}}}}}
   CASE: force question mark as last character
+
   |delete=<!--
   -->|?=  <!--
+
-->{{#if:{{#pos: .;:?!{{#var: punctuation}}|{{#var: this_text_last_character}} }}<!--
  ,
+
    then
    :
+
  -->|{{#sub: {{#var: this_text}}|0|-1}}<!--
      ;
+
  -->|{{#var: this_text}}<!--
        .
+
-->}}
          !
+
  |#default=<!--
            ? question mark
+
  -->{{#ifeq: {{#var: this_text_last_character}}<!-- last character in 2:text -->|<!-- same as 1:punctuation -->{{#var: punctuation}}<!--
-->{{#ifeq: , |{{#sub: {{{2|}}}|-1}}<!--
+
  THEN
    yes , → remove last character + punctuation
+
   -->|{{#var: this_text}}<!--
  -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: , | {{{allow|}}} | ,|?}}<!--
+
   ELSE: force last punctuation
      other
+
  -->|{{#if: {{{allow|}}}<!--  
   -->|{{#ifeq: : |{{#sub: {{{2|}}}|-1}}<!--
+
    Then
      yes : → remove last character + punctuation
+
     -->|{{#if: {{#pos:{{{allow|}}}|{{#var: this_text_last_character}} }}<!--
    -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: : | {{{allow|}}} |<nowiki>:</nowiki>|?}}<!--
+
      then
        other
+
       -->|{{#var: this_text}}<!--
    -->|{{#ifeq: ; |{{#sub: {{{2|}}}|-1}}<!--
+
      else
        yes ; → remove last character + punctuation
+
      -->|{{#var: this_text_with_forced_character}}<!--
      -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: ; | {{{allow|}}} |<nowiki>;</nowiki>|?}}<!--
+
    -->}}<!--
          other
+
    Else
      -->|{{#ifeq: . |{{#sub: {{{2|}}}|-1}}<!--
+
    -->|<!--
          yes . → remove last character + punctuation
+
      -->{{#var: this_text_with_forced_character}}<!--
        -->|{{#sub: {{{2|}}} | 0 | {{#expr: {{#len: {{{2|}}} }} - 1 }} }}{{#ifeq: . | {{{allow|}}} |.|?}}<!--
+
  -->}}<!-- Ende if:allow
            other
+
   -->}}<!-- ifeq
        -->|{{#ifeq: ! |{{#sub: {{{2|}}}|-1}}<!--
+
-->}}<!-- switch
            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 68:
 
//////////////////////////
 
//////////////////////////
  
  -->{{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 86:
 
-->
 
-->
 
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 had no dot or other punctuation}}</nowiki>
 +
| {{ {{PAGENAME}}| : |Text had no dot or other punctuation}}
 +
|-
 +
|
 +
<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 … }}
 +
|-
 +
|
 +
<nowiki>{{</nowiki>{{PAGENAME}}<nowiki>| delete |only text and no punctuation}}</nowiki>
 +
| {{ {{PAGENAME}}| delete |only text and no punctuation}}
 +
|}
  
 
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

Aktuelle Version vom 19. März 2022, 22:58 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 had no dot or other punctuation}}
Text had no dot or other punctuation:
{{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 …
{{Force last punctuation| delete |only text and no punctuation}}
only text and no punctuation

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

Dependencies