Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Sesquipedalian on February 27, 2016, 05:59:09 PM

Title: Paragrapher
Post by: Sesquipedalian on February 27, 2016, 05:59:09 PM
Link to the mod (https://custom.simplemachines.org/index.php?mod=4074)

Paragrapher

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


Features


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:



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:
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:
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:
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.6:

Version 2.5:

Version 2.4:

Version 2.3:

Version 2.2:

Version 2.1:

Version 2.0:

Version 1.1:

Version 1.0.1:

Version 1.0:
Title: Re: Paragrapher
Post by: pocttopus on March 24, 2019, 07:10:46 AM
Could you please send a screenshot of how this mod is working?
Thanks.
Title: Re: Paragrapher
Post by: woolly bugger 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!
Title: Re: Paragrapher
Post by: Sesquipedalian on March 25, 2019, 07:37:11 AM
Quote from: pocttopus on March 24, 2019, 07:10:46 AM
Could you please send a screenshot of how this mod is working?
Thanks.

Done.

Quote from: woolly bugger 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!

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. :)
Title: Re: Paragrapher
Post by: -Rock Lee- 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.

<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!
Title: Re: Paragrapher
Post by: Arantor on March 25, 2019, 06:40:54 PM
Like it. Not for all forums, but like the idea.
Title: Re: Paragrapher
Post by: Sesquipedalian on March 25, 2019, 08:10:22 PM
Quote from: Rock Lee 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.

<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! :)

Quote from: Arantor on March 25, 2019, 06:40:54 PM
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.
Title: Re: Paragrapher
Post by: Biology Forums 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?
Title: Re: Paragrapher
Post by: Sesquipedalian on March 26, 2019, 01:37:08 AM
Quote from: Study Force 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?

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.
Title: Re: Paragrapher
Post by: -Rock Lee- on March 26, 2019, 09:07:27 AM
Quote from: Sesquipedalian on March 25, 2019, 08:10:22 PM
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!
Title: Re: Paragrapher
Post by: njtweb 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?
Title: Re: Paragrapher
Post by: Arantor 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.
Title: Re: Paragrapher
Post by: njtweb 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.
Title: Re: Paragrapher
Post by: Sesquipedalian on March 26, 2019, 06:52:17 PM
Quote from: Arantor 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.

That, and for people like me who care about having consistently formatted content and semantically correct HTML on their sites. :)
Title: Re: Paragrapher
Post by: Sesquipedalian on March 26, 2019, 06:58:47 PM
Quote from: Rock Lee on March 26, 2019, 09:07:27 AM
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. :)
Title: Re: Paragrapher
Post by: RGMears 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.
Title: Re: Paragrapher
Post by: Sesquipedalian 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 (https://www.simplemachines.org/community/index.php?action=pm;sa=send;u=394956).
Title: Re: Paragrapher
Post by: RGMears 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.

Title: Re: Paragrapher
Post by: Sesquipedalian on June 30, 2020, 08:11:00 PM
Quote from: RGMears on June 30, 2020, 05:11:38 PM
By raw text do you mean what is typed in the BBCode editor pane?

Yes. :)
Title: Re: Paragrapher
Post by: RGMears on July 01, 2020, 10:39:38 AM
Here are two examples. One without images:
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:
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]
Title: Re: Paragrapher
Post by: Sesquipedalian on July 05, 2020, 11:33:15 PM
Thanks, RGMears. Very helpful. I believe this bug has been fixed in Paragrapher 2.2. Please give it a try and let me know if it solves the problem on your forum, too.
Title: Re: Paragrapher
Post by: RGMears on July 06, 2020, 12:06:08 PM
Thanks for the update Sesquipedalian.
I have to first uninstall the older version and get five error messages. I can, of course, modify the required files. But, is there a bit of code I can copy and paste where it's needed?
Title: Re: Paragrapher
Post by: RGMears on July 07, 2020, 10:35:01 AM
Thanks Sesquipedalian,

The new version works!
Title: Re: Paragrapher
Post by: Shades. on July 09, 2021, 08:39:31 AM
While using my search on smf 2.0.18 I'm getting the following error:

Quotehxxx://xxxx.com/index.php?action=search2
8: Undefined index: body
File: /home/xxxxx/public_html/xxxxx/Sources/Paragrapher.php
Line: 278

#0 /Sources/Paragrapher.php(48): paragrapher_process_post(array, string)
#1 /Sources/Subs.php(4539): paragrapher_prepare_message_context(array, array, integer)
#2 /Sources/Search.php(2094): call_integration_hook(string, array)
#3 /Themes/default/Search.template.php(442): prepareSearchContext()
#4 /Sources/Load.php(2135): template_results()
#5 /Sources/Subs.php(2984): loadSubTemplate(string)
#6 /index.php(193): obExit(NULL, boolean, boolean)
#7 {main}
Title: Re: Paragrapher
Post by: Sesquipedalian on July 09, 2021, 01:31:15 PM
Thanks for this bug report. I will look into it ASAP.
Title: Re: Paragrapher
Post by: Sesquipedalian on July 11, 2021, 03:57:27 PM
I've just uploaded Paragrapher 2.4 to fix that bug, Shades. Thanks again for the report!
Title: Re: Paragrapher
Post by: Shades. on December 21, 2021, 07:19:24 PM
Was having problems with Code Select (https://www.simplemachines.org/community/index.php?topic=579975.msg4105277#msg4105277) not working in topic view and I think it was because of this mod. Just letting you know! ;)

Also when uninstalling I got this error in Admin:
QuoteError
Type of error
General
Error message
The file "paragrapher.css" could not be located on the current or the default theme and, therefore, it was not included in the minified file.
URL of page causing the error
https://*****.com/index.php?action=admin;area=packages;sa=uninstall2;package=1633677502.tar.gz;pid=462

Backtrace information
#0: custMinify()
Called from /home2/*****/public_html/*****/Sources/Subs.php on line 4265
#1: template_css()
Called from /home2/*****/public_html/*****/Themes/default/index.template.php on line 119
#2: template_html_above()
Called from /home2/*****/public_html/*****/Sources/Load.php on line 2735
#3: loadSubTemplate()
Called from /home2/*****/public_html/*****/Sources/Subs.php on line 3948
#4: template_header()
Called from /home2/*****/public_html/*****/Sources/Subs.php on line 3535
#5: obExit()
Called from /home2/*****/public_html/*****/index.php on line 190