Vorlage:Force last punctuation: Unterschied zwischen den Versionen
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|}}} → | + | {{{2|}}} → this_text |
THEN -->|<!-- | THEN -->|<!-- | ||
CASES , ; : . ! ? | CASES , ; : . ! ? | ||
| − | -->{{# | + | -->{{#vardefine: punctuation|{{#if: trim-always|{{#switch: {{{1|}}}<!-- |
| − | + | -->| delete=<!-- | |
| − | + | -->| #default={{{1|}}}<!-- | |
| − | + | -->}}<!-- switch end | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | -->}}<!-- | ||
-->}}<!-- | -->}}<!-- | ||
-->}}<!-- | -->}}<!-- | ||
| − | -->}}<!-- | + | -->{{#vardefine: this_text|{{#if: trim-always|{{{2|}}}}}<!-- -->}}<!-- |
| + | -->{{#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}} }}<!-- | |
| − | + | then | |
| − | + | -->|{{#sub: {{#var: this_text}}|0|-1}}<!-- | |
| − | + | -->|{{#var: this_text}}<!-- | |
| − | + | -->}}<!-- if | |
| − | + | ||
| − | + | fix Wiki definition list (;) or indented text (:) | |
| − | -->{{# | + | -->{{#ifeq: :|{{#var: punctuation}}<!-- |
| − | + | then | |
| − | + | -->|<nowiki>:</nowiki><!-- | |
| − | + | else | |
| − | + | -->|{{#ifeq: ;|{{#var: punctuation}}<!-- | |
| − | + | then | |
| − | + | -->|<nowiki>;</nowiki><!-- | |
| − | + | else | |
| − | --> | + | -->|{{#var: punctuation}}<!-- |
| − | + | -->}}<!-- ifeq | |
| − | + | -->}}<!-- ifeq | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | -->}}<!-- | ||
| − | -->}}<!-- | ||
-->}}<!-- | -->}}<!-- | ||
| − | + | ||
| − | + | -->{{#switch: {{#if: trim-always|{{{1|}}}}} | |
| − | + | |delete=<!-- | |
| − | + | -->{{#if:{{#pos: .;:?!{{#var: punctuation}}|{{#var: this_text_last_character}} }}<!-- | |
| − | + | then | |
| − | + | -->|{{#sub: {{#var: this_text}}|0|-1}}<!-- | |
| − | + | -->|{{#var: this_text}}<!-- | |
| − | + | -->}} | |
| − | + | |#default=<!-- | |
| − | + | -->{{#ifeq: {{#var: this_text_last_character}}<!-- last character in 2:text -->|<!-- same as 1:punctuation -->{{#var: punctuation}}<!-- | |
| − | -->{{# | + | THEN |
| − | + | -->|{{#var: this_text}}<!-- | |
| − | + | ELSE: force last punctuation | |
| − | + | -->|{{#if: {{{allow|}}}<!-- | |
| − | + | Then | |
| − | + | -->|{{#if: {{#pos:{{{allow|}}}|{{#var: this_text_last_character}} }}<!-- | |
| − | + | then | |
| − | + | -->|{{#var: this_text}}<!-- | |
| − | + | else | |
| − | + | -->|{{#var: this_text_with_forced_character}}<!-- | |
| − | + | -->}}<!-- | |
| − | + | Else | |
| − | + | -->|<!-- | |
| − | + | -->{{#var: this_text_with_forced_character}}<!-- | |
| − | + | -->}}<!-- Ende if:allow | |
| − | + | -->}}<!-- ifeq | |
| − | + | -->}}<!-- switch | |
| − | + | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | -->{{# | ||
| − | |||
| − | -->|{{# | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | -->|{{# | ||
| − | |||
| − | |||
| − | |||
| − | -->|{{# | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | -->}}<!-- | ||
| − | -->}}<!-- | ||
| − | |||
| − | |||
| − | |||
| − | |||
ELSE -->|<!-- | ELSE -->|<!-- | ||
| Zeile 297: | Zeile 68: | ||
////////////////////////// | ////////////////////////// | ||
| − | --> | + | --><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>. | ||
<!-- | <!-- | ||
| − | --> | + | --></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: | ||
| − | + | {| class="wikitable" | |
| − | + | |- | |
| − | + | ! 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 | ||
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