Adam Shelly
11/25/2006 8:29:00 PM
On 11/25/06, Paul Lutus <nospam@nosite.zzz> wrote:
> Louis J Scoras wrote:
>
> > On 11/25/06, Paul Lutus <nospam@nosite.zzz> wrote:
> >
> >> All except the part where it didn't work.
> >
> > *Chuckles.* Of course. The best-laid schemes o' mice an' men and all
> > that.
> >
> >> You are arguing that it should work in principle, even if it doesn't work
> >> in fact. And I agree.
> >>
> >> Yes. Agreed. My point is that there are much simpler solutions.
> >
> > And so we come to the point where both parties discover that there
> > isn't much disagreement over most of the substantive points. That
> > being said, I need to ask what you think simpler solutions are. Mind
> > you I ask this not in a glove-slapping, defend your honor type of way.
> > On the contrary, I'd be genuinely interested in such a solution.
>
> Very simple: tell me what the requirement is. I will then post a solution.
> The solution will (1) work, and (2) not be large or incomprehensible -- or
> I will fail, and if that happens I will say so.
>
Ok, I'll jump back into my question, after a 2 day break for turkey gluttony.
I think the 'requirement' could be stated at two levels.
1) In the simplest case, it is to take a string formatted according to
the RedCloth rules, and to have code blocks in that string render
correctly. Where 'correctly' means that
a) text inside code blocks is not interpreted as markup - specifically
that pairs of asterisks don't get replaced by <strong> tags.
b) all the words are rendered in the original order, so that given
text = <<EOT
comment
line = "\n"+misplaced
EOT
puts RedCloth.new(text).to_html()
the word 'misplaced' does not appear before 'line' in the resulting html.
2) The real requirement (needed for my RubyQuiz solution) is: Be able
to enter code blocks in the 'junebug' wiki (which is built on the
RedCloth and Camping libraries) and have the code render correctly, as
defined above.
I actually found a 'simple' solution to all of these requirements:
Don't use markdown style code blocks (indicated by indenting 4 spaces)
in RedCloth. Insert the <pre><code>...</code></pre> tags yourself
when entering code into the wiki. I can live with that - although it
takes away some of the ease of use which led me to choose a wiki in
the first place.
On the other hand, I think requirement 1b can be viewed as a failed
unit test for RedCloth. RedCloth is supposed to support the markdown
formatting rules, yet in this case you get misplaced text even if you
restrict it to the markdown ruleset with
`RedCloth.new(text).to_html(:markdown)`
I was hoping someone would address that issue.
-Adam