Jump to content


Photo

Module: Textile Text Formatter

Module

  • Please log in to reply
37 replies to this topic

#1 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3108

  • LocationAtlanta, GA

Posted 16 November 2011 - 12:08 PM

Today I needed to install the latest Textile on an older site for a client, and figured I would go ahead and make a PW2 module out of it at the same time. Textile is the markdown language included with Textpattern CMS and apparently also used by Basecamp and Google+ to some extent. More information about Textile and syntax here: http://en.wikipedia....kup_language%29

Textile is very similar to Markdown (already included with PW), though now that I've spent some time with the syntax, I think I might like Textile a little more.

To Install
Download or clone from GitHub at: https://github.com/r...ormatterTextile

Place files in /site/modules/TextformatterTextile/. Go to Modules in the admin, 'Check for new modules' and click install for Textile under the Textformatter section.

You'll also see 'Textile Restricted' and that is a separate version of the module that may be used with untrusted input like user-supplied input or blog comments. The regular Textile should only be used with trusted input.

To use
Add this to any textarea (or text) field, and that field will interpret Textile codes and output XHTML markup on the front end of your site. Note that Textformatters appear on the 'Details' tab of the field editor when editing a text or textarea field. Use the regular 'Textile' unless the field in question may contain untrusted user input, in which case you should use 'Textile Restricted'.

Please note
Don't use this in combination with other text formatters like Markdown. Don't use with TinyMCE (there would be no point). This module may be used with any version of ProcessWire: 2.0, 2.1 or 2.2+.

Edited by Pete, 23 March 2012 - 03:30 PM.
Moved download to GitHub, Updated to Textile 2.3, added TextileRestricted version


#2 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,520 posts
  • 845

  • LocationVihti, Finland

Posted 16 November 2011 - 05:36 PM

Great job! I have never really used either of those (markdown or textile), but I was thinking about markdown on my discussions module. Now I have more options to choose from :)

#3 martinluff

martinluff

    Full Member

  • Members
  • PipPipPip
  • 79 posts
  • 2

  • LocationChristchurch NZ

Posted 17 November 2011 - 09:22 PM

Useful addition, not least of all just because Textile has a big following; I used Textpattern a fair bit at one point and still loosely involved in a project that runs 100+ copies of it... Wasn't sure why you'd want to use something like Textile when I first used it but warmed to it later and still use it to run a decent-sized ExpressionEngine site in which I used Textile for all the text boxes in the admin. Takes a little to bring a client up to speed but then much less likely for them to accidentally trash the site or produce HTML spaghetti than if using TinyMCE/CKEditor etc. also I think it's quite useful at times for a client to realise they're not just generating a word processing document but are creating web markup in the background; and by default Textile has some nice tweaks to text formatting like 'proper' quotes, em and en dashes etc. and, as you say, the syntax is quite good. On the other hand it is another proprietary markup language...

I think in a CMS admin it can sometimes also make more sense to clients since you're often re-using the same content in different contexts throughout a site and so 'WYSIWYG' is never really going to be a good analogy to try and fit since an individual chunk of content can look quite different in each context; in this respect I think Textpattern's more 'abstract' approach to content fields actually seems to fit well.

As an aside I noticed Textpattern seems to be enjoying a lot more activity of late and steadily moving towards their big new '5' release with a fully revised architecture after a couple of rocky years...

#4 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3108

  • LocationAtlanta, GA

Posted 18 November 2011 - 11:15 AM

Great points Martin. I think that lightweight markup languages (LML) like Textile and Markdown are in a lot of cases better with clients. The resulting markup is so much cleaner and maintains that integrity long term. And results in reduced support burden down the road. Plus, it gets the client into thinking in semantic terms rather than trying to "design" in the rich text editor. Still, everyone seems to want rich text editors these days, so I don't fight it. But if it were up to me, we'd all be using Markdown, Textile and the like. :) There is a ton of overhead that goes with TinyMCE and the like, and I'm not even talking about bandwidth and speed.

#5 MarcC

MarcC

    Sr. Member

  • Members
  • PipPipPipPip
  • 252 posts
  • 60

  • LocationCalifornia

Posted 18 November 2011 - 03:46 PM

Your implementation of TinyMCE is pretty ideal though, Ryan. Major props for that. I used to use WYSIWYG Pro and just let clients have the kitchen sink--embedded media, whatever. I found that it can result in a lot of wasted time during redesigns, so I headed toward Textile, but after trying PW's TinyMCE, I'm actually using TinyMCE as the main editor with some Textpattern sites I do. :D

I'm a freelance, processwire-using web designer based in california. work site | personal site | visuals


#6 Soma

Soma

    Hero Member

  • Moderators
  • 3,186 posts
  • 1739

  • LocationSH, Switzerland

Posted 19 November 2011 - 02:08 PM

Thanks Ryan for the module. I already was wondereing what's about these textformaters, as I didn't really get into these until now , I know they exist but will maybe give it a try. I always thought they're too complicated and not intuitive for clients to use. But maybe I'm wrong. I would love to hear experiences from others using it.

I know it can make sense regarding the issues caused by wysiwygs. But if you know your way around in one of those you can pretty much configure it to your needs and restrict all things that could make troubles, but still it can be buggy in certain situations and inconstistent in different browsers. While a simple textarea you can't go wrong except not knowing how the markup tags work or make an error there, wouldn't it be possible or make sense to have a preview or a validator?

@somartist | modules created | support me, flattr my work flattr.com


#7 MarcC

MarcC

    Sr. Member

  • Members
  • PipPipPipPip
  • 252 posts
  • 60

  • LocationCalifornia

