Difference between revisions of "Template:PrintFirstParagraph"

From Encyclopedia of Scientonomy
Jump to navigation Jump to search
Line 11: Line 11:
 
--><!-- exctract only the first 1000 characters to avoid "String exceeds 1,000 character limit" error
 
--><!-- exctract only the first 1000 characters to avoid "String exceeds 1,000 character limit" error
 
-->{{#vardefine: varTextShort|{{#sub: {{{vartext|}}}|0|800}}|}}<!--
 
-->{{#vardefine: varTextShort|{{#sub: {{{vartext|}}}|0|800}}|}}<!--
 +
-->{{#vardefine: varLen|{{#len: {{#var: varTextShort}} }}|}}<!--
 +
-->varlen={{#var: varLen}}<!-- 
 
--><!--   
 
--><!--   
 
--><!-- check if there is a paragraph sign
 
--><!-- check if there is a paragraph sign
Line 20: Line 22:
 
   -->|<!-- if there is one paragraph or less
 
   -->|<!-- if there is one paragraph or less
 
   --><!--   
 
   --><!--   
  -->{{#vardefine: varLen|{{#len: {{#var: varTextShort}} }}|}}<!--
 
  -->varlen={{#var: varLen}}<!-- 
 
 
   -->{{#if: {{#expr: {{#var: varLen}} > 997}}<!--
 
   -->{{#if: {{#expr: {{#var: varLen}} > 997}}<!--
 
     -->|{{#sub: {{#var: varTextShort}}|0|500}}&#8230;<!--
 
     -->|{{#sub: {{#var: varTextShort}}|0|500}}&#8230;<!--

Revision as of 00:26, 15 March 2018

This template is used to extract the first paragraph from a given text. If the first paragraph of the text is longer than 1000 characters, only the first 997 characters are returned, and an ellipsis (…) is added.

NOTE: As any "printing" template, it doesn't store any values anywhere, but merely returns them.

Parameters:

  • |vartext= - the text to extract the first paragraph from.