File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -124,14 +124,14 @@ def option(name, desc)
124124 def demo_file ( arg = :absent )
125125 return @demo_file = Pathname . new ( arg ) unless arg == :absent
126126
127- @demo_file = Pathname . new ( File . join ( __dir__ , 'demos' , tag ) )
127+ @demo_file || = Pathname . new ( File . join ( __dir__ , 'demos' , tag ) )
128128 end
129129
130130 # Specify or get a small demo string for this lexer
131131 def demo ( arg = :absent )
132132 return @demo = arg unless arg == :absent
133133
134- @demo = File . read ( demo_file , mode : 'rt:bom|utf-8' )
134+ @demo || = File . read ( demo_file , mode : 'rt:bom|utf-8' )
135135 end
136136
137137 # @return a list of all lexers.
Original file line number Diff line number Diff line change @@ -243,4 +243,12 @@ def initialize(*)
243243 assert { php . instance_variable_get ( :@start_inline ) == :guess }
244244 assert { inline_php . instance_variable_get ( :@start_inline ) == true }
245245 end
246+
247+ it 'supports custom demos' do
248+ lexer = Class . new ( Rouge ::Lexer ) do
249+ demo 'my cool demo'
250+ end
251+
252+ assert { lexer . demo == 'my cool demo' }
253+ end
246254end
You can’t perform that action at this time.
0 commit comments