Sha256: 5b11cbc84755161625e9085c1424b76cc9db5d3852e0b05525a3fbe35f96c368
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true module EditorJs module Blocks # markdown block class MarkdownBlock < Base def sanitize!; end def schema YAML.safe_load(<<~YAML) type: object additionalProperties: false properties: text: type: string YAML end # commonmarker: markdown to html # https://github.com/gjtorikian/commonmarker # https://github.github.com/gfm/#ordered-list # https://meta.stackexchange.com/questions/348746/were-switching-to-commonmark # rouge: syntax highlighter # https://github.com/rouge-ruby/rouge/ # https://spsarolkar.github.io/rouge-theme-preview/ # shell: rougify help style # # Get some CSS # Rouge::Themes::Base16.mode(:light).render(scope: '.highlight') # # Or use Theme#find with string input # Rouge::Theme.find('base16.light').render(scope: '.highlight') def render(_options = {}) content_tag :div, class: css_name do content_text = data['text'] || '' CommonMarker::Rouge.render_html( content_text, %i[UNSAFE FOOTNOTES STRIKETHROUGH_DOUBLE_TILDE], %i[UNSAFE GITHUB_PRE_LANG HARDBREAKS TABLE_PREFER_STYLE_ATTRIBUTES FULL_INFO_STRING FOOTNOTES], %i[table strikethrough tasklist tagfilter], formatter: Rouge::Formatters::HTMLLegacy.new(inline_theme: 'github') ).html_safe end end def plain data['text'].strip end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
editor_js-0.4.0 | lib/editor_js/blocks/markdown_block.rb |
editor_js-0.3.6.1 | lib/editor_js/blocks/markdown_block.rb |
editor_js-0.3.6 | lib/editor_js/blocks/markdown_block.rb |