Giter Site home page Giter Site logo

text-textile's People

Contributors

amirkarger avatar bradchoate avatar domm avatar marcusramberg avatar petdance avatar serap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

text-textile's Issues

Blockcode (bc.) does not autoescape HTML properly

While using bc.. some <,> and " are not escaped properly.

See the testcode:

#!/usr/bin/perl

use strict;
use warnings;

use Text::Textile;

my $textile = Text::Textile->new;

my $code = <<'CODE';
bc.. <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="de" xml:lang="de">
<script src="/test/test.js" type="text/javascript"></script>
<head>
<title>Test</title>

bc. <?xml version="1.0" encoding="UTF-8"?>

bc. <script src="/test/test.js" type="text/javascript"></script>

CODE
print $textile->process($code);

__END__

Code generates this HTML

<pre><code><?xml version="1.0" encoding="UTF-8"?>
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; dir=&quot;ltr&quot; lang=&quot;de&quot; xml:lang=&quot;de&quot;&gt;
<script src="/test/test.js" type="text/javascript"></script>
&lt;head&gt;
&lt;title&gt;Test&lt;/title&gt;</code></pre>

<pre><code><?xml version="1.0" encoding="UTF-8"?></code></pre>

<pre><code><script src="/test/test.js" type="text/javascript"></script></code></pre>

Documentation in http://search.cpan.org/~bchoate/Text-Textile-2.12/lib/Text/Textile.pm#SYNTAX says:

bc
A "bc" signature is short for "block code", which implies a preformatted section like the "pre" block,
but it also gets a <code> tag (or for XHTML 2, a <blockcode> tag is used instead).
Note that within a "bc" block, < and > are translated into HTML entities automatically.

As you can see, the <, > and " char in <script>, </script>, <? and ?> are not HTML-escaped!

Seems to be a bug.

What's the license

2.13 release states in lib/Text/Textile.pm:

Copyright 2005-2009 Brad Choate, [email protected].

This program is free software; you can redistribute it and/or modify
it under the terms of either:

=over 4

=item * the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
version, or

=item * the Artistic License version 2.0.

=back

While the ARTISTIC file delivers Artistic 1.0 license text.

Which of these two declarations are true? If the former, please remove the ARTISTIC file and supply the GPL and Artistic 2.0 texts.

No formatting with == not working correctly

Example:

use Text::Textile;
print Text::Textile->new->process("foo==*test*==bar"), "\n";

The output is

<p>foo==*test*==bar</p>

but the output should be

<p>foo*test*bar</p>

Rowspan greater than 2 does not render to table

|/3. !/img/carver.jpeg(the image)! | r1 c2 |
| *r2 c2* |
| *r3 c2* |

Is producing html:

<p>|/3. <img src="/img/carver.jpeg" alt="the image" /> | r1 c2 |<br />
| <strong>r2 c2</strong> |<br />
| <strong>r3 c2</strong> |</p>

while:

|/2. !/img/carver.jpeg(the image)! | r1 c2 |
| *r2 c2* |

is producing

<table><tr>
 <td rowspan="2"><img src="/img/carver.jpeg" alt="the image" /></td>
 <td>r1 c2</td></tr><tr><td><strong>r2 c2</strong></td>
</tr></table>

local href

how to create local links?

$ echo 'text from "local link":here really' | textile 
<p>text from <a href="http://here">local link</a> really</p>

Is it possibile avoid the prefixed "http://" by default?

Disabling CSS names does not affect handling of "caps" spans

As pointed out to me by Eric Meyer, if you use:

$textile->css(0);

this will not actually prevent Textile from wrapping <span class="caps"> around uppercase text. Since there is no obvious inline style to apply as an alternative, disabling CSS class names should simply prevent these spans from being created altogether.

[PATCH] fix spelling error in manpage

Hi,

In Debian we are currently applying the following patch to Text-Textile.
We thought you might be interested in it too.

The patch is located at http://anonscm.debian.org/gitweb/?p=pkg-perl/packages/libtext-textile-perl.git;a=blob;f=debian/patches/fix-spelling-error-in-manpage.patch;hb=HEAD

Fix spelling errors in manpage
Origin: vendor
Author: Salvatore Bonaccorso <[email protected]>
Last-Update: 2014-07-27

Thanks in advance,
Salvatore Bonaccorso, Debian Perl Group

Using filters consecutively don't work

