Vorlage:Force last punctuation: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(+example: Text had no dot or other punctuation) |
(+delete) |
||
| (Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
| 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}}<!-- -->}}<!-- | ||
| − | -->{{#vardefine: this_text_with_forced_character|{{#if:{{#pos: .;:?!{{#var: punctuation}}|{{#var: this_text_last_character}} }}<!-- | + | -->{{#vardefine: this_text_with_forced_character|<!-- |
| + | -->{{#if:{{#pos: .;:?!{{#var: punctuation}}|{{#var: this_text_last_character}} }}<!-- | ||
then | then | ||
| + | -->|{{#sub: {{#var: this_text}}|0|-1}}<!-- | ||
-->|{{#var: this_text}}<!-- | -->|{{#var: this_text}}<!-- | ||
| − | + | -->}}<!-- if | |
| − | |||
fix Wiki definition list (;) or indented text (:) | fix Wiki definition list (;) or indented text (:) | ||
| − | -->{{#ifeq: | + | -->{{#ifeq: :|{{#var: punctuation}}<!-- |
| + | then | ||
| + | -->|<nowiki>:</nowiki><!-- | ||
| + | else | ||
| + | -->|{{#ifeq: ;|{{#var: punctuation}}<!-- | ||
then | then | ||
| − | -->|<nowiki> | + | -->|<nowiki>;</nowiki><!-- |
else | else | ||
| − | + | -->|{{#var: punctuation}}<!-- | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
-->}}<!-- ifeq | -->}}<!-- ifeq | ||
| − | -->}}<!-- | + | -->}}<!-- ifeq |
-->}}<!-- | -->}}<!-- | ||
| 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}} | ||
|} | |} | ||
Neueste Überarbeitung 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