Class: PublishingPlatformMarkdown::Document
- Inherits:
-
Object
- Object
- PublishingPlatformMarkdown::Document
- Defined in:
- lib/publishing_platform_markdown.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source, options = {}) ⇒ Document
constructor
A new instance of Document.
- #to_html ⇒ Object
Constructor Details
#initialize(source, options = {}) ⇒ Document
Returns a new instance of Document.
18 19 20 21 22 23 24 25 |
# File 'lib/publishing_platform_markdown.rb', line 18 def initialize(source, = {}) = .dup.deep_symbolize_keys @source = source ? source.dup : "" @allowed_elements = .delete(:allowed_elements) || [] @options = { sanitize: true, syntax_highlighter: nil }.merge() end |
Class Method Details
.to_html(source, options = {}) ⇒ Object
14 15 16 |
# File 'lib/publishing_platform_markdown.rb', line 14 def self.to_html(source, = {}) new(source, ).to_html end |
Instance Method Details
#to_html ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/publishing_platform_markdown.rb', line 27 def to_html @to_html ||= if @options[:sanitize] HtmlSanitizer.new(kramdown_doc.to_html) .sanitize(allowed_elements: @allowed_elements) else kramdown_doc.to_html end end |