module WikiScript
Constants
- LINK_PATTERN
todo: fix? - strip spaces from link and title
spaces possible? strip in ruby later e.g. use strip - why? why not? todo/change: find a better name - rename LINK_PATTERN to LINK_REGEX - why? why not?
- VERSION
Public Class Methods
get( title, lang: Wikiscript.lang )
click to toggle source
# File lib/wikiscript.rb, line 96 def self.get( title, lang: Wikiscript.lang ) Page.get( title, lang: lang ); end
lang()
click to toggle source
# File lib/wikiscript.rb, line 34 def self.lang # note: for now always returns a string e.g. 'en', 'de' etc. not a symbol @@lang ||= 'en' end
lang=(value)
click to toggle source
for now make lang a global - change why? why not??
# File lib/wikiscript.rb, line 30 def self.lang=(value) @@lang = value.to_s # use to_s - lets you pass ing :en, :de etc. end
parse( text )
click to toggle source
more convenience shortcuts / helpers
# File lib/wikiscript.rb, line 92 def self.parse( text ) PageReader.parse( text ); end
parse_link( text )
click to toggle source
# File lib/wikiscript.rb, line 75 def self.parse_link( text ) ## todo/change: find a better name - use match_link/etc. - why? why not? ## find first matching link ## return [nil,nil] if nothing found if (m = LINK_PATTERN.match( text )) link = m[:link] title = m[:title] link = link.strip ## remove leading and trailing spaces title = title.strip if title [link,title] else [nil,nil] end end
parse_table( text )
click to toggle source
# File lib/wikiscript.rb, line 93 def self.parse_table( text ) TableReader.parse_table( text ); end
read( path )
click to toggle source
# File lib/wikiscript.rb, line 95 def self.read( path ) Page.read( path ); end
root()
click to toggle source
# File lib/wikiscript/version.rb, line 9 def self.root "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}" end
unlink( text )
click to toggle source
# File lib/wikiscript.rb, line 54 def self.unlink( text ) ## replace ALL wiki links with title (or link) ## e.g. [[Santiago]] ([[La Florida, Chile|La Florida]]) ## => Santiago (La Florida) text = text.gsub( LINK_PATTERN ) do |_| link = $~[:link] title = $~[:title] if title title else link end end text.strip end
Also aliased as: flatten_links