If I use filters consecutively,then only the first filter is processed. All other filters are treated as tables-
See this example:

use Text::Textile;

my $textile = new Text::Textile;

# define a hash of filters,
# here we just have one
$textile->filters(
    {
    test => sub {
          my ( $text, $param ) = (@_);
            # $text contains the string between the last
            # '|' and the '==', here I expect a number
            $text =~ s/(\d+)/http::\/\/localhost\/item\/view\/$1/;
           return $text;
           },
    video => sub {
            my ( $text, $r_param_list ) = (@_);
            # $text contains the string between the last
            # '|' and the '==', here I expect a number
            $text =~ s/(.*)###(.*)/\<video src\=\"$1\">$2<\/video\>/;
            return $text;
            },
    
    }
);


# Set the base URL as parameter (localhost for test)
$textile->filter_param( [ $base_url ] );

# generate the result
while ( my $line = <DATA>) { $lines = $lines.$line;}
#chomp @lines;
$dest = $textile->process($lines);

# $dest is the result
print "ERGEBNIS $dest\n";

__DATA__
==|video|/home/maximilian/video.mp2###Video ansehen==

==|video|/home/maximilian/video.mp2###Video ansehen==

==|item|12==

CPAN Pull Request Challenge

Hi Brad,

I've been assigned your module for the CPAN pull request challenge. Are there any bits or pieces that you'd like me to focus on?

background: I've been coding in perl for 10+ years on a daily basis, so I'm experienced there, but I haven't used Textile (though I've of course various flavors of Markdown, etc).

thanks,
John

Use of uninitialized value $1 in string eq at /usr/share/perl5/Text/Textile.pm line 89

Similar problem to that noted by domm resulting in much noise printed to stderr.

--- /usr/share/perl5/Text/Textile.pm.orig 2009-08-08 19:20:45.000000000 +0100
+++ /usr/share/perl5/Text/Textile.pm 2011-07-29 14:21:57.000000000 +0100
@@ -86,7 +86,7 @@
my $flavor = shift;
$self->{flavor} = $flavor;
if ($flavor =~ m/^xhtml(\d)?(\D|$)/) {

  •        if ($1 eq '2') {
    
  •        if (defined $1 && $1 eq '2') {
             $self->{_line_open} = '<l>';
             $self->{_line_close} = '</l>';
             $self->{_blockcode_open} = '<blockcode>';
    

"Use of uninitialized value" warning for images

perl -e 'use Text::Textile qw(textile); print textile("!/path/to/image!")'
Use of uninitialized value $w in string eq at /usr/share/perl5/Text/Textile.pm line 1557.
Use of uninitialized value $h in string eq at /usr/share/perl5/Text/Textile.pm line 1558.

Nothing more to say.

sorry - wrong regex - created pull request with new & better solution (Do not allow spaces directly after '!' in image processing)

sub format_inline {
...

# images must be processed before encoding the text since they might
# have the <, > alignment specifiers...

my $pattern = '(?<=[^!])\s*';
# !blah (alt)! -> image
$text =~ s!(?:^|(?<=[\s>])|([{[]))     # $1: open brace/bracket
           \!                          # opening
           ($imgalignre?)              # $2: optional alignment
           ($clstypadre*)              # $3: optional CSS class/id
           ($imgalignre?)              # $4: optional alignment
           ($pattern)                     # space between alignment/css stuff
           ([^\s\(\!]+)                # $5: filename
           (\s*[^\(\!]*(?:\([^\)]+\))?[^\!]*) # $6: extras (alt text)
           \!                          # closing
           (?::(\d+|$urlre))?          # $7: optional URL
           (?:$|([\]}])|(?=$punct{1,2}|\s))# $8: closing brace/bracket
          !_repl(\@repl, $self->format_image(pre => $1, src => $5, align => $2||$4, extra => $6, url => $7, clsty => $3, post => $8))!gemx;

...
}

Bug: colspan is added if an column is empty

This is a bug:

use Text::Textile;
my $text = '
| a | a | a |
| b |   | b |
| c | c | c |
| d |   | d |
';
print Text::Textile->new->process($text), "\n";

Output:

<table><tr><td>a</td><td>a</td><td>a</td></tr><tr><td colspan="2">b</td><td>b</td></tr><tr><td>c</td><td>c</td><td>c</td></tr><tr><td colspan="2">d</td><td>d</td></tr></table>

colspan should not be added there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.