How to Converts Bodies/Long Paragraph of Text Into Paragraphs | Paragraphier

A Jquery-based script that converts large strings from text into paragraphs. Paragraphier is a jQuery applet for writers that converts/splits a long paragraph into short paragraphs for easy reading.

random paragraph copy and paste, long paragraph example, html paragraph spacing, html space between words on same line, jquery plugin to highlight word within content

How to make use of it:

1. Create a Textarea component to simply accept long paragraphs.

<textarea id="text" rows="5"></textarea>

2. Create a choose component from which you’ll choose the number of sentences per paragraph.

<select id="sentences">
  <option value="2">2</option>
  <option value="4">4</option>
  <option value="6">6</option>
</select>

3. Load the required jQuery JavaScript library on the finish of the doc.

<script src="/path/to/cdn/jquery.slim.min.js"></script>

4. The most important JavaScript (jQuery script) to allow the lengthy paragraph converter.

function paragrphier(){

  let text = $('#text').val();
  let sentences = $("#sentences option:selected" ).val();

  const expectedSentenceCount = sentences;
  let overallCount = 0;
  let sentenceCount = 0;
  let previousIndex = 0;

  const totalFullStops = (text.match(/,/g) || []).length;

  
  $('#sentenceCount').html('Total Number Sentences: '+ totalFullStops);

  let newText = '';

  for(let i = 0; i < text.length; i++){
    let value = text.charAt(i);

    if(sentenceCount == expectedSentenceCount){
      newText += text.substring(previousIndex, i) + '</br></br>';
      previousIndex = i;
      sentenceCount = 0;

      if((totalFullStops - overallCount) < expectedSentenceCount ){
      newText += text.substring(previousIndex, (text.length)) + '</br></br>';
      }
    }

    if(value === '.'){
      sentenceCount += 1;
      overallCount += 1;
    }


  }
  
  
  $('#outputText').html(newText);
  
}

5. Create a convert button on the web page.

<button onclick="paragrphier()">Paragraphy</button>

6. Create an empty container to hold the output.

<div id="outputText">
</div>

long paragraph to short paragraph converter, Paragraphier Plugin/Github


See Demo And Download

Official Website(Plaganomics): Click Here

This superior jQuery/javascript plugin is developed by Plaganomics. For extra advanced usage, please go to the official website.

Related Posts

Cookie-Consent-Using-Bootstrap

How to Create a Simple Cookie Banner Consent Using Bootstrap 4

Cookie Consent Popup Javascript – Quick and simple tutorial for creating a simple Bootstrap cookie banner. If you have a website or blog with people visiting or…

Create-HTML-Terminals

Create Custom HTML Terminals With Pure JavaScript | shell.js

Custom HTML Terminals is A JavaScript library to create HTML terminals on web pages. The shell js JavaScript library offers a straightforward method to create Ubuntu, OS X,…

Bootstrap-Alert-Bootbox

Bootstrap Alert, Confirm, and Flexible Dialog Boxes | Bootbox

Bootbox.js is a small JavaScript library that allows you to create programming dialogs using Bootstrap templates, without having to worry about creating, managing, or removing any required…

Slider-fg-carousel

An Accessible Touch-enabled Slider Web Component | fg-carousel

fg-carousel Slider – A simple & modern slider web component to create versatile, accessible, touch-enabled picture carousels utilizing CSS scroll snap, Custom Element, and Intersection Observer API….

Tags-Input-Component

A Lightweight and Efficient Tags Input Component in Vanilla JS | tagify

tagify transforms an input field or textarea into a tags component, in an easy and customizable way, with great performance and a small code footprint, full of…

copy-to-clipboard-javascript

A Lightweight Library to Copy Text to Clipboard | CopyJS

CopyJS is a lightweight JavaScript library that allows you to copy plain text or HTML content to the clipboard. Must Read: Tiny Library for Copy Text In…