Advertisement:

Author Topic: Paragrapher  (Read 2812 times)

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sophist Member
  • *
  • Posts: 1,126
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Paragrapher
« on: February 27, 2016, 05:59:09 PM »
Link to Mod

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.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
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline pocttopus

  • Full Member
  • ***
  • Posts: 467
  • Low pressure
    • @pocttopus on Twitter
    • mkreef.com
Re: Paragrapher
« Reply #1 on: March 24, 2019, 07:10:46 AM »
Could you please send a screenshot of how this mod is working?
Thanks.

Offline woolly bugger

  • Jr. Member
  • **
  • Posts: 182
    • Blue Ridge Fly Fisherman's Forum
Re: Paragrapher
« Reply #2 on: March 24, 2019, 01:56:53 PM »
Thanks, this fixed all of the tages that became visible in the members signatures after the 2.1 upgrade!

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sophist Member
  • *
  • Posts: 1,126
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Paragrapher
« Reply #3 on: March 25, 2019, 07:37:11 AM »
Could you please send a screenshot of how this mod is working?
Thanks.

Done.

Thanks, this fixed all of the tages that became visible in the members signatures after the 2.1 upgrade!

I'm not sure what you are referring to, nor do I understand how this mod could have solved your problem. But if it did, I'm glad it was helpful to you. :)
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 3,652
  • Gender: Male
  • Learning more every day!
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: Paragrapher
« Reply #4 on: March 25, 2019, 10:00:14 AM »
As it is in the branch 2.0.and 2.1 I have some doubts with the language files but I leave the translations to the Latin Spanish as well.

Code: [Select]
<file name="$languagedir/Modifications.spanish_latin.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['paragrapher_normalize_layout'] = 'Normalizar la disposici&oacute;n al dar formato a los p&aacute;rrafos';]]></add>
</operation>
</file>

<file name="$languagedir/Modifications.spanish_latin-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['paragrapher_normalize_layout'] = 'Normalizar la disposición al dar formato a los párrafos';]]></add>
</operation>
</file>

Anything you will tell me...


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2020
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,651
    • StoryBB/StoryBB on GitHub
Re: Paragrapher
« Reply #5 on: March 25, 2019, 06:40:54 PM »
Like it. Not for all forums, but like the idea.
Please don’t PM me for paid work, I’m not for hire, and even if I was, I doubt you could afford me.
USD$150 per hour. Typical waiting list 3 months.

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sophist Member
  • *
  • Posts: 1,126
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Paragrapher
« Reply #6 on: March 25, 2019, 08:10:22 PM »
As it is in the branch 2.0.and 2.1 I have some doubts with the language files but I leave the translations to the Latin Spanish as well.

Code: [Select]
<file name="$languagedir/Modifications.spanish_latin.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['paragrapher_normalize_layout'] = 'Normalizar la disposici&oacute;n al dar formato a los p&aacute;rrafos';]]></add>
</operation>
</file>

<file name="$languagedir/Modifications.spanish_latin-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['paragrapher_normalize_layout'] = 'Normalizar la disposición al dar formato a los párrafos';]]></add>
</operation>
</file>

Anything you will tell me...


Regards!

Thanks again, Rock Lee. I've added your translations to version 2.1 of Paragrapher.

There was no need to include translated changes to the Modifications language file. That stuff only appears in the upgrade_SMF20.xml because that file is used to remove changes when upgrading from Paragrapher 1.x to 2.x. But thanks for taking the time to be so thorough! :)

Like it. Not for all forums, but like the idea.

Thanks. I agree that this isn't for every forum. It all depends on who the target demographic is. I mostly use this mod for forums where users may not be tech-savvy enough to know the formatting conventions of the Internet and how they differ from those of paper-based documents.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,779
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Paragrapher
« Reply #7 on: March 26, 2019, 01:24:00 AM »
What happens in the situation the user wants two or more line breaks? Does The mod add an empty <p></p> tag in between?

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sophist Member
  • *
  • Posts: 1,126
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Paragrapher
« Reply #8 on: March 26, 2019, 01:37:08 AM »
What happens in the situation the user wants two or more line breaks? Does The mod add an empty <p></p> tag in between?

That depends on the "Normalize layout when formatting paragraphs" setting. If the "Normalize layout" setting is disabled, the extra <br> tags will be wrapped in a <div></div> in order to preserve them. If the "Normalize layout" setting is enabled, the extra <br> tags will be stripped out.

Since both the "Normalize layout when formatting paragraphs" setting and the "Allow single line breaks to create new paragraphs" setting are disabled by default, the visual layout of posts will appear unchanged after the mod is first installed.

The admin can test the effects of each setting without making any permanent changes to the forum's content at all. If you try one setting for a while, and then you or your users decide that you/they don't like it, you can simply turn it back off and everything will go back to normal.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 3,652
  • Gender: Male
  • Learning more every day!
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: Paragrapher
« Reply #9 on: March 26, 2019, 09:07:27 AM »
Thanks again, Rock Lee. I've added your translations to version 2.1 of Paragrapher.

