Sha256: 0da28703c2dcbf0bf0cb07b65850b1df36d7cbf72837c8812a28cb807ea414bf

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

#!/usr/bin/env ruby

macro :anchor do 
	min_parameters 1
	max_parameters 2
	ident, title = params
	macro_error "Bookmark '#{ident}' already exists" if bookmark? ident
	bookmark :id => ident, :title => title
	%{<a id="#{ident}">#{title}</a>}
end

macro :codeph do
	%{<code>#@value</code>}
end

macro :link do
	min_parameters 1
	max_parameters 2
	href, title = params
	if href.match /^#/ then
		anchor = href.gsub(/^#/, '').to_sym
		bmk = bookmark? anchor
		if bmk then
			title ||= bmk[:title]
		else
			plac = placeholder do |document|
				macro_error "Bookmark '#{anchor}' does not exist" unless document.bookmarks[anchor] 
				document.bookmarks[anchor][:title]
			end
			title ||= plac
		end
	end
	title ||= href
	%{<a href="#{href}">#{title}</a>}
end

macro :fmi do
	exact_parameters 2, :level => :warning
	topic, href = params
	link = placeholder do |document| 
		interpret "link[#{href}]"
	end
	%{<span class="fmi">for more information on #{topic}, see #{link}</span>}
end

macro :draftcomment do
	if Glyph['document.draft'] then
		%{<span class="comment"><span class="comment-pre"><strong>Comment:</strong> </span>#{@value}</span>}
	else
		""
	end
end

macro :todo do
	min_parameters 1
	todo = "[#{@source}] -- #{@value}"
	 @node[:document].todos << todo unless @node[:document].todos.include? todo
	if Glyph['document.draft']  then
	 	%{<span class="todo"><span class="todo-pre"><strong>TODO:</strong> </span>#{@value}</span>} 
	else
		""
	end
end

macro_alias :bookmark => :anchor
macro_alias '#' => :anchor
macro_alias '=>' => :link
macro_alias '!' => :todo
macro_alias :dc => :draftcomment

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glyph-0.2.0 macros/html/inline.rb