madness 1.2.2 → 1.2.4
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 +4 -4
- data/README.md +26 -8
- data/lib/madness/cli.rb +2 -2
- data/lib/madness/commands/config.rb +3 -3
- data/lib/madness/inline_table_of_contents.rb +1 -3
- data/lib/madness/refinements/string_refinements.rb +8 -2
- data/lib/madness/rendering/pandoc.rb +7 -0
- data/lib/madness/rendering/redcarpet.rb +5 -1
- data/lib/madness/rendering/redcarpet_custom.rb +18 -0
- data/lib/madness/version.rb +1 -1
- metadata +4 -4
- data/lib/madness/rendering/redcarpet_highlighter.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5790a84273b260c95800d1497ce38a0d5e7f2eabe77b8231309ebf70eb7acb4
|
4
|
+
data.tar.gz: 013d8d7b8dd741bc5a03092c58c6326caa2cdf6c82b001be4755615e6184439b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 942b0408a4ef4e85630703cd31a0c1b0c9d4a5695db685d612cd4280dc01282e725b63629b006dd41abf1ec198ac13df34370444820ea00bdf67c0ffe9c686b4
|
7
|
+
data.tar.gz: 1d0c07859780758c0ea6211ac6f0f62662f49be96adf2d083aba88703148b69e0979caeea5ca47351b5aa775310172533d74ccdb82566013fbd137172de22d9b
|
data/README.md
CHANGED
@@ -2,12 +2,6 @@
|
|
2
2
|
|
3
3
|
# Madness - Instant Markdown Server
|
4
4
|
|
5
|
-
[](https://badge.fury.io/rb/madness)
|
6
|
-
[](https://github.com/DannyBen/madness/actions?query=workflow%3ATest)
|
7
|
-
[](https://codeclimate.com/github/DannyBen/madness/maintainability)
|
8
|
-
|
9
|
-
---
|
10
|
-
|
11
5
|
Madness is a command line server for rendering markdown documents in your
|
12
6
|
browser. It is designed to facilitate easy development of internal
|
13
7
|
markdown-based documentation sites.
|
@@ -267,8 +261,32 @@ file or a directory in the same directory as the file itself.
|
|
267
261
|
|
268
262
|
### Mermaid Diagrams and Charts
|
269
263
|
|
270
|
-
When the `mermaid` option is enabled, you
|
271
|
-
|
264
|
+
When the `mermaid` option is enabled, you can embed Mermaid diagrams in your
|
265
|
+
document using either of the following methods:
|
266
|
+
|
267
|
+
1. **Using a `<div>` block with `mermaid` class**:
|
268
|
+
|
269
|
+
```html
|
270
|
+
<div class="mermaid">
|
271
|
+
graph TD;
|
272
|
+
A-->B;
|
273
|
+
A-->C;
|
274
|
+
B-->D;
|
275
|
+
C-->D;
|
276
|
+
</div>
|
277
|
+
```
|
278
|
+
|
279
|
+
2. **Using a code fence with `mermaid` language specifier**:
|
280
|
+
|
281
|
+
````markdown
|
282
|
+
```mermaid
|
283
|
+
graph TD;
|
284
|
+
A-->B;
|
285
|
+
A-->C;
|
286
|
+
B-->D;
|
287
|
+
C-->D;
|
288
|
+
```
|
289
|
+
````
|
272
290
|
|
273
291
|
### Table of Contents Generation
|
274
292
|
|
data/lib/madness/cli.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'mister_bin'
|
2
2
|
|
3
3
|
module Madness
|
4
|
-
# The CLI class is used by the
|
5
|
-
# commands to the relevant
|
4
|
+
# The CLI class is used by the madness 'binary' and forwards incoming CLI
|
5
|
+
# commands to the relevant Madness::Commands class
|
6
6
|
class CLI
|
7
7
|
def self.runner
|
8
8
|
runner = MisterBin::Runner.new version: Madness::VERSION,
|
@@ -3,9 +3,9 @@ module Madness
|
|
3
3
|
class Config < Base
|
4
4
|
summary 'Manage the madness configuration file'
|
5
5
|
|
6
|
-
usage '
|
7
|
-
usage '
|
8
|
-
usage '
|
6
|
+
usage 'madness config new'
|
7
|
+
usage 'madness config show'
|
8
|
+
usage 'madness config (-h|--help)'
|
9
9
|
|
10
10
|
command 'new', 'Create a new .madness.yml configuration file'
|
11
11
|
command 'show', 'Show all configuration options'
|
@@ -36,10 +36,8 @@ module Madness
|
|
36
36
|
level = matches[:level].size - 2
|
37
37
|
|
38
38
|
spacer = ' ' * level
|
39
|
-
slug = text.to_slug
|
39
|
+
slug = text.to_slug config.renderer
|
40
40
|
|
41
|
-
# pandoc removes leading numbers and dots from header slugs, we do the same
|
42
|
-
slug = slug.remove(/^[\d\-]+/) if config.renderer == 'pandoc'
|
43
41
|
"#{spacer}- [#{text}](##{slug})"
|
44
42
|
end
|
45
43
|
|
@@ -11,8 +11,14 @@ module Madness
|
|
11
11
|
Addressable::URI.escape self
|
12
12
|
end
|
13
13
|
|
14
|
-
def to_slug
|
15
|
-
downcase.strip
|
14
|
+
def to_slug(renderer = nil)
|
15
|
+
result = downcase.strip
|
16
|
+
|
17
|
+
if renderer == 'pandoc'
|
18
|
+
result.remove(/[^a-z0-9 ]/).tr(' ', '-')
|
19
|
+
else
|
20
|
+
result.gsub(/[^[:alnum:]]/, '-').squeeze('-').remove(/(^-|-$)/)
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
24
|
# This is here so we can have one place that defines how to convert
|
@@ -6,6 +6,7 @@ module Madness
|
|
6
6
|
include ServerHelper
|
7
7
|
|
8
8
|
def render(text)
|
9
|
+
text = process_mermaid_blocks text if config.mermaid
|
9
10
|
PandocRuby.new(text, [{ from: :gfm, to: :html }], *options).convert
|
10
11
|
end
|
11
12
|
|
@@ -14,6 +15,12 @@ module Madness
|
|
14
15
|
def options
|
15
16
|
@options ||= config.highlighter ? [] : :no_highlight
|
16
17
|
end
|
18
|
+
|
19
|
+
def process_mermaid_blocks(text)
|
20
|
+
text.gsub(/```mermaid\s+(.+?)\s+```/m) do
|
21
|
+
"<div class='mermaid'>#{$1.strip}</div>"
|
22
|
+
end
|
23
|
+
end
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
require 'rouge'
|
3
|
+
require 'rouge/plugins/redcarpet'
|
4
|
+
|
5
|
+
module Madness
|
6
|
+
# Renderer with syntax highlighting support
|
7
|
+
class CustomRenderer < Redcarpet::Render::HTML
|
8
|
+
include Rouge::Plugins::Redcarpet
|
9
|
+
|
10
|
+
def block_code(code, language)
|
11
|
+
if language == 'mermaid'
|
12
|
+
"<div class='mermaid'>#{code}</div>"
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/madness/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: addressable
|
@@ -294,7 +294,7 @@ files:
|
|
294
294
|
- lib/madness/rendering/handler.rb
|
295
295
|
- lib/madness/rendering/pandoc.rb
|
296
296
|
- lib/madness/rendering/redcarpet.rb
|
297
|
-
- lib/madness/rendering/
|
297
|
+
- lib/madness/rendering/redcarpet_custom.rb
|
298
298
|
- lib/madness/search.rb
|
299
299
|
- lib/madness/server.rb
|
300
300
|
- lib/madness/server_base.rb
|
@@ -327,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
327
327
|
- !ruby/object:Gem::Version
|
328
328
|
version: '0'
|
329
329
|
requirements: []
|
330
|
-
rubygems_version: 3.6.
|
330
|
+
rubygems_version: 3.6.9
|
331
331
|
specification_version: 4
|
332
332
|
summary: Instant Markdown Server
|
333
333
|
test_files: []
|