actiontext-syntax-highlighter 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31390bf8597bfd8d545a61a1682161e6e5e7096411cd89e1bcf981aa358eb0b2
4
- data.tar.gz: be598fa01d142a066f9c736594f7b58e67cd26338f1349f4ae60ba531003c4d4
3
+ metadata.gz: 237e94b19c7b9fcf502f85f01e71cd7d4eb6bdf372feedb036cc88699863127a
4
+ data.tar.gz: c7c503cbc3d413e1543b1df16bef35e5eebbb6611b82482ed52debbf970a1261
5
5
  SHA512:
6
- metadata.gz: 05bf47fa9c3a47e153b51a63a532e806fe18d6b3aa8d68a49c0ad9c7d04613f794971f2bd3efa81020c0204a3a8900fbabc75187e430905195a98e9e375d3d78
7
- data.tar.gz: 3d8c27f3a029bb7b13ec6e4b95ad1a3a39150632a41cc0e388f732a2b5348f8f9f61a0fa1c577d3e9c80b52c68401653886c5dc34f7b3590b1a5d62a46455feb
6
+ metadata.gz: 7d37cbff4ad68c89e68cac23b3e3034ea04264f764ab52996da963b329cdd9d12898a5eb12bc0b3c0d79fb43072f623368e185f2860dbf8abc58c38ecb8a79c7
7
+ data.tar.gz: ba94cbab086ab0e4ff21b6a35addedb23ba69e9f8c6c8fca1d8bb77038572556af952d85d7a487f320b9316a01b909b1d2a777861d56e8431d43b02e52242bc0
data/README.md CHANGED
@@ -60,7 +60,7 @@ config.action_text_syntax_highlighter.default_theme = :base16
60
60
 
61
61
  You can override the default theme by setting `@highlighted_code_block_theme` in your controller action where you're rendering out the rich text.
62
62
 
63
- This plugin requires a global `Trix` variable to create attachments, so require Trix in your application as below:
63
+ `ActionTextSyntaxHighlighter` requires a global `Trix` variable to create attachments, so require Trix in your application as below:
64
64
 
65
65
  ```javascript
66
66
  window.Trix = require("trix")
@@ -80,6 +80,25 @@ If you wish, you can import pre-bundled JavaScript instead of the module as desc
80
80
  import "@ayushn21/actiontext-syntax-highlighter/dist"
81
81
  ```
82
82
 
83
+ ## Converting existing rich texts
84
+
85
+ If you've already code rich texts in your app with code blocks using a `pre` tag, you can use the method `convert_pre_tags_to_highlighted_code_blocks` on `ActionText::RichText` to migrate them over to highlighted code blocks.
86
+
87
+ For example:
88
+
89
+ ```ruby
90
+ ActionText::RichText.find_each do |rich_text|
91
+ rich_text.convert_pre_tags_to_highlighted_code_blocks
92
+ end
93
+ ```
94
+
95
+ ## Cleaning up deleted code blocks
96
+
97
+ `ActionTextSyntaxHighlighter` nullifies the `rich_text_id` on a `HighlightedCodeBlock` when it's removed from an `ActionText::RichText`. However it doesn't delete the record.
98
+
99
+ I recommend you set up a cron job to execute the included `ActionTextSyntaxHighlighter::PurgeDeletedHighlightedCodeBlocksJob` which will delete all `HighlightedCodeBlock`s over a day old without an associated `RichText`.
100
+
101
+
83
102
  ## Contributing
84
103
 
85
104
  1. Fork it (https://github.com/ayushn21/actiontext-syntax-highlighter/fork)
@@ -31,6 +31,7 @@ class ActionTextSyntaxHighlighter::HighlightedCodeBlock < ApplicationRecord
31
31
 
32
32
  private
33
33
  def process_content
34
+ self.content = CGI.unescapeHTML(self.content)
34
35
  self.content&.gsub!(/<br>/, "\n")
35
36
  end
36
37
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionTextSyntaxHighlighter
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actiontext-syntax-highlighter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ayush Newatia