actiontext-syntax-highlighter 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 237e94b19c7b9fcf502f85f01e71cd7d4eb6bdf372feedb036cc88699863127a
|
4
|
+
data.tar.gz: c7c503cbc3d413e1543b1df16bef35e5eebbb6611b82482ed52debbf970a1261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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)
|