1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
=begin
= Ϣץ饰 sn.rb $Revision: 1.3 $
==
դֹ̤ɽޤ
== Ȥ
sn( number )
number - ꤷͤ˥åȤޤ
sn_anchorid
sn()åɤγդȤˡ1Ϥޤֹ̤ɽޤ
sn_anchorid()åɤϸߤΥidֹɽޤ
sn_anchorid()ꥪץΥ/ĥåߥ
Ȥƻꤹ뤳ȤˤäơΥ/ĥåߥ
URLȷդͤɽ뤳ȤǤޤ
==
anchor()zoenumber_anchor.rbͤ˺ޤ
= Sequential number generator plugin
== Abstract
Display sequential numbers for every date.
== Usage
sn( number )
number - Set the value of the internal counter to 'number'.
sn_anchorid
The sn() method displays sequential numbers starting at 1 for
every date.
The sn_anchorid() method displays a current number of the anchorid.
If you use sn_anchorid() as a section/comment anchor in the setup
option, you can display the number relevant to URL of
the section/comment anchor.
== reference
Original anchor() appeared in the number_anchor.rb by zoe-san.
== ˤĤ (Copyright notice)
Copyright (c) 2003 SAKAMOTO Hideki <hs@on-sky.net>
Distributed under the GPL
=end
=begin Changelog
2003-09-23 SAKAMOTO Hideki <hs@on-sky.net>
* document corrected
2003-09-17 SAKAMOTO Hideki <hs@on-sky.net>
* add add_body_leave_proc
2003-09-13 SAKAMOTO Hideki <hs@on-sky.net>
* change @sn_section initialization: nil -> 0
* delete @sn_section clear line in sn()
* add sn_anchorid method
2003-09-10 SAKAMOTO Hideki <hs@on-sky.net>
* write English document
* force to use anchor-id in section anchor
* delete 'sn.use_anchorid' option
2003-08-29 SAKAMOTO Hideki <hs@on-sky.net>
* first version
=end
add_body_enter_proc do |date|
@sn_count = 1
@sn_idx = 0
""
end
add_body_leave_proc do |date|
@sn_count = 1
@sn_idx = 0
""
end
alias :_orig_anchor_sn :anchor
def anchor( s )
if /^(\d+)#?([pct])?(\d*)?$/ =~ s then
if $2 then
@sn_idx = $3.to_i
end
end
_orig_anchor_sn(s)
end
def sn( number = nil )
if number then
@sn_count = number.to_i
else
number = @sn_count
end
@sn_count += 1
%Q[#{'%d' % number}]
end
def sn_anchorid
%Q[#{'%d' % @sn_idx}]
end
|