Problem with special characters using Textile

Adrian Cooke's Avatar

Adrian Cooke

14 Jul, 2012 01:21 AM

Special characters typed directly into the source (e.g. ’ — a right single quote) are getting mangled when using Textile. Not sure if this is a problem with the Perl module or something that can be configured in Marked? I can’t figure it out based on the Text::Textile documentation, though it seems it should be able to support UTF-8. I don’t notice this problem when testing in Markdown. Would appreciate any pointers.

  1. Support Staff 1 Posted by Brett on 14 Jul, 2012 02:57 AM

    Brett's Avatar

    When using a custom processor, Marked displays the rendered HTML output as it's returned by the processor. I'm guessing the perl module is causing the issue, but I could be wrong. If you `cat` a Textile file directly to your script, does the output on the command line still contain the error?

  2. 2 Posted by Adrian Cooke on 14 Jul, 2012 05:18 AM

    Adrian Cooke's Avatar

    Ah, yes, it still has the error.
    `less ex_textile.txt` shows:
      Here’s a list:
    while `textile ex_textile.txt` or `cat ex_textile.txt | textile` shows:
      <p>Here&acirc;&#128;&#153;s a list:</p>
    Text::Textile documentation describes a method that can be used to set UTF-8:
      charset( [$charset] )
    But unfortunately I don’t have the knowledge to know how to use this and haven’t been able to find any examples.

  3. Support Staff 3 Posted by Brett on 14 Jul, 2012 05:50 AM

    Brett's Avatar

    First, just try putting at the top of the perl script:

    use utf8;

    If that doesn't make a difference can you send some sample text in a Textile file and a copy of the script your running for the custom prcessor?

    Thanks,
    Brett

  4. 4 Posted by Adrian Cooke on 14 Jul, 2012 06:17 AM

    Adrian Cooke's Avatar

    Thanks, I tried adding the line but it didn’t make a difference. The files are attached. I’m using https://github.com/bradchoate/text-textile. Marked is looking at /usr/local/bin/textile. The Perl module is at /Library/Perl/5.12/Text/.
    Adrian

  5. Support Staff 5 Posted by Brett on 14 Jul, 2012 07:01 AM

    Brett's Avatar

    Interesting that it doesn't do this already, but I modified the textile script to use the Encode::decode_utf8 function. You can see the include statement on line 10 and the modified output line on 49, if you're interested. Otherwise, just replace /usr/local/bin/textile with the attached one and you should be good to go.

  6. 6 Posted by Adrian Cooke on 14 Jul, 2012 07:45 AM

    Adrian Cooke's Avatar

    That did it :) Yes, seeing what you did was very helpful. Thanks Brett. Much appreciated.
    Adrian

  7. Brett closed this discussion on 14 Jul, 2012 09:17 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac