rouge-ddot 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6dd196cff29b3d1b7435c68febdf46fec71e7246ef1d1bfa40cc56793bf3094
4
- data.tar.gz: 40e95e043ee75d8bd53ba25a3c411a63a616f9f1a8ca07edd9998bea11e0145f
3
+ metadata.gz: 525dce4930ec1a53d67c034d86b7e4be1b3f6c0e177b62c7b06ba5ae0d93f875
4
+ data.tar.gz: af0fe26c6678d6cfd2fea2fe78aa030097402f44539084a8d778bc33d1f09e90
5
5
  SHA512:
6
- metadata.gz: 5bc30e43a5ad1909266a3d4908fea9c94ee3bddab264ad4eea04a4f03ae083db3cc9288f9892f86e86c8fc700fc1e5dae5cc9c99a4d35a0234299cef43a91068
7
- data.tar.gz: a27f2ea628b044ade571952af1638ae661a9b30b00cd674d38bd7169f27807dd2adaeed25114ea09c6179768c3e6b830d8bd8f27987db116d3c0a3967ac23d81
6
+ metadata.gz: 5bd9a99e2d35d17813dbb1efc9086fb1d25d4b48f616886119e46caf6f3d365af3727940311ae672cf4bd276c5800b4f41a0022217de566fd3aa7c6b3e30c44f
7
+ data.tar.gz: 93bd0e5a73d65f413e8d7fa4be1116a1a0d3970ef2d0534ebc8f5a80e2c611c52620a264aafb2d68ca0d5a5f3fd86f2bdf8cc178066c42e34375832e7dcfdf61
data/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.4
4
+
5
+ Brings the lexer up to all 42 cases of the cross-implementation corpus. The
6
+ emitted Rouge token types are the same as in 0.1.3, so themes need no change.
7
+
8
+ ### Changed
9
+
10
+ - **Unicode whitespace.** Whitespace is `[\t\p{Zs}]`, so a no-break space
11
+ (U+00A0) or any other space separator between slots separates exactly like a
12
+ space. U+200B ZERO WIDTH SPACE is a format character (Cf), not a space
13
+ separator, so it stays inside the name it is in (corpus case
14
+ 35-unicode-whitespace).
15
+ - **`,, !!block` opens a block.** The free metadata text after `,,` is the
16
+ fourth position in which a `!!block` opener is recognised, after subject,
17
+ object and metadata object (34-block-meta-text).
18
+ - **Inline metadata entries.** In `,,` inline metadata, `;;` always separates
19
+ entries, and an entry is a relation/value pair only when it carries a complete
20
+ `..relation.. value`; anything else is a note (36 to 42):
21
+ - an empty entry is allowed: in `,, ;; a note` the `;;` is a separator, not
22
+ unlexed text;
23
+ - `,, ..bla` is a note, not the start of a pair whose relation is `bla`;
24
+ - a pair's relation cannot run across a `;;`, so `,, ..bla ;; ..since.. 2016`
25
+ is the note `..bla` and the pair `since`/`2016`, not the relation `bla ;;`.
26
+
27
+ ## 0.1.3
28
+
29
+ No lexer changes — token output is identical to 0.1.2.
30
+
31
+ ### Added
32
+
33
+ - **`require 'rouge-ddot'` now works.** The gem shipped only
34
+ `lib/rouge/lexers/ddot.rb`, so requiring it by gem *name* raised
35
+ `LoadError: cannot load such file -- rouge-ddot`. Since Rouge does not
36
+ auto-discover third-party lexers, and `Bundler.require` (Jekyll's
37
+ `:jekyll_plugins` group, Rails initializers, …) requires gems by name,
38
+ hosts could not load the lexer the conventional way: adding it to a
39
+ `:jekyll_plugins` group *crashed the build*. Every host therefore had to
40
+ know the internal path and write `require 'rouge/lexers/ddot'` into a plugin
41
+ file of its own. A `lib/rouge-ddot.rb` entry point now requires the lexer,
42
+ so this is enough to highlight `[source,ddot.it]` blocks in Jekyll:
43
+
44
+ ```ruby
45
+ # Gemfile
46
+ group :jekyll_plugins do
47
+ gem 'rouge-ddot', '~> 0.1.3'
48
+ end
49
+ ```
50
+
51
+ `require 'rouge/lexers/ddot'` keeps working unchanged.
52
+
3
53
  ## 0.1.2