Posted 19 November 2011 - 04:35 PM

Soma, I always make sure my Textile-using clients have a link to this nearby: http://labs.metanati...tile-reference/

I'm a freelance, processwire-using web designer based in california. work site | personal site | visuals


#8 diogo

diogo

    Hero Member

  • Moderators
  • 1,982 posts
  • 1061

  • LocationPorto, Portugal

Posted 19 November 2011 - 08:47 PM

Soma, I used markdown on a website, and the client loved it and got the hang of it very quickly.
I'm a Print Designer, and in the office I was even considering of making some kind of custom application with markup, so people could submit their tests to me instead of word or rtf documents. I tried to teach everyone to use styles in word, but people just seem to not understand the concept, and they ruin all the layout, and make it very tedious to correct everything... I agree with Martin, that it's good that editors are aware of the structure they are creating instead of relying on the visual thing.

edit 1: Maruchan, nice! I will bookmark that one :)
edit 2: For markdown there is this live preview http://softwaremania...wdown-highlight

#9 Marty Walker

Marty Walker

    Sr. Member

  • Members
  • PipPipPipPip
  • 330 posts
  • 153

  • LocationKatoomba, AU

Posted 09 December 2011 - 10:20 PM

The way Ryan has wrangled TinyMCE makes it easier to insert (and resize) images, link to other pages with your site. This is quite unintuitive with both Markdown and textile.

martkItUp!(http://markitup.jaysalvat.com/home/) might be nice to have when using textile and Markdown (especially when it comes to using custom styles), Ryan's implementation here wins me over.

#10 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3108

  • LocationAtlanta, GA

Posted 12 December 2011 - 11:34 AM

I like MarkItUp. Actually I used that in PW1 as an option in addition to TinyMCE. Would be good to bring back at some point.

#11 diogo

diogo

    Hero Member

  • Moderators
  • 1,982 posts
  • 1061

  • LocationPorto, Portugal

Posted 19 December 2011 - 12:09 AM

I'm, using the textile module on a site I'm building and there seems to be a bug when building tables.
When I do this:

| something here | something here |
| something here | something here |
| a line break
here | something here |

the line doesn't break. I looked for some reason, And apparently, people that had this problem solved it by adding a raw <br> (bah!), but even this doesn't work with me...

here everything works fine http://textile.thresholdstate.com/


#12 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3108

  • LocationAtlanta, GA

Posted 19 December 2011 - 10:50 AM

It's hard to say here. The one at thresholdstate.com is Textile 2.0 and we're using Textile 2.2 (a newer version). I don't know enough about Textile or it's code to be able to debug it very easily, so I think we should try to look at all other factors. Do you have any other text formatters applied to the field where textile is applied? Where did you read about others solving this problem with a <br>? It makes me wonder if this is some known issue with Textile. Also, can you post the full textile code that is failing? I'd like to try and duplicate it here.

#13 diogo

diogo

    Hero Member

  • Moderators
  • 1,982 posts
  • 1061

  • LocationPorto, Portugal

Posted 19 December 2011 - 11:07 AM

It's working now, even without raw tags. I redid everything and don't really know what fixed it. I will report if there is something else.

#14 diogo

diogo

    Hero Member

  • Moderators
  • 1,982 posts
  • 1061

  • LocationPorto, Portugal

Posted 19 December 2011 - 11:12 AM

Ah... of course...

This was the code that was breaking it:

$(".menu td:first-child").text(function(n){
		var content = $(this).text();
		var dots = "...";
		var both = content + dots;
    	return both;
  });

EDIT: Ok, I manage a workaround, although it will mean a bit more complexity to the editor.

| _something here_ | something here |
| _something here_ | something here |
| _a line break 
here_ | something here |

$(".menu td em").append('...');

td em { font-style:normal }


#15 MarcC

MarcC

    Sr. Member

  • Members
  • PipPipPipPip
  • 252 posts
  • 60

  • LocationCalifornia

Posted 11 January 2012 - 01:59 PM

Just saw this: New version of Textile released (v. 2.3)

I'm a freelance, processwire-using web designer based in california. work site | personal site | visuals


#16 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3108

  • LocationAtlanta, GA

Posted 12 January 2012 - 12:27 PM

Thanks Marc, I will plan to put in this update soon.

#17 diogo

diogo

    Hero Member

  • Moderators
  • 1,982 posts
  • 1061

  • LocationPorto, Portugal

Posted 31 January 2012 - 10:27 AM

Ryan, did you consider MarkitUp as an option for imputfield type when using markdown or textile formatters?

http://markitup.jaysalvat.com/

#18 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3108

  • LocationAtlanta, GA

Posted 31 January 2012 - 11:38 AM

Diogo, ProcessWire 1.x actually used MarkItUp and it's a great editor. I definitely want to get it going again in 2.x, hopefully soon unless someone beats me to it. :)

#19 keithar

keithar

    Newbie

  • Members
  • Pip
  • 3 posts
  • 0

  • LocationGdańsk, Poland

Posted 04 February 2012 - 07:38 AM

Hey, thanks for this useful module. I found small problem on PW 2.2. This code:

* _name_ *price*

gives me

<li><em>name</em> <em>price</em></li>

Is this incopability problem with the new PW?

#20 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3108

  • LocationAtlanta, GA

Posted 04 February 2012 - 09:47 AM

Keithar, that looks like the output of the Markdown module rather than the Textile module. Can you double check that you are using Textile (only) in that field and not Markdown? I just tried it here with TextformatterTextile and this is the output I got:


<ul>
<li><em>name</em> <strong>price</strong></li>
</ul>

Please let me know what you find.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users