Vorlage:Force last punctuation: Unterschied zwischen den Versionen

Aus Open Source Ecology - Germany
Zur Navigation springen Zur Suche springen
(+delete)
 
Zeile 5: Zeile 5:
 
   CASES , ; : . ! ?
 
   CASES , ; : . ! ?
  
   -->{{#vardefine: punctuation|{{#if: trim-always|{{{1|}}}}}<!-- -->}}<!--
+
   -->{{#vardefine: punctuation|{{#if: trim-always|{{#switch: {{{1|}}}<!--
 +
      -->| delete=<!--
 +
      -->| #default={{{1|}}}<!--
 +
      -->}}<!-- switch end
 +
    -->}}<!--
 +
  -->}}<!--
 
   -->{{#vardefine: this_text|{{#if: trim-always|{{{2|}}}}}<!-- -->}}<!--
 
   -->{{#vardefine: this_text|{{#if: trim-always|{{{2|}}}}}<!-- -->}}<!--
 
   -->{{#vardefine: this_text_last_character|{{#sub: {{#var: this_text}}|-1|1}}<!-- -->}}<!--
 
   -->{{#vardefine: this_text_last_character|{{#sub: {{#var: this_text}}|-1|1}}<!-- -->}}<!--
Zeile 104: Zeile 109:
 
  <nowiki>{{</nowiki>{{PAGENAME}}<nowiki>| delete |Text had no final .;:!? or so … }}</nowiki>
 
  <nowiki>{{</nowiki>{{PAGENAME}}<nowiki>| delete |Text had no final .;:!? or so … }}</nowiki>
 
| {{ {{PAGENAME}}| delete |Text had no final .;:!? or so … }}
 
| {{ {{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}}
 
|}
 
|}
  

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