Add list formatting component

jhodgdon - March 10, 2009 - 19:24
Project:Flexifilter
Version:6.x-1.1-rc2
Component:Code - Components
Category:feature request
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

I've created a little component module for Flexifilters that adds list formatting, similar to what you can do in Mediawiki, where you can enter things like

* item 1
* item 2

# num 1
# num 2

and it converts into UL and OL lists. See the README for more info - it handles nested lists, and has config options to control what characters correspond to lists.

I just thought I would submit it for possible inclusion in Flexifilters. It might be useful for many people, and it was something I couldn't easily figure out how to do in Flexifilters without writing it in PHP code (the conditionals and such were a bit complex, because you have to keep track of state as you go through the code).

AttachmentSize
ff_lists.zip - List filtering for Flexifilter in 6.x10.51 KB

#1

Charles Oertel - March 29, 2009 - 16:37

Hi Jennifer

Thanks for this - I couldn't get my head around how to do it using the chunk grabber and text replacement. I'm glad to see it needs to have been done the way you did.

Without this module the MediaWiki filter can hardly be called that - the instant bullets are a significant feature of this wiki format and the main reason I use it.

You should get this module into the contributions section.

kind regards
Charles

#2

jhodgdon - April 2, 2009 - 16:08

Charles -- My thought was that it could be added as part of the Flexifilters module itself. But I could see about adding it as a separate module too... right now I don't have a d.o contributer's CVS account.

Let me know how you think it would be best to proceed.
--Jennifer

#3

suit4 - April 8, 2009 - 14:56

jhodgdon -- thanks for the list filter.

I currently trying to integrate it into an extended mediawiki style filter.

It seems, that your list filter only creates the correct list, if the list is prepended with a line of text, if there is no prepended line, your filter misses the first list element.

works:

test line
* item 1
* item 2

result is:
test line
<ul>
<li>item 1</li>
<li>item 2</li>
</ul>

fails:

* item 1
* item 2

result is:
* item 1
<ul>
<li>item 2</li>
</ul>

Any idea with this problem occurs?

#4

jhodgdon - April 9, 2009 - 15:14

I am not seeing the same problem in my installation...

My guess is that some other processing is happening in your setup before the text gets to the List filter. Could be two places -- either (a) other filtering components within the Flexifilter you have set up, or (b) other processing within the Input Format you have defined that includes the Flexifilter.

You can test for (a) by trying Preview mode in the Flexifilter you have set up that includes list processing. See if it works there. If not, Preview shows you all the processing, so see if something is happening to the text before it gets to the List filter component.

You could also try setting up a Flexifilter with only one component (just my List filter), and see if it works for you there in Preview mode. If that works, but not your Mediawiki filter, then maybe try moving the List filter up higher in processing.

(b) If Preview works correctly to format the list, then probably there is processing happening before the Flexifilter gets invoked in your Input Format. Try putting the Flexifilter first.

For either (a) or (b), the issue can arise because the List processing filter I wrote is expecting plain text input, not HTML that has been for instance divided into paragraphs first. The * has to be the first character on the line, after spaces/tabs/etc, for my filter to recognize it. So if something is changing
* item 1
* item 2
into
<p>*item 1 (etc)
(before the text gets to the List filtering component), then a <p> tag will be first on the line instead of *, and the List component won't recognize it.

Let me know if this solves your problem, or at least narrows it down...

#5

jhodgdon - April 15, 2009 - 13:45

Could one of the maintainers of this module please weigh in on whether you plan to add this to Flexifilters, or if you'd prefer that it be a separately-distributed module?

I would prefer the former, especially since I don't have a CVS account (yet) and can't contribute it as a separate module at this time.

I would assign it to the maintainers, but I don't appear to have permission to do so.

Thanks!

#6

EgonO - April 16, 2009 - 22:09

great! nead this too. hope it is in the next version.

#7

jhodgdon - April 17, 2009 - 19:58

Egon0: In the meantime, you can just grab the zip file above and use it as a separate module.

#8

suit4 - April 20, 2009 - 09:19

jhodgdon, you are right. It's the line break converter, which should better be processed after the list converter, if necessary.

#9

