Latest Maruku and Tweak for itex2MML 1.3.4

Instiki's LaTeX output also supports \Perp.
This commit is contained in:
Jacques Distler 2008-02-29 01:30:46 -06:00
parent 5dd0507acc
commit 9b7b6fb805
94 changed files with 2126 additions and 1171 deletions

View file

@ -0,0 +1,100 @@
OpenDiv = /^[ ]{0,3}\+\-\-+\s*([^\s-]*)\s*\-*\s*$/
CloseDiv = /^[ ]{0,3}\=\-\-+\s*([^\s-]*)\s*\-*\s*$/
StartPipe = /^[ ]{0,3}\|(.*)$/ # $1 is rest of line
DecorativeClosing = OpenDiv
MaRuKu::In::Markdown::register_block_extension(
:regexp => OpenDiv,
:handler => lambda { |doc, src, context|
# return false if not doc.is_math_enabled?
first = src.shift_line
first =~ OpenDiv
ial_at_beginning = $1
ial_at_end = nil
lines = []
# if second line starts with "|"
if src.cur_line =~ StartPipe
# then we read until no more "|"
while src.cur_line && (src.cur_line =~ StartPipe)
content = $1
lines.push content
src.shift_line
end
if src.cur_line =~ DecorativeClosing
ial_at_end = $1
src.shift_line
end
else
# else we read until CloseDiv
divs_open = 1
while src.cur_line && (divs_open>0)
if src.cur_line =~ CloseDiv
divs_open -= 1
if divs_open == 0
ial_at_end = $1
src.shift_line
break
else
lines.push src.shift_line
end
else
if src.cur_line =~ OpenDiv
divs_open += 1
end
lines.push src.shift_line
end
end
if divs_open > 0
e = "At end of input, I still have #{divs_open} DIVs open."
doc.maruku_error(e, src, context)
return true
end
end
ial_at_beginning = nil unless
(ial_at_beginning&&ial_at_beginning.size > 0)
ial_at_end = nil unless (ial_at_end && ial_at_end.size > 0)
if ial_at_beginning && ial_at_end
e = "Found two conflicting IALs: #{ial_at_beginning.inspect} and #{ial_at_end.inspect}"
doc.maruku_error(e, src, context)
end
al_string = ial_at_beginning || ial_at_end
al = nil
if al_string =~ /^\{(.*)\}$/
inside = $1
cs = MaRuKu::In::Markdown::SpanLevelParser::CharSource
al = al_string &&
doc.read_attribute_list(cs.new(inside), its_context=nil, break_on=[nil])
end
src = MaRuKu::In::Markdown::BlockLevelParser::LineSource.new(lines)
children = doc.parse_blocks(src)
context.push doc.md_div(children, al)
true
})
module MaRuKu; class MDElement
def md_div(children, a=nil)
self.md_el(:div, children, meta={}, a)
end
end end
module MaRuKu; module Out; module HTML
def to_html_div
add_ws wrap_as_element('div')
end
end end end

View file

@ -33,7 +33,7 @@ Summary: Math openings which should be numerated
Array containing any of `'\\['`, `'\\begin{equation}'`, `'$$'`.
MaRuKu::Globals[math_numbered] = ['\\[']
MaRuKu::Globals[:math_numbered] = ['\\[']
=end

View file

@ -508,7 +508,9 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
end
def split_cells(s)
s.strip.split('|').select{|x|x.strip.size>0}.map{|x|x.strip}
# s.strip.split('|').select{|x|x.strip.size>0}.map{|x|x.strip}
# changed to allow empty cells
s.strip.split('|').select{|x|x.size>0}.map{|x|x.strip}
end
def read_table(src)

View file

@ -271,7 +271,7 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
extension_meta(src, con, break_on_chars)
else
stuff = read_simple(src, escaped=[?}], break_on_chars, [])
if stuff =~ /^(\w+\s|[^\w])/u
if stuff =~ /^(\w+\s|[^\w])/
extension_id = $1.strip
if false
else
@ -594,7 +594,7 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
return
end
else # empty [link]
id = children.to_s.downcase.gsub(' ','_')
id = sanitize_ref_id(children.to_s) #. downcase.gsub(' ','_')
con.push_element md_link(children, id)
end
end # read link
@ -647,14 +647,19 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
con.push_element md_im_image(alt_text, url, title)
when ?[ # link ref
ref_id = read_ref_id(src,con)
if ref_id.size == 0
ref_id = alt_text.to_s.downcase.gsub(' ','_')
else
ref_id = ref_id.downcase
if not ref_id # TODO: check around
error('Reference not closed.', src, con)
ref_id = ""
end
if ref_id.size == 0
ref_id = alt_text.to_s
end
ref_id = sanitize_ref_id(ref_id)
con.push_element md_image(alt_text, ref_id)
else # no stuff
ref_id = alt_text.to_s.downcase.gsub(' ','_')
ref_id = sanitize_ref_id(alt_text.to_s)
con.push_element md_image(alt_text, ref_id)
end
end # read link

View file

@ -44,8 +44,8 @@ module MaRuKu; module Strings
return :definition if l =~ Definition
# I had a bug with emails and urls at the beginning of the
# line that were mistaken for raw_html
return :text if l=~ /^#{EMailAddress}/
return :text if l=~ /^<http:/
return :text if l=~ /^[ ]{0,3}#{EMailAddress}/
return :text if l=~ /^[ ]{0,3}<http:/
# raw html is like PHP Markdown Extra: at most three spaces before
return :xml_instr if l =~ %r{^\s*<\?}
return :raw_html if l =~ %r{^[ ]?[ ]?[ ]?</?\s*\w+}

View file

@ -148,6 +148,7 @@ module MaRuKu; module Strings
s[0, i+1].strip
end
# change space to "_" and remove any non-word character
def sanitize_ref_id(x)
x.downcase.gsub(' ','_').gsub(/[^\w]/,'')
end

View file

@ -0,0 +1 @@
require 'maruku/input_textile2/t2_parser'

View file

@ -19,7 +19,7 @@
#++
module MaRuKu
Version = '0.5.7'
Version = '0.5.8'
MarukuURL = 'http://maruku.rubyforge.org/'