Wincent Colaiuta [Thu, 29 Nov 2012 07:50:56 +0000 (23:50 -0800)]
Simplify Wikitext_parser_sanitize_link_target
Commit 778839e made the wiki_append_sanitized_link_target function more
flexible by making it accept a str_t instead of a parser_t. This in turn
means that we can simplify the Wikitext_parser_sanitize_link_target
function; it can deal with a str_t directly rather than working with a
throwaway parser_t.
Wincent Colaiuta [Thu, 29 Nov 2012 07:46:30 +0000 (23:46 -0800)]
Teach wiki_append_sanitized_link_target to take a str_t
Rather than passing in a parser_t and assuming the text we want to
operate on is the one in the struct, pass in the link target str_t
explicitly. This added flexibility will make the
wiki_append_sanitized_link_target function suitable for wider use, which
I am presently going to do in order to fix a bug.
Wincent Colaiuta [Sun, 4 Mar 2012 00:25:21 +0000 (16:25 -0800)]
Allow email addresses inside external link text
Previously we allowed:
[mailto:user@example.com text]
but dealt poorly with:
[mailto:user@example.com user@example.com]
While that might seem like a contrived example (because you could
dispense with the explicit external link entirely and instead rely on
the standard auto-linkification) it also meant that we couldn't handle
perfectly reasonable and useful input like:
[mailto:user@example.com contact me at user@example.com for info]
Note the problem wasn't just limited to URIs with the "mailto:" schema;
we also choked on stuff like:
[http://google.com/?q=user@example.com Google for user@example.com]
Wincent Colaiuta [Sat, 28 May 2011 07:24:20 +0000 (00:24 -0700)]
Bump version number for 3.0b release
Bumpig the major version number here because this is a
compatibility-breaking release (supporting only Rails 3.1.0 and above).
As Rails 3.1.0 isn't finalized yet, marking this one as a beta, as other
tweaks may be required by the time Rails 3.1.0 goes final.
Wincent Colaiuta [Sat, 28 May 2011 07:12:29 +0000 (00:12 -0700)]
Rename spec/trash -> spec/.trash
This has a number of benefits:
- things which search (like Command-T and ack) won't waste time
looking at the enormous quantity of stuff that accumulates in the
trash dir
- RSpec won't try to run stuff buried deep down inside the trash dir,
almost certainly breaking
Wincent Colaiuta [Sat, 28 May 2011 06:07:12 +0000 (23:07 -0700)]
Drop support for Rails 3.0.x
In the interests of moving forward, older versions of Rails will
continue to be supported with the last Wikitext release (2.1.1, 2.1.x),
but the current version will only support Rails 3.1.0 and above.
Wincent Colaiuta [Sat, 28 May 2011 05:48:26 +0000 (22:48 -0700)]
Avoid another Rails 3.1 deprecation warning
Specifically:
DEPRECATION WARNING: Including Compilable in your template handler is
deprecated. Since Rails 3, all the API your template handler needs to
implement is to respond to #call.
Wincent Colaiuta [Sat, 28 May 2011 05:45:03 +0000 (22:45 -0700)]
Avoid a Rails 3.1 deprecation warning
Specifically:
DEPRECATION WARNING: Inheriting from ActionView::Template::Handler is
deprecated. Since Rails 3, all the API your template handler needs to
implement is to respond to #call.
Wincent Colaiuta [Sun, 15 May 2011 23:36:40 +0000 (16:36 -0700)]
Manage Arel version as well when setting up Rails test apps
This gets the spec suite passing in a hopefully robust and independent,
"bundlerized" way, for Rails version 3.0.1 through 3.0.7. It even works
on the current "Edge" Rails.
Wincent Colaiuta [Sun, 15 May 2011 19:53:02 +0000 (12:53 -0700)]
More attempts at getting Bundlerized test Rails app working
Trying with the latest Bundler (1.0.13) and RubyGems (1.8.2) I see the
test environment also winds up with GEM_PATH and GEM_HOME set, so be a
little more careful about how we clean the environment (note that before
we were going too far, cleaning the entire environment). We now clean
any environment variables starting with GEM_ or BUNDLE_.
Wincent Colaiuta [Sun, 15 May 2011 04:15:22 +0000 (21:15 -0700)]
Don't test against Rails 2 versions
Testing against so many versions of Rails is proving to be a
maintenance nightmare, so we're going to change tack: I'll continue to
support the current 2.x series of the Wikitext gem, and it will work
perfectly with Rails 2.x.
I'll also be supporting a new 3.x series of the gem, which will support
only Rails 3.x. It is relatively easy to support multiple versions of
the gem, each tailored for a particular version of Rails, compared with
trying to get a single version fo the gem to support all versions (see
the hoops that Haml jumps through to do this).
Additionally, testing against so many versions is complicated even more
when Bundler is added to the equation. From here on I'll be
concentrating on making the Rails specs Bundler-aware, but evidently
only in the 3.x branch, and only against Rails 3.x.
Wincent Colaiuta [Sun, 15 May 2011 04:08:45 +0000 (21:08 -0700)]
Update version numbers for Rails specs
Reformat for readability, add a couple of missing versions to the list,
and remove versions which we no longer test against.
We only test released versions, and it appears that some versions have
(eg. 2.3.2.1, 2.3.3.1) have been pulled from the gem servers (or at
least they no longer show up in the output of "gem list --remote --all
rails").
Wincent Colaiuta [Fri, 5 Nov 2010 23:51:12 +0000 (00:51 +0100)]
Don't drop unexpected token on the floor after failed external link
This specifically arises after an EXT_LINK_START + PATH sequence. At
this point we expect a SPACE token, but if we don't get it, we were just
dropping it on the floor, which is bad.
Wincent Colaiuta [Sun, 17 Oct 2010 17:47:53 +0000 (19:47 +0200)]
Remove BASEDIR constant from spec_helper
We can rely on Ruby itself to guard against double-evaluating the
spec_helper file seeing as we always require it as "spec_helper" and
rely on the load path being set up in order to find it.
Wincent Colaiuta [Sun, 17 Oct 2010 17:46:38 +0000 (19:46 +0200)]
Remove explicit rubygems require from spec_helper
As we should always be run via Bundler (specifically, bin/rspec) there
is no need to ever require rubygems explicitly as it will already have
been loaded and the load path set up by Bundler.
Wincent Colaiuta [Sun, 17 Oct 2010 17:42:59 +0000 (19:42 +0200)]
Don't use absolute path when requiring spec_helper.rb
RSpec 2.0 adds the spec directory to the load path, so it is no longer
necessary to specify an absolute path in order to ensure that the helper
only gets evaluated once.
Wincent Colaiuta [Sun, 17 Oct 2010 15:41:32 +0000 (17:41 +0200)]
Use Bundler to manage development environment
Note that this actually breaks many (all?) of the specs which run
in the scratch Rails environments set up to test the extension against
different versions of Rails.
This is because Bundler tries to apply the same restrictions to those
sub-environments as apply to the parent environment, so more changes
will be needed to adapt those Rails tests to work in a Bundler-dominated
world.
Wincent Colaiuta [Wed, 23 Jun 2010 16:12:20 +0000 (18:12 +0200)]
Format all "pre" blocks for YARD
This means marking all non-Ruby "pre" blocks using a "!!!wikitext" or
"!!!html" marker.
At the moment there is no syntax highlighting for wikitext or HTML, so
those tags are effectively equivalent to "!!!plain", but the important
thing is that we stop YARD from inappropriately applying Ruby syntax
highlighting rules to non-ruby code, and if syntax highlighting for the
other languages is ever added, we will be ready for it.
Wincent Colaiuta [Wed, 23 Jun 2010 15:34:47 +0000 (17:34 +0200)]
Bump YARD requirement to 0.5.8
From the official announcement:
Yesterday I released YARD 0.5.7. Unfortunately a few important bug fixes
were omitted from the release because they were lost in the 0.6-master
branch and I did not merge them back. That was a total screwup on my
part. Hopefully this doesn't happen again (some extra specs were added
to make sure this issue stays fixed).
Wincent Colaiuta [Sun, 13 Jun 2010 17:37:24 +0000 (19:37 +0200)]
DRY up gemspec
Rather than repeating the gem names (4 of them), repeat the
"respond_to?" check (1 check) each time through the loop.
Speed not an issue, here, so just run the check every time
through the loop rather than sacrificing readability by
cluttering things up with a local variable.
Wincent Colaiuta [Sun, 13 Jun 2010 09:29:15 +0000 (11:29 +0200)]
Backend support for HTML5/XML output styles
HTML5 has two output syntaxes, HTML and XML. Under HTML5 the HTML output
syntax is likely to be predominant, given that the XML syntax can only
be used if it is served with an appropriate MIME type (ie.
application/xml), and the vast majority of deployed web servers are
configured to use a text/html MIME type.
So, this dictates that for our 2.0 release we are going to default to
emitting HTML syntax, but allow the user to override the default and
emit XML syntax if required.
In practice, the only place in the code base where this necessitates a
change is the part where we emit "img" tags. In the XML syntax, these
tags should be self-closing; ie:
<img src="foo.png" alt="Foo!" />
Whereas in the HTML syntax they should not (even if all user agents
accept them anyway); ie:
Wincent Colaiuta [Sat, 12 Jun 2010 23:01:35 +0000 (01:01 +0200)]
Run specs under Rails 3.0.0.beta4
Note how that when targetting Rails 3 release versions, we can't use the
version number as the app name as we did with Rails 2.
This is because Rails 3 tries to turn the name into a constant, and
constants can't start with a number. To work around this we take such
version numbers and prepend them with a "v" to create a test app name;
this in turn can be "constantized" into "V300Beta4" or similar.
Wincent Colaiuta [Sat, 12 Jun 2010 20:37:22 +0000 (22:37 +0200)]
Start refactoring Rails specs
The "Edge" Rails specs have been broken for a long time as we really
need a separate code path for these (too many changes in the underlying
machinery).
Lay the groundwork by renaming the existing working infrastructure as
a "rails2".
Early on in the application boot process. In our case, that effectively
means that the code in the C extension's Init_wikitext() function will
be evaluated.
So, in this commit, we replicate in C what we would have done in the
following manner if the Wikitext gem were just a pure Ruby project:
if Object.const_defined? :ActiveSupport
# we are running under Rails
require 'wikitext/nil_class'
require 'wikitext/string'
if ActiveSupport.respond_to? :on_load
# running under Rails 3
ActiveSupport.on_load :action_view do
require 'wikitext/rails_template_handler'
end
else
# running under Rails 2
require 'wikitext/rails_template_handler'
end
Note that because one of the code paths involves passing in a block, we
have to define a couple of ancilliary helper functions and use
rb_iterate() to achieve the same effect in C.
Wincent Colaiuta [Sat, 12 Jun 2010 16:08:10 +0000 (18:08 +0200)]
Split String#wikitext_preprocess into a separate file
This has always been a bit of a wart, the fact that what is essentially
an application-specific preprocessing pass was included in our
"wikitext/strings" file.
Now, if you want the behavior you have to explicitly require
'wikitext/preprocess'.
As a side effect of this change, the file now serves as a nice example
of how to implement a custom preprocessing phase if you need it.
Wincent Colaiuta [Fri, 11 Jun 2010 16:33:55 +0000 (18:33 +0200)]
Emit <code> rather than <tt> elements
The <tt> element has been dropped from HTML5 and the recommendation is
to instead use more "semantic" elements such as <code>, <samp> and
<kbd>. As one of the major goals for the 2.0 release is to emit valid
HTML5, the <tt> element has to go.
Given that we are working with wikitext markup and the focus is on
simplicity, we won't be adding new syntax to enable the user to control
which of the three "semantic" tag alternatives is emitted.
Instead, we maintain the existing input markup options (that is,
backticks and <tt> elements will continue to be recognized) to maintain
compatibility with existing bodies of wikitext markup, and we choose
one of the three possible elements as a replacement for <tt>.
In the end, we're going with <code> because it seems to be the most
frequently used in the terrain where the wikitext module is used (online
wikis). A customization option to override this choice could be added in
the future, but I honestly don't expect there to be any demand for it.
Likewise, explicit support for <samp> and <kbd> tags could be added, but
I doubt there'll ever be a call for it, as the whole point of working in
wikitext markup is to have an easy-to-use format and not have to write
HTML tags.
Wincent Colaiuta [Thu, 10 Jun 2010 18:41:05 +0000 (20:41 +0200)]
Run Rails specs against many more versions of Rails 2
Previously we only ran against Rails 2.2.2 (the latest release at the
time the specs were written) and Rails "Edge".
In this commit we extend that to run against all versions of Rails 2
put out since the release of 2.2.2. The only exception to this is
version 2.3.0, which is marked as pending because it throws a Rack
exception. I am not sure if the version of Rack bundled with 2.3.0 has
some kind of bug, or this is an interaction with the versions of Rack
that are on my system (1.0.1 and 1.1.0) and might be getting
inadvertently pulled into the tests.
Note that we don't bother running the specs against versions of Rails
older than 2.2.2, because that came out in November 2008, and there is
not much sense in retroactively extending compatibility even further
backwards in time.
Wincent Colaiuta [Wed, 9 Jun 2010 21:33:32 +0000 (23:33 +0200)]
Move to Rails 3 template UI
It seems that under Rails 3 the old "self.call" method no longer works
in the same fashion. Previously returning the string "template.source.w"
worked because Rails, evidently, ended up eval'ing it in a context where
"template" resolved to the desired object.
In Rails 3, however, this is no longer the case, and it ends up trying
to call a "template" method on the controller, failing.
Googling for different template handlers shows that some use "render"
(for example, liquid) but I am unable to get any variant of "render" to
work under Rails 3.
On the other hand, the three handlers included with Rails itself (ERB,
Builder, and RJS) all use the "compile" method, as does Haml.
It's hard to tell from the scant in-code documentation, but it looks
like "compile" might be "the" supported way to write template handlers
for now. The only reference I can find to this online is this thread
from back in 2008:
http://www.ruby-forum.com/topic/159810
In which Josh Peek says:
I'd really like deprecate the TemplateHandler#render all together. If
you think your handler can not be compiled, you always just compile in
a delegate call to your "noncompilable" handler. This leaves us with
only one method, compile.
So I am not sure if this is the "official" stance on the API, but in
light of the fact that I can't get anything else to work, I am going to
go with "compile" for now.
This unfortunately requires a somewhat ugly gsub call in order to escape
any single quotes that might be in the input, but it seems a necessary
evil. For example, a template with this wikitext markup:
* don't you like this list?
Will be "compiled" to:
'<ul>
<li>don\'t you like this list?<li>
</ul>
'
Which when evaluated and emitted to the output steam becomes:
<ul>
<li>don't you like this list?</li>
</ul>
Note that this commit makes things work with Rails 3 only, breaking
Rails 2 support. In a subsequent commit I plan to add in a conditional
code path that kicks in when running under Rails 2.
Wincent Colaiuta [Wed, 9 Jun 2010 19:33:58 +0000 (21:33 +0200)]
Mark String#w and String#to_wikitext output as HTML safe
This applies only when running under Rails 3, or when the "html_safe"
method is otherwise available.
As these methods are the most commonly used methods for translating
wikitext markup to HTML in Rails applications, this should provide a
fairly convenient upgrade path for developers moving from Rails 2 to
Rails 3.