Jump to content
ryan

Module: Textile Text Formatter

Recommended Posts

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Textile and TinyMCE are pretty different beasts, there is actually very little on what to compare on feature wise.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks Netcarver -- I'm thinking I'll make it implement the ConfigurableModule interface and they can specify the doctype with the module's config settings.

Share this post


Link to post
Share on other sites

Just updated these formatters for textile v2.5.1 which was released about an hour ago.

HNY!

  • Like 4

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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? 

Share this post


Link to post
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. 

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
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) 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

5.2.17.

Sorry, should have checked the version. Too many hosts to keep track of...

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@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!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...