Make Andrea Happy
Use a counter, instead of rand() to aid in generating unique IDs in Maruku. Add Unit test for the Theorem Environment.
This commit is contained in:
parent
e48b000c11
commit
39348c65c2
4 changed files with 85 additions and 4 deletions
|
@ -2,7 +2,7 @@ module MaRuKu
|
|||
|
||||
class MDDocument
|
||||
# Hash equation id (String) to equation element (MDElement)
|
||||
attr_accessor :eqid2eq, :refid2ref
|
||||
attr_accessor :eqid2eq
|
||||
|
||||
def is_math_enabled?
|
||||
get_setting :math_enabled
|
||||
|
|
|
@ -45,8 +45,9 @@ class MDElement
|
|||
$uid += 1
|
||||
title = "id#{$uid}"
|
||||
end
|
||||
|
||||
title << "_" + rand(10000).to_s
|
||||
|
||||
@doc.id_counter += 1
|
||||
title << "_" + @doc.id_counter.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -144,6 +144,10 @@ class MDDocument
|
|||
safe_attr_accessor :footnotes_order, Array
|
||||
|
||||
safe_attr_accessor :latex_required_packages, Array
|
||||
|
||||
safe_attr_accessor :refid2ref, Hash
|
||||
# A counter for generating unique IDs
|
||||
safe_attr_accessor :id_counter, Integer
|
||||
|
||||
def initialize(s=nil)
|
||||
super(:document)
|
||||
|
@ -155,6 +159,7 @@ class MDDocument
|
|||
self.abbreviations = {}
|
||||
self.ald = {}
|
||||
self.latex_required_packages = []
|
||||
self.id_counter = 0
|
||||
|
||||
parse_doc(s) if s
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue