lib/kramdown/parser/govuk.rb in govspeak-8.2.1 vs lib/kramdown/parser/govuk.rb in govspeak-8.3.0

- old
+ new

@@ -15,10 +15,17 @@ Default: www.gov.uk Used by: KramdownWithAutomaticExternalLinks DESCRIPTION simple_array_validator(val, :document_domains, AlwaysEqual.new) end + + define(:ordered_lists_disabled, Boolean, false, <<~DESCRIPTION) + Disables ordered lists + + Default: false + Used by: KramdownWithAutomaticExternalLinks + DESCRIPTION end module Parser class Govuk < Kramdown::Parser::Kramdown CUSTOM_INLINE_ELEMENTS = %w[govspeak-embed-attachment-link].freeze @@ -44,10 +51,20 @@ end def parse_block_html return false if CUSTOM_INLINE_ELEMENTS.include?(@src[1].downcase) - super + return super unless @options[:ordered_lists_disabled] + + # Kramdown loads parsers into the instance from `options` which are scoped to + # the class. Because we are changing these options inside an instance, we must + # reconfigure the parser before and after disbaling ordered lists. + Govspeak::KramdownOverrides.with_kramdown_ordered_lists_disabled do + configure_parser + super + end + + configure_parser end end end end