Jump to content

Module: Textile Text Formatter


ryan

Recommended Posts

  • 4 weeks later...

A tiny discovery I made about the source produced by Textile Vs. TinyMCE.

I love Textile, a fan of Textpattern (and also Perch) I have loved using Textile over the WYSMAM (what you see makes awful markup) editors of old.

But the TinyMCE used in PW looks ideal, a safe alternative to Textile (that I think I will use for customer facing editing).

So I thought I'd just check the differences as far as the produced output goes:

Textile

<p>I call it luck. Remember, a Jedi can feel the Force flowing through him. Look, I can take you as far as Anchorhead. You can get a transport there to Mos Eisley or wherever you’re going. She must have hidden the plans in the escape pod. Send a detachment down to retrieve them, and see to it personally, Commander. There’ll be no one to stop us this time! Look, I ain’t in this for your revolution, and I’m not in it for you, Princess. I expect to be well paid. I’m in it for the money. What!?</p>

TinyMCE

<p>I call it luck. Remember, a Jedi can feel the Force flowing through him. Look, I can take you as far as Anchorhead. You can get a transport there to Mos Eisley or wherever you're going. She must have hidden the plans in the escape pod. Send a detachment down to retrieve them, and see to it personally, Commander. There'll be no one to stop us this time! Look, I ain't in this for your revolution, and I'm not in it for you, Princess. I expect to be well paid. I'm in it for the money. What!?</p>

Conclusion

I thought "Oo, Textile is better, it automatically converts required characters to their numeric entities.

But then I also checked if I was behind the times as regards use of entities in HTML source. If this authoritative sounding post is anything to go by, then it looks like actually the code produced by TinyMCE is preferable [edit: Thanks to wet for pointing out Textile is only entifying where it's appropriate, so now I think the output of Textile is actually 'better' than that of TinyMCE — but it may be a subtle distinction for many people probably].

Cheers, -Alan

Edited by alan
Link to comment
Share on other sites

Alan,

I assume that you're talking about these differences:

Textile

<p>...wherever you’re going...</p>

TinyMCE

<p>...wherever you're going...</p>

This difference does not occur because Textile tries to be smart about numerical entities, but about typographically correct quote characters. Textile automatically converts " and ' characters into curly quotes, which is what you see here.

TinyMCE simply uses whatever you type.

Remember, Dean Allen once was a book designer by profession - which shows.

  • Like 1
Link to comment
Share on other sites

Ah, THANKS wet for correcting me, I've immense respect for Dean and Textile and like using Textile very much.

Thanks for correcting my assumption it was 'over entify-ing' by todays standards, I'll edit my post.

Yes apeisa I totally agree that Textile and TinyMCE are so different, my bad for not making myself clearer, I was just intrigued to spot that their outputs were different.

Link to comment
Share on other sites

  • 2 weeks later...

I committed some updates to PHP textile today. Added since post #28 above were...

  • Support for HTML5 output.
  • Support for symbols as backref link characters for note lists.
  • Support for raw urlencoding of unicode characters in URLs.
  • Simpler forms of "$" style links.
  • More robust support for n-dash characters.

If I can, I'd like to add better support for Japanese-wikipedia style links (info here) and close a problem with line breaks in table cells; and that should get PHP Textile to version 2.4.

  • Like 1
Link to comment
Share on other sites

Thanks Netcarver, I didn't realize you were involved with Textile. That's good to hear. I'm a fan of Textile, and lately have really preferred it to Markdown and thinking we should add the Textile modules to PW's core modules. The only reason it wasn't in before is because I couldn't get it to work with UTF-8 text a few years ago when I initially included Textile in PW 1.0. I think I must have been working off Dean Allen's original version back then or something. I have upgraded the Textile module to the version from your repo and will track that one from now on.

  • Like 1
Link to comment
Share on other sites

Ryan,

You might want to think about adding the target doctype to the constructor call now that textile can target HTML5. Not sure how you'd want to have the user indicate their preferred output type though. Presumably, if a site is targeting HTML5 then some kind of site-wide setting, or config option would do it.

$textile = new Textile('html5');

Currently this causes textile to output <abbr> instead of <acronym> and drops the invalid align attribute on images, instead inserting classes to allow CSS to do the alignment.

  • Like 1
Link to comment
Share on other sites

  • 9 months later...
  • 1 month later...

I'm very new to Processwire and one of the first things I needed to do was install the markdown module.  The installation process is simple (see the solid documentation page here) but for those like me who are new to Processwire, once you install the module, you also need to tell fields in processwire to use markdown on the content. This is pretty simple. From the admin, go to the SetUp section and then click through to Fields->body->Details and there you'll see a dropdown menu where you can select text formatters. I, personally don't care for WYSIWYG editors once markdown is implemented, and you can additionally turn off those editors on the same page by making the body field a 'textarea' instead of 'tinyMCE' in the InputFieldType section.

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

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

Hi, Ryan!

How it's going with MarkItUp? Do you still want to resurrect it in pw2 or maybe it's already released, but I cant find it? 

Link to comment
Share on other sites

I would still like to resurrect it in PW2, but just haven't yet had the need for it in one of my projects. There are also some alternatives now we may want to look at too. But I would like to see a MarkItUp option in PW. 

Link to comment
Share on other sites

I would still like to resurrect it in PW2, but just haven't yet had the need for it in one of my projects. There are also some alternatives now we may want to look at too. But I would like to see a MarkItUp option in PW. 

Thanks for the answer. There are alternatives, but whey are white and dark, figuratively speaking (WYSIWYG editors suitable only for text and Ace requires some html knowledge). But MarkItUp is the grey thing =) I can explain to content manager how to "bold" words in it and I can build more complicated output by myself.

