Advertisement:

Navigation

SMF Mod Site

Mod Name:
Paragrapher
Created By:
Sesquipedalian
Type:
New Feature
First Created:
December 07, 2015, 03:34:28 PM
Last Modified:
September 18, 2020, 08:52:29 PM
Latest Version:
2.3
Compatible With:
2.0.11, 2.0.15, 2.0.17, 2.1 RC1, 2.1 RC2
Total Downloads:
493

Download this mod

Paragrapher.tar.gz (18kB) [23]
Manual Install Instructions for SMF


Below are some preview images of what the mod looks like when being used

Description:

Paragrapher

Paragrapher reformats the HTML generated from user posts so that it uses semantically correct <p></p> elements rather than <br> elements.


Features

  • Intelligently converts line breaks into paragraphs.
  • Admin can choose whether to preserve the original visual layout or to normalize it.
  • The content of [code][/code], [pre][/pre], and [php][/php] BBCodes is always left untouched.
  • Does not modify the content of posts in the database.
  • Does not interfere with the editor.
  • Does not interfere with BBCode parsing.
  • Acts on posts and personal messages within the forum, in RSS feeds, and via SSI.
  • Can be extended and integrated with other mods and custom code with very little work.

Because Paragrapher never modifies the content of any stored data, you can freely install, uninstall, or change the settings at any time without consequences.


Settings

Two admin settings are available in Administration Center ► Modification Settings ► Miscellaneous:

  • Normalize layout when formatting paragraphs: Enabling this will collapse extra lines of white space between paragraphs, resulting in more consistent formatting in the output. Leave it disabled to preserve the original visual layout.
  • Allow single line breaks to create new paragraphs: This offers three options.
    • Never: (Default) Users must always enter at least two line breaks to create a new paragraph.
    • Always: One line break will be enough to create a new paragraph.
    • Intelligently: (Recommended) Paragrapher will attempt to analyze and adapt to the author's writing style when making this decision for each post.


Extending Paragrapher

Forum admins and even other mods can easily integrate Paragrapher into their code wherever they like.

If you want Paragrapher to process a string of text stored in a variable called $str, paste the following into your code at an appropriate point in the relevant PHP file:
Code: [Select]
call_integration_hook('integrate_paragrapher_string', array(&$str));
If you have some data in an array called $foo, and you want Paragrapher to process its 'desc' element, use this:
Code: [Select]
call_integration_hook('integrate_paragrapher_post', array(&$foo, 'desc'));
If you have an multidimensional array called $bar, and you want Paragrapher to process the 'body' element of every sub-array inside $bar, use this:
Code: [Select]
call_integration_hook('integrate_paragrapher_posts', array(&$bar, 'body'));

License

Paragrapher uses code derived from WordPress, and is therefore released under the GPLv2 (or later). A copy of this license in included in the package file.


Changelog

Version 2.3:
  • Improves content handling for some less common HTML elements
  • Avoids creating unnecessary <p> elements inside <li>, <td>, etc.
  • Improves code efficiency

Version 2.2:
  • Posts no longer appear "un-paragraphed" after using the Quick Edit button. (Previously it was necessary to refresh the page after using Quick Edit.)
  • Ignores the content of [php][/php] BBCodes
  • Fixes a bug with handling <hr> elements
  • Improves code efficiency

Version 2.1:
  • Adds Latin Spanish translation

Version 2.0:
  • Adds a new option to control handling of single line breaks
  • Improves handling of preserved line breaks when not using the "normalize layout" option
  • Improves handling of paragraphs inside list items
  • Supports SMF 2.1
  • Rewritten to use integration hooks everywhere
    • Uses standard integration hooks on SMF 2.1
    • Creates custom integration hooks on SMF 2.0
  • Declares several generic integration hooks to enable easy integration with other mods and custom code
  • Makes some minor CSS improvements

Version 1.1:

Version 1.0.1:
  • Replaces "preserve layout" option with "normalize layout" option

Version 1.0:
  • Initial submission to simplemachines.org