jhodgdon - April 24, 2009 - 15:11
Category:feature request» bug report

I'm changing this temporarily to a bug report to see if it will catch the attention of the module maintainers better that way.

I'd really like to know whether you plan to add this to the Flexifilters distribution, or whether you'd prefer me to release it as a separate module. I now have a contrib CVS account, so I can do it either way, but I think it's better as part of Flexifilters. Thanks for your attention!

#10

dhigby - May 13, 2009 - 22:24

Thanks so much, this is exactly what I was looking for!!!!

#11

dhigby - May 13, 2009 - 22:36

Installation instructions:
1. Unzip the zip file to your modules directory.
2. Activate the module
3. Go to Home | Administer | Site Building | Flexifilters
4. Edit the Mediawiki or other filter you have created
5. Under Chunk Grabber -> Components
6. Add componant: Text Intermediate -> List Formatting
7. Configure the componant as you like.

#12

jhodgdon - June 29, 2009 - 23:40
Status:needs review» reviewed & tested by the community

Is it possible to get a decision from the Flexifilters maintainers on whether or not they intend to add this to Flexifilters? Thanks!

#13

kiamlaluno - July 1, 2009 - 03:59
Category:bug report» feature request

Changing the category didn't catch the attention of the maintainer.
It's not a good idea to change the category of a report just to catch the attention of the maintainer; there are other people who read the issue queue, and who could be checking the module bugs before to adopt the module.

#14

jhodgdon - July 1, 2009 - 15:11

Sorry! You are correct.

#15

pvarney - August 10, 2009 - 22:43

How hard would it be to modify this to support multi level lists? It would be nice to have infinitive levels however a minimum of 3 levels would be very nice.

A side note when you have ** in the file it prevents any of the filtering from being done at all

#16

jhodgdon - August 11, 2009 - 14:28

This already does support multiple levels of lists embedded within lists. Check the README file for an example.

If ** is preventing filtering, that is coming from some other step, not the list filterer module submitted above.

#17

pvarney - August 11, 2009 - 16:13

I actually had it as the top filter and still had ** result in problems

In the end Ive decided to rewrite the function.

#18

jhodgdon - August 11, 2009 - 18:12

Can you post your entire list text, and I will check into the issue?

#19

pvarney - August 11, 2009 - 22:15

sorry your code works right i just didnt understand how you implimented it.

mediawiki uses the following for levels of bullets
*Item1
**Item1-1
***Item1-1-1
**Item1-2
**Item1-3
*Item2

i am having an issue with mine that implements it the mediawiki way. i cant seem to figure out how to get it into the list. I tested my code directly in flexifilter however to make upgrades easier i want it to be separate.

was there something special that needs to be done? maybe something with the name of functions?

#20

jhodgdon - August 12, 2009 - 01:03

Without seeing your code, it is difficult to answer your question... My module is definitely tied into the Flexifilter API, so if you followed that structure, you will be too. If you want your module to tie directly into the core Drupal Input Filters API, you'll have to learn about that API. Good luck!

Check http://api.drupal.org/api/function/hook_filter/6

#21

pvarney - August 12, 2009 - 05:42

attached is what i have so far. it only does bullets right now but it covers what i need for function at the moment.

Im almost positive my issue is my lack of understanding how the hooks actually work

if you wouldnt mind taking a quick peek that would be awesome

AttachmentSize
flexifilter_BulletList.zip 10.22 KB

#22

jhodgdon - August 12, 2009 - 13:42

If your file is called flexifilter_BulletList.module, then all of your functions (or at least the ones implementing hooks) need to be called flexifilter_BulletList_whatever() in order to be recognized by Drupal or Flexifilter. Your functions are named mediawiki_bulletlist_whatever(), which is why they would not be recognized. So as a first step, try renaming your file mediawiki_bulletlist.module (same for the .info) and that should help.

#23

pvarney - August 12, 2009 - 14:31

Thank you for pointing me in the right direction!!! Ive never actually made a drupal module before as this was the first time i couldnt find exactly what i wanted.

Having so much meaning in a function name is a first for me. Thank you for your help.

 
 

Drupal is a registered trademark of Dries Buytaert.