There was no need to include translated changes to the Modifications language file. That stuff only appears in the upgrade_SMF20.xml because that file is used to remove changes when upgrading from Paragrapher 1.x to 2.x. But thanks for taking the time to be so thorough! :)

That's the doubt I had but that's why I take my time calmly and translate everything, if you have to do it well :P, right?


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2020
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Offline njtweb

  • Sophist Member
  • *****
  • Posts: 1,012
Re: Paragrapher
« Reply #10 on: March 26, 2019, 09:26:22 AM »
Trying to figure out what the use for this mod is? Is it for lazy people who just don't want to hit the enter key when typing?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,651
    • StoryBB/StoryBB on GitHub
Re: Paragrapher
« Reply #11 on: March 26, 2019, 09:28:43 AM »
It’s more for people who get confused around how many line breaks they actually need and who don’t exactly get how bbcode works.
Please don’t PM me for paid work, I’m not for hire, and even if I was, I doubt you could afford me.
USD$150 per hour. Typical waiting list 3 months.

Offline njtweb

  • Sophist Member
  • *****
  • Posts: 1,012
Re: Paragrapher
« Reply #12 on: March 26, 2019, 09:37:19 AM »
Ok, got it. There is a very small group of my traffic that actually know what BBCode is and how to use it. 99% of the time they contact me asking to add attachments, embed images etc.

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sophist Member
  • *
  • Posts: 1,126
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Paragrapher
« Reply #13 on: March 26, 2019, 06:52:17 PM »
It’s more for people who get confused around how many line breaks they actually need and who don’t exactly get how bbcode works.

That, and for people like me who care about having consistently formatted content and semantically correct HTML on their sites. :)
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sophist Member
  • *
  • Posts: 1,126
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Paragrapher
« Reply #14 on: March 26, 2019, 06:58:47 PM »
That's the doubt I had but that's why I take my time calmly and translate everything, if you have to do it well :P, right?

Agreed and much appreciated. :)
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline RGMears

  • Semi-Newbie
  • *
  • Posts: 48
    • studio five
Re: Paragrapher
« Reply #15 on: June 30, 2020, 08:56:53 AM »
I am using this Mod.
When I look at the page code (view source) it is doing something peculiar:
After an <hr /> tag the text for the next bit of content displays, regardless how long it is.
Then there is a </p> tag. But there is no opening <p> tag.

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sophist Member
  • *
  • Posts: 1,126
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Paragrapher
« Reply #16 on: June 30, 2020, 03:59:45 PM »
Can you provide me with a copy of the raw text of the post that causes this, RGMears? You can send it to me via a private message.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline RGMears

  • Semi-Newbie
  • *
  • Posts: 48
    • studio five
Re: Paragrapher
« Reply #17 on: June 30, 2020, 05:11:38 PM »
Thanks for the reply Sesquipedalian,

By raw text do you mean what is typed in the BBCode editor pane?
Or copy the html from Page Source?
Or both?

I might mention it does this on multiple posts, wherever an
was inserted in the BBCode.


Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sophist Member
  • *
  • Posts: 1,126
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Paragrapher
« Reply #18 on: June 30, 2020, 08:11:00 PM »
By raw text do you mean what is typed in the BBCode editor pane?

Yes. :)
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline RGMears

  • Semi-Newbie
  • *
  • Posts: 48
    • studio five
Re: Paragrapher
« Reply #19 on: July 01, 2020, 10:39:38 AM »
Here are two examples. One without images:
Code: [Select]
You can add "tags" to your posts simply by typing the word you want in the box beside [size=16pt][font=arial][b]Tags:[/b][/font][/size]
If the word is already used it will appear in a dropdown below the text box. If it's already there, select it. If your word is somehow different, keep typing.
[hr]
The [u]Tags[/u] section, accessible through the top menu (between [u]Messages[/u] and [u]Bookmarks[/u]), displays words which have been added as tags. Tapping on a "tag" displays a list of Posts so tagged.
And one with images:
Code: [Select]
Yes there are. And maybe you don't want to see them all.
You can select which boards you want to see on your Profile page.
Under Profile, select Modify Profile >
Ignore Boards Options ...
... tap on the box beside boards you [b]don't[/b] want to see.
[attachment=3,msg71]
Scroll to the bottom and tap Change profile. The top level Category will remain but the boards under it do not display.
[hr]
Conversely, you can tap the [color=magenta]title of the Category[/color] or the [color=magenta]beige icon[/color] with the "-" (minus sign) to collapse it.
[attachment=1,msg71]
[hr]
Tapping on the closed [color=magenta]title[/color] or the [color=magenta]beige icon[/color] with a "+" (plus sign) will reopen the category.
 [attachment id=2 msg=71]