4
54
 
5
55
  Brings the lexer in line with the ddot.it Parse and Highlight specifications.
data/README.md CHANGED
@@ -6,35 +6,53 @@ graph notation (https://ddot.it).
6
6
  ## Usage
7
7
 
8
8
  ```ruby
9
- require 'rouge'
10
- require 'rouge/lexers/ddot'
9
+ require 'rouge-ddot'
11
10
 
12
11
  Rouge::Lexers::Ddot.new.lex("Project Eagle ..started in.. 2024") do |tok, val|
13
12
  puts [tok.qualname, val].inspect
14
13
  end
15
14
  ```
16
15
 
16
+ Rouge does not auto-discover third-party lexers, so the gem has to be required
17
+ before a `ddot.it` block can be highlighted. Requiring it by name is enough
18
+ (since 0.1.3); `require 'rouge/lexers/ddot'` also works.
19
+
20
+ In **Jekyll**, put it in the `:jekyll_plugins` group and Bundler requires it at
21
+ startup — no `_plugins/` file needed:
22
+
23
+ ```ruby
24
+ # Gemfile
25
+ group :jekyll_plugins do
26
+ gem 'rouge-ddot', '~> 0.1.4'
27
+ end
28
+ ```
29
+
17
30
  In Asciidoctor with `:source-highlighter: rouge` set, `[source,ddot]` blocks
18
- are dispatched here automatically — no extra wiring per document.
31
+ are dispatched here automatically — no extra wiring per document. The lexer
32
+ registers under the tag `ddot`, with the aliases `ddotit` and `ddot.it`.
19
33
 
20
34
  ## Token mapping
21
35
 
22
36
  The lexer emits standard Rouge tokens; they map to the canonical ddot.it
23
37
  token vocabulary in [`../../ddot.it/test-data/tokens.md`](../../ddot.it/test-data/tokens.md):
24
38
 
25
- | Rouge | Canonical |
26
- |-----------------------------|-----------------|
27
- | `Name::Class` | `subject` |
28
- | `Name::Function` | `relation` |
29
- | `Literal::String::Symbol` | `object` |
30
- | `Operator` | `operator` |
31
- | `Keyword::Pseudo` | `command` |
32
- | `Comment::Preproc` | `meta-delim` |
33
- | `Comment::Hashbang` | `meta-operator` |
34
- | `Comment::Doc` | `meta-relation` |
35
- | `Comment::Special` | `meta-object` |
36
- | `Comment::Multiline` | `meta-text` |
37
- | `Comment::Single` | `disabled` |
39
+ | Rouge | Canonical |
40
+ |-----------------------------|------------------|
41
+ | `Name::Class` | `subject` |
42
+ | `Name::Function` | `relation` |
43
+ | `Literal::String::Symbol` | `object` |
44
+ | `Operator` | `doubledot` |
45
+ | `Keyword::Pseudo` | `command` |
46
+ | `Name::Attribute` | `command-param` |
47
+ | `Name::Label` | `block-end` |
48
+ | `Comment::Preproc` | `meta-delim` |
49
+ | `Punctuation` | `meta-separator` |
50
+ | `Comment::Hashbang` | `meta-doubledot` |
51
+ | `Comment::Doc` | `meta-relation` |
52
+ | `Comment::Special` | `meta-object` |
53
+ | `Comment::Multiline` | `meta-text` |
54
+ | `Comment::Single` | `excluded` |
55
+ | `Literal::String::Backtick` | `verbatim` |
38
56
 
39
57
  ## Conformance
40
58
 
@@ -57,9 +75,11 @@ lockstep.
57
75
  ```
58
76
  rouge/
59
77
  ├── lib/
78
+ │ ├── rouge-ddot.rb # entry point: require 'rouge-ddot'
60
79
  │ └── rouge/
61
80
  │ └── lexers/
62
81
  │ └── ddot.rb # the lexer
82
+ ├── CHANGELOG.md
63
83
  ├── README.md
64
84
  └── rouge-ddot.gemspec
65
85
  ```
@@ -41,22 +41,30 @@ module Rouge
41
41
  filenames '*.ddot'
42
42
  mimetypes 'text/x-ddot'
43
43
 
44
+ # WS := TAB + every Unicode space separator (category Zs) — see the Parse
45
+ # Spec, "what counts as WS". NBSP (U+00A0) and NARROW NO-BREAK SPACE
46
+ # (U+202F) are visually identical to a space, so treating them as slot
47
+ # text would silently build a different node. WSX adds the characters
48
+ # Ruby's \s also covers, for use in negated classes.
49
+ WS_C = '\t\p{Zs}'.freeze
50
+ WSX_C = '\t\p{Zs}\r\n\f\v'.freeze
51
+
44
52
  # --- lexical tokens (see the Parse Spec's "Token Sequences") ----------
45
53
  # Each is a run of EXACTLY n, neither preceded nor followed by the same
46
54
  # character — the lookarounds are what express that. `\.{2}` alone would
47
55
  # happily match the first two dots of `...`.
48
56
  DT2 = /(?<!\.)\.{2}(?!\.)/.freeze
49
57
  DT4 = /(?<!\.)\.{4}(?!\.)/.freeze
50
- QUAD = /(?<!\.)(?:\.{4}|\.{2}[ \t]+\.{2})(?!\.)/.freeze
58
+ QUAD = /(?<!\.)(?:\.{4}|\.{2}[#{WS_C}]+\.{2})(?!\.)/.freeze
51
59
  CM2 = /(?<!,),,(?!,)/.freeze
52
60
  SC2 = /(?<!;);;(?!;)/.freeze
53
61
 
54
62
  OFF_RE = %r{(?:ddot\.it/off|!!off)}.freeze
55
63
  ON_RE = %r{(?:ddot\.it/on|!!on)}.freeze
56
64
  # Pins the command NAME: `!!office` must not read as `!!off`.
57
- BOUND_SRC = /(?![^\s?#])/.freeze
65
+ BOUND_SRC = /(?![^#{WSX_C}?#])/.freeze
58
66
  # A command needs the slash and a non-empty name; bare `ddot.it` is not one.
59
- CMD_RE = %r{(?:(?:https?://)?ddot\.it/|!!)[^\s?#]+(?:\?[^\s#]*)?(?:\#\S*)?}.freeze
67
+ CMD_RE = %r{(?:(?:https?://)?ddot\.it/|!!)[^#{WSX_C}?#]+(?:\?[^#{WSX_C}#]*)?(?:\#[^#{WSX_C}]*)?}.freeze
60
68
  BLOCK_RE = %r{(?:(?:https?://)?ddot\.it/|!!)block}.freeze
61
69
 
62
70
  # The line-shape gate: a line is ddot.it only if it carries a complete
@@ -65,7 +73,7 @@ module Rouge
65
73
  GATE = /(?=[^\n]*(?:#{DT4}|#{DT2}[^\n]*#{DT2}))/.freeze
66
74
 
67
75
  # `!!block` filling a whole field: it must END its physical line.
68
- BLOCK_OPENER = /#{BLOCK_RE}(?:(\?end=)(\S+))?[ \t]*(?=\n|\z)/.freeze
76
+ BLOCK_OPENER = /#{BLOCK_RE}(?:(\?end=)([^#{WSX_C}]+))?[#{WS_C}]*(?=\n|\z)/.freeze
69
77
 
70
78
  def reset!
71
79
  super
@@ -84,7 +92,7 @@ module Rouge
84
92
  # marker, and switch to verbatim.
85
93
  def open_block(match)
86
94
  raw = match[0]
87
- lead = raw[/\A[ \t]*/]
95
+ lead = raw[/\A[#{WS_C}]*/]
88
96
  body = raw[lead.length..].rstrip
89
97
  tail = raw[(lead.length + body.length)..]
90
98
  token Text, lead unless lead.empty?
@@ -104,7 +112,7 @@ module Rouge
104
112
  # ─────────── line-dispatch root ───────────
105
113
  state :root do
106
114
  # Standalone ,, opens a free-form meta block.
107
- rule(%r/^[ \t]*#{CM2}[ \t]*(?=\n|\z)/) do |m|
115
+ rule(%r/^[#{WS_C}]*#{CM2}[#{WS_C}]*(?=\n|\z)/) do |m|
108
116
  token Comment::Preproc, m[0]
109
117
  goto :meta_block
110
118
  end
@@ -115,12 +123,12 @@ module Rouge
115
123
  # this lexer, as an unmatched ",," followed by subject "since").
116
124
  # Keyed on shape — a state machine over physical lines cannot see that a
117
125
  # block object preceded: ",," then whitespace then "..".
118
- rule(%r/^[ \t]*(#{CM2})(?=[ \t]+#{DT2})/) do |m|
126
+ rule(%r/^[#{WS_C}]*(#{CM2})(?=[#{WS_C}]+#{DT2})/) do |m|
119
127
  token Comment::Preproc, m[1]
120
128
  push :inline_meta
121
129
  end
122
130
  # ... and SC2 after a block META OBJECT (`;; ..until.. 2020`).
123
- rule(%r/^[ \t]*(#{SC2})(?=[ \t]+#{DT2})/) do |m|
131
+ rule(%r/^[#{WS_C}]*(#{SC2})(?=[#{WS_C}]+#{DT2})/) do |m|
124
132
  token Punctuation, m[1]
125
133
  push :inline_meta
126
134
  end
@@ -134,11 +142,11 @@ module Rouge
134
142
  goto :disabled
135
143
  end
136
144
  # `!!block` alone on a line = a SUBJECT opener (block-as-field).
137
- rule(%r/^[ \t]*#{BLOCK_OPENER}/) { |m| open_block(m) }
145
+ rule(%r/^[#{WS_C}]*#{BLOCK_OPENER}/) { |m| open_block(m) }
138
146
  # Empty / whitespace-only line.
139
- rule %r/^[ \t]*\n/, Text
147
+ rule %r/^[#{WS_C}]*\n/, Text
140
148
  # Gate: only lines with a full operator skeleton parse as triples.
141
- rule(/^#{GATE}(?=[ \t]*(?:#{DT2}|#{QUAD}))/) { goto :after_subject }
149
+ rule(/^#{GATE}(?=[#{WS_C}]*(?:#{DT2}|#{QUAD}))/) { goto :after_subject }
142
150
  rule(/^#{GATE}/) { goto :subject }
143
151
  # Anything else is not a triple: consume the line, emit no token.
144
152
  rule %r/[^\n]+/, Text
@@ -153,11 +161,11 @@ module Rouge
153
161
  # newline instead — visible as an error-styled blank line inside every
154
162
  # `?end=` block. (The conformance harness drops whitespace-only chunks,
155
163
  # so the corpus cannot catch this; it only shows in rendered output.)
156
- rule(%r/^[ \t]*\n/) do |m|
164
+ rule(%r/^[#{WS_C}]*\n/) do |m|
157
165
  token Text, m[0]
158
166
  goto :root if @block_end.nil?
159
167
  end
160
- rule(%r/^[ \t]*\z/) do |m|
168
+ rule(%r/^[#{WS_C}]*\z/) do |m|
161
169
  token Text, m[0]
162
170
  goto :root if @block_end.nil?
163
171
  end
@@ -181,27 +189,27 @@ module Rouge
181
189
  token Text, m[3]
182
190
  goto :root
183
191
  end
184
- rule %r/^[ \t]*\n/, Text
192
+ rule %r/^[#{WS_C}]*\n/, Text
185
193
  rule %r/[^\n]+/, Comment::Single
186
194
  rule %r/\n/, Text
187
195
  end
188
196
 
189
197
  # ─────────── multi-line meta block (free-form or typed) ───────────
190
198
  state :meta_block do
191
- rule(%r/^[ \t]*#{CM2}[ \t]*(?=\n|\z)/) do |m|
199
+ rule(%r/^[#{WS_C}]*#{CM2}[#{WS_C}]*(?=\n|\z)/) do |m|
192
200
  token Comment::Preproc, m[0]
193
201
  goto :root
194
202
  end
195
- rule %r/^[ \t]*\n/, Text
196
- rule(/^(?=[ \t]*(?:#{DT2}|#{QUAD}))/) { goto :typed_meta_op }
203
+ rule %r/^[#{WS_C}]*\n/, Text
204
+ rule(/^(?=[#{WS_C}]*(?:#{DT2}|#{QUAD}))/) { goto :typed_meta_op }
197
205
  rule %r/[^\n]+/, Comment::Multiline # free-form meta text
198
206
  rule %r/\n/, Text
199
207
  end
200
208
 
201
209
  # ─────────── triple line: subject phase ───────────
202
210
  state :subject do
203
- rule %r/[ \t]+/, Text
204
- rule(/[^\s.,][^\n,]*?(?=[ \t]*(?:#{DT2}|#{QUAD})|[ \t]*#{CM2}|[ \t]*$|\n|\z)/) do |m|
211
+ rule %r/[#{WS_C}]+/, Text
212
+ rule(/[^#{WSX_C}.,][^\n,]*?(?=[#{WS_C}]*(?:#{DT2}|#{QUAD})|[#{WS_C}]*#{CM2}|[#{WS_C}]*$|\n|\z)/) do |m|
205
213
  slot m, Name::Class
206
214
  goto :after_subject
207
215
  end
@@ -210,7 +218,7 @@ module Rouge
210
218
 
211
219
  # ─────────── after subject (or continuation-line entry) ───────────
212
220
  state :after_subject do
213
- rule %r/[ \t]+/, Text
221
+ rule %r/[#{WS_C}]+/, Text
214
222
  # QuadDot FIRST: '.. ..' is ONE operator, not two.
215
223
  rule(%r/#{QUAD}/) do |m|
216
224
  token Operator, m[0]
@@ -229,8 +237,8 @@ module Rouge
229
237
 
230
238
  # ─────────── relation phase ───────────
231
239
  state :relation do
232
- rule %r/[ \t]+/, Text
233
- rule(/[^\s.,][^\n.,]*?(?=[ \t]*#{DT2}|[ \t]*$|\n|\z)/) do |m|
240
+ rule %r/[#{WS_C}]+/, Text
241
+ rule(/[^#{WSX_C}.,][^\n.,]*?(?=[#{WS_C}]*#{DT2}|[#{WS_C}]*$|\n|\z)/) do |m|
234
242
  slot m, Name::Function
235
243
  goto :after_relation
236
244
  end
@@ -238,7 +246,7 @@ module Rouge
238
246
  end
239
247
 
240
248
  state :after_relation do
241
- rule %r/[ \t]+/, Text
249
+ rule %r/[#{WS_C}]+/, Text
242
250
  rule(%r/#{DT2}/) do |m|
243
251
  token Operator, m[0]
244
252
  goto :object
@@ -254,9 +262,9 @@ module Rouge
254
262
  # Object := TextExcept{NL,CM2} — it MAY contain `..` (20-object-dotdot),
255
263
  # so it runs to end of line or to a `,,`; it does not stop at a DT2.
256
264
  state :object do
257
- rule %r/[ \t]+/, Text
265
+ rule %r/[#{WS_C}]+/, Text
258
266
  rule(%r/#{BLOCK_OPENER}/) { |m| open_block(m) }
259
- rule(/[^\s,][^\n,]*?(?=[ \t]*#{CM2}|[ \t]*$|\n|\z)/) do |m|
267
+ rule(/[^#{WSX_C},][^\n,]*?(?=[#{WS_C}]*#{CM2}|[#{WS_C}]*$|\n|\z)/) do |m|
260
268
  slot m, Literal::String::Symbol
261
269
  goto :after_object
262
270
  end
@@ -264,9 +272,9 @@ module Rouge
264
272
  end
265
273
 
266
274
  state :after_object do
267
- rule %r/[ \t]+/, Text
275
+ rule %r/[#{WS_C}]+/, Text
268
276
  # Trailing `,,` at end-of-line opens a multi-line meta block.
269
- rule(%r/#{CM2}(?=[ \t]*(?:\n|\z))/) do |m|
277
+ rule(%r/#{CM2}(?=[#{WS_C}]*(?:\n|\z))/) do |m|
270
278
  token Comment::Preproc, m[0]
271
279
  goto :meta_block_open
272
280
  end
@@ -278,13 +286,13 @@ module Rouge
278
286
  end
279
287
 
280
288
  state :meta_block_open do
281
- rule %r/[ \t]+/, Text
289
+ rule %r/[#{WS_C}]+/, Text
282
290
  rule(%r/\n/) { |m| token Text, m[0]; goto :meta_block }
283
291
  end
284
292
 
285
293
  # ─────────── typed meta inside a ,, block ───────────
286
294
  state :typed_meta_op do
287
- rule %r/[ \t]+/, Text
295
+ rule %r/[#{WS_C}]+/, Text
288
296
  rule(%r/#{QUAD}/) do |m| # implicit meta relation
289
297
  token Comment::Hashbang, m[0]
290
298
  goto :typed_meta_object
@@ -297,8 +305,8 @@ module Rouge
297
305
  end
298
306
 
299
307
  state :typed_meta_relation do
300
- rule %r/[ \t]+/, Text
301
- rule(/[^\s.,][^\n.,]*?(?=[ \t]*#{DT2}|[ \t]*$|\n|\z)/) do |m|
308
+ rule %r/[#{WS_C}]+/, Text
309
+ rule(/[^#{WSX_C}.,][^\n.,]*?(?=[#{WS_C}]*#{DT2}|[#{WS_C}]*$|\n|\z)/) do |m|
302
310
  slot m, Comment::Doc
303
311
  goto :typed_meta_after_relation
304
312
  end
@@ -306,7 +314,7 @@ module Rouge
306
314
  end
307
315
 
308
316
  state :typed_meta_after_relation do
309
- rule %r/[ \t]+/, Text
317
+ rule %r/[#{WS_C}]+/, Text
310
318
  rule(%r/#{DT2}/) do |m|
311
319
  token Comment::Hashbang, m[0]
312
320
  goto :typed_meta_object
@@ -317,9 +325,9 @@ module Rouge
317
325
  # MetaObjectInBlock := TextExcept{NL} — `;;` is CONTENT here, not a
318
326
  # separator (that is the inline form only). See 28-semicolon-in-meta-block.
319
327
  state :typed_meta_object do
320
- rule %r/[ \t]+/, Text
328
+ rule %r/[#{WS_C}]+/, Text
321
329
  rule(%r/#{BLOCK_OPENER}/) { |m| open_block(m) }
322
- rule(/[^\s][^\n]*?(?=[ \t]*$|\n|\z)/) do |m|
330
+ rule(/[^#{WSX_C}][^\n]*?(?=[#{WS_C}]*$|\n|\z)/) do |m|
323
331
  slot m, Comment::Special
324
332
  goto :typed_meta_after_object
325
333
  end
@@ -327,22 +335,39 @@ module Rouge
327
335
  end
328
336
 
329
337
  state :typed_meta_after_object do
330
- rule %r/[ \t]+/, Text
338
+ rule %r/[#{WS_C}]+/, Text
331
339
  rule(%r/\n/) { |m| token Text, m[0]; goto :meta_block }
332
340
  end
333
341
 
334
342
  # ─────────── inline metadata (after `,,` on a triple line) ───────────
335
343
  state :inline_meta do
336
- # A `..` / `....` right after the `,,` selects the triple form…
337
- rule(/(?=[ \t]*(?:#{DT2}|#{QUAD}))/) { goto :inline_meta_op }
344
+ # A complete `..rel.. value` right after the `,,` selects the pair form.
345
+ # It must be COMPLETE: a lone `..` before the entry ends (at `;;` or EOL)
346
+ # is not an operator, it is literal meta text (41-inline-meta-unclosed-pair).
347
+ # The inner class excludes SC2 so this cannot borrow the `..` of the NEXT entry.
348
+ rule(/(?=[#{WS_C}]*(?:#{QUAD}|#{DT2}(?:(?!#{DT2})(?!#{SC2})[^\n])*?#{DT2}))/) { goto :inline_meta_op }
349
+ # An entry may be EMPTY and still be separated: `,, ;; a note` and a
350
+ # trailing `,, ;;` (40-inline-meta-empty-entry). `;;` separates
351
+ # unconditionally, so it is a separator here too, not meta text.
352
+ rule(%r/#{SC2}/) { |m| token Punctuation, m[0] }
353
+ # …a `!!block` that fills the whole meta-text position opens a verbatim
354
+ # body (block-as-field, 4th position). Must precede the free-text rule,
355
+ # which would otherwise swallow the opener as meta text.
356
+ rule(%r/#{BLOCK_OPENER}/) { |m| open_block(m) }
338
357
  # …anything else is free-form meta text, trimmed of surrounding WS.
339
- rule %r/[ \t]+/, Text
340
- rule(/[^\s][^\n]*?(?=[ \t]*$|\n|\z)/) { |m| token Comment::Multiline, m[0] }
358
+ # MetaTextInline := TextExcept{NL,SC2}: the note ENDS at the next `;;`,
359
+ # exactly as a pair's object does — `;;` separates entries unconditionally
360
+ # (36-inline-meta-notes, 37-inline-meta-mixed).
361
+ rule %r/[#{WS_C}]+/, Text
362
+ rule(/(?!#{SC2})[^#{WSX_C}](?:(?!#{SC2})[^\n])*?(?=[#{WS_C}]*#{SC2}|[#{WS_C}]*$|\n|\z)/) do |m|
363
+ token Comment::Multiline, m[0]
364
+ goto :inline_meta_next
365
+ end
341
366
  rule(%r/\n/) { |m| token Text, m[0]; goto :root }
342
367
  end
343
368
 
344
369
  state :inline_meta_op do
345
- rule %r/[ \t]+/, Text
370
+ rule %r/[#{WS_C}]+/, Text
346
371
  rule(%r/#{QUAD}/) do |m| # implicit meta relation
347
372
  token Comment::Hashbang, m[0]
348
373
  goto :inline_meta_object
@@ -355,8 +380,8 @@ module Rouge
355
380
  end
356
381
 
357
382
  state :inline_meta_relation do
358
- rule %r/[ \t]+/, Text
359
- rule(/[^\s.,][^\n.,]*?(?=[ \t]*#{DT2}|[ \t]*$|\n|\z)/) do |m|
383
+ rule %r/[#{WS_C}]+/, Text
384
+ rule(/[^#{WSX_C}.,][^\n.,]*?(?=[#{WS_C}]*#{DT2}|[#{WS_C}]*$|\n|\z)/) do |m|
360
385
  slot m, Comment::Doc
361
386
  goto :inline_meta_after_relation
362
387
  end
@@ -364,7 +389,7 @@ module Rouge
364
389
  end
365
390
 
366
391
  state :inline_meta_after_relation do
367
- rule %r/[ \t]+/, Text
392
+ rule %r/[#{WS_C}]+/, Text
368
393
  rule(%r/#{DT2}/) do |m|
369
394
  token Comment::Hashbang, m[0]
370
395
  goto :inline_meta_object
@@ -374,21 +399,23 @@ module Rouge
374
399
 
375
400
  # MetaObjectInline := TextExcept{NL,SC2} — stops at `;;`.
376
401
  state :inline_meta_object do
377
- rule %r/[ \t]+/, Text
402
+ rule %r/[#{WS_C}]+/, Text
378
403
  rule(%r/#{BLOCK_OPENER}/) { |m| open_block(m) }
379
- rule(/[^\s;][^\n;]*?(?=[ \t]*#{SC2}|[ \t]*$|\n|\z)/) do |m|
404
+ rule(/[^#{WSX_C};][^\n;]*?(?=[#{WS_C}]*#{SC2}|[#{WS_C}]*$|\n|\z)/) do |m|
380
405
  slot m, Comment::Special
381
406
  goto :inline_meta_next
382
407
  end
383
408
  rule(%r/\n/) { |m| token Text, m[0]; goto :root }
384
409
  end
385
410
 
386
- # `;;` divides several (relation, object) pairs about one triple.
411
+ # `;;` divides the ENTRIES of one triple's inline meta. The next entry may be
412
+ # a pair OR a free-text note, so go back to the :inline_meta dispatcher —
413
+ # :inline_meta_op would accept only the dotted forms.
387
414
  state :inline_meta_next do
388
- rule %r/[ \t]+/, Text
415
+ rule %r/[#{WS_C}]+/, Text
389
416
  rule(%r/#{SC2}/) do |m|
390
417
  token Punctuation, m[0]
391
- goto :inline_meta_op
418
+ goto :inline_meta
392
419
  end
393
420
  rule(%r/\n/) { |m| token Text, m[0]; goto :root }
394
421
  end
data/lib/rouge-ddot.rb ADDED
@@ -0,0 +1,13 @@
1
+ # Entry point for `require 'rouge-ddot'` — the path Bundler takes when the gem
2
+ # is listed in a Jekyll `:jekyll_plugins` group, or under any other
3
+ # `Bundler.require`, which requires a gem by its *name*.
4
+ #
5
+ # Rouge does not auto-discover third-party lexers: a lexer is registered only
6
+ # when its file is loaded. Up to 0.1.2 the gem shipped `lib/rouge/lexers/ddot.rb`
7
+ # alone, so `require 'rouge-ddot'` raised LoadError and every host had to know
8
+ # the internal path and write `require 'rouge/lexers/ddot'` into a plugin file
9
+ # of its own. This file makes the conventional require work.
10
+ #
11
+ # `require_relative` rather than `require` so loading does not depend on this
12
+ # gem's lib directory being on `$LOAD_PATH`. The lexer requires 'rouge' itself.
13
+ require_relative 'rouge/lexers/ddot'
data/rouge-ddot.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'rouge-ddot'
5
- s.version = '0.1.2'
5
+ s.version = '0.1.4'
6
6
  s.summary = 'Rouge lexer for ddot.it'
7
7
  s.description = 'Syntax highlighter for the ddot.it knowledge graph notation. ' \
8
8
  'Plugs into Rouge so any tool that uses Rouge for source ' \
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge-ddot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calpano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-29 00:00:00.000000000 Z
11
+ date: 2026-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rouge
@@ -35,6 +35,7 @@ extra_rdoc_files: []
35
35
  files:
36
36
  - CHANGELOG.md
37
37
  - README.md
38
+ - lib/rouge-ddot.rb
38
39
  - lib/rouge/lexers/ddot.rb
39
40
  - rouge-ddot.gemspec
40
41
  homepage: https://ddot.it