So I'm very glad what you don't forget about MarkItUp, will waiting for the suitable project for it %)

Cheers!

Link to comment
Share on other sites

  • 8 months later...

I'd just like to register some interest in getting markItUp! (or something similar that supports an interactive way for clients to use either textile or markdown) wrapped up as an inputfield.

Perhaps those of us interested can pitch in a few bucks to get this happening?

Link to comment
Share on other sites

  • 3 weeks later...

@all

I just pushed a waaaay overdue update to the Textile textformatters that brings in the latest version of Textile (now at 3.5.5 compared to 2.4.1 before.) If you want to see what new features Textile picked up along the way then browse the changelog.

Please be aware that this new version requires PHP 5.3.0 or higher as it uses namespaces.

This release also introduces a new formatter: TextformatterTextileField. This is a very lightweight formatter that only applies Textile's span and glyph handers to a single line input and does not wrap the result in paragraph tags - making it suitable for formatting fields for use in PW templates without having to resort to stripping paragraph tags.

  • Like 5
Link to comment
Share on other sites

Thanks for the update!

Unfortunately i got an error when installing (via modules manager):

Parse Error: syntax error, unexpected T_STRING (line 41 of /xxx/site/modules/TextformatterTextile/TextformatterTextile.module) 
Link to comment
Share on other sites

@Mats

Thanks for the report - I'll try a fresh install via the Module manager and see if I can reproduce this.

Updated to add: Worked fine for me using the PW dev branch and PHP 5.5.11. Could you paste-bin/gist the content of your TextformatterTextile.module? Sounds like it might have been corrupted.

Edited by netcarver
  • Like 1
Link to comment
Share on other sites

@Mats

No problem - I forgot I could add that PHP dependency as a requirement in the plugin info. I'll fix that.

Edited to add: Updated the module to require PHP>=5.3.0 which should stop this occurring again.

Edited by netcarver
  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

@netcarver

Using your module would be great. Unfortunately i'm not be able to install the module with the dependency message "PHP Version >= 5.3", although i am (definitely) on PHP 5.4.21. I am not sure this is strictly related to this module (i am a newbie to PW, first project), but being a bit stranded what to do.

Latest PW (2.4), freshly zip download of the Textile module.

Thx in advance!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...