markdownr 0.3.4 → 0.3.6

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: 22318ff27259abe3a66849439a50b48103e0a7d2bea077290fd9b8d4a6329716
4
- data.tar.gz: ce38b5daf5f53c9cf56ae41e1f343bd1db39a1af25a7d04f3fdd1205538ac0bd
3
+ metadata.gz: 01f55ab4612df6c57dc37c6632765cdced4f4a18d19965eca28db4c653c262d6
4
+ data.tar.gz: 3b3cd87a76bd220fc998557978c240aab570705df3b890beba2459b8634feac5
5
5
  SHA512:
6
- metadata.gz: 9996ded48092a440241e924b914a0ad12c054fd02b68e06debaf21cdfbfce6cd74f5f4f5e4657357aff00ae8f3824fc1eb8dc8fb62efdea9153c5ff55ac9b5e0
7
- data.tar.gz: d9bca1a6f76dd9f578af6b135cfac6d0a12626a4a4720661ef2c46bfdd1c06b7228c73a1ee0f008b29f1ce32709e0ecdd5f060435044b17ee1c79c6f55a51044
6
+ metadata.gz: 914d2a3a8bb19aff817d29c2f2bb651ad6175a084faca1c261554eee64daad795e7a7e65a5e3ac1631ea0d1eaad5bca43b5a9751b56f3412734d268c58ee4763
7
+ data.tar.gz: e1afd582d417c7170accd7fbb95b00c896f920a910a4d6ab0c04727834819e5f5fcdb8a58946cae7ef156a8fe552c215ba87b0b17fe8042e798e81c8215f8a23
@@ -189,13 +189,48 @@ module MarkdownServer
189
189
  nil
190
190
  end
191
191
 
192
+ def render_inline_wiki_links(str)
193
+ result = ""
194
+ last_end = 0
195
+ str.scan(/\[\[([^\]]+)\]\]/) do |match|
196
+ raw = match[0]
197
+ m_start = $~.begin(0)
198
+ result += h(str[last_end...m_start])
199
+ target, display = raw.include?("|") ? raw.split("|", 2) : [raw, nil]
200
+ label = display || target
201
+ if target.start_with?("#")
202
+ anchor = target[1..].downcase.gsub(/\s+/, "-").gsub(/[^\w-]/, "")
203
+ result += %(<a class="wiki-link" href="##{h(anchor)}">#{h(label)}</a>)
204
+ else
205
+ resolved = resolve_wiki_link(target)
206
+ if resolved
207
+ result += %(<a class="wiki-link" href="/browse/#{encode_path_component(resolved).gsub('%2F', '/')}">#{h(label)}</a>)
208
+ else
209
+ result += %(<span class="wiki-link broken">#{h(label)}</span>)
210
+ end
211
+ end
212
+ last_end = $~.end(0)
213
+ end
214
+ result += h(str[last_end..])
215
+ result
216
+ end
217
+
192
218
  def render_frontmatter_value(value)
193
219
  case value
194
220
  when Array
195
- value.map { |v| %(<span class="tag">#{h(v)}</span>) }.join(" ")
221
+ value.map { |v|
222
+ str = v.to_s
223
+ if str =~ /\A\[\[([^\]]+)\]\]\z/
224
+ render_inline_wiki_links(str)
225
+ else
226
+ %(<span class="tag">#{h(str)}</span>)
227
+ end
228
+ }.join(" ")
196
229
  when String
197
230
  if value =~ /\Ahttps?:\/\//
198
231
  %(<a href="#{h(value)}" target="_blank" rel="noopener">#{h(value)}</a>)
232
+ elsif value.include?("[[")
233
+ render_inline_wiki_links(value)
199
234
  elsif value.length > 120
200
235
  render_markdown(value)
201
236
  else
@@ -1,3 +1,3 @@
1
1
  module MarkdownServer
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.6"
3
3
  end
data/views/layout.erb CHANGED
@@ -113,14 +113,13 @@
113
113
  }
114
114
 
115
115
  /* Frontmatter */
116
- details.frontmatter {
116
+ div.frontmatter {
117
117
  margin-bottom: 1.5rem;
118
118
  border: 1px solid #e0d8c8;
119
119
  border-radius: 6px;
120
120
  background: #fdfcf9;
121
121
  }
122
- details.frontmatter summary {
123
- cursor: pointer;
122
+ .frontmatter-heading {
124
123
  padding: 0.6rem 1rem;
125
124
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
126
125
  font-size: 0.85rem;
@@ -128,9 +127,6 @@
128
127
  color: #8b6914;
129
128
  background: #f5f0e4;
130
129
  border-radius: 6px 6px 0 0;
131
- user-select: none;
132
- }
133
- details.frontmatter[open] summary {
134
130
  border-bottom: 1px solid #e0d8c8;
135
131
  }
136
132
  .meta-table {
@@ -403,40 +399,6 @@
403
399
  min-width: 0;
404
400
  }
405
401
 
406
- /* Mobile TOC (replaces sidebar) */
407
- .toc-mobile {
408
- display: none;
409
- margin-bottom: 1rem;
410
- border: 1px solid #e0d8c8;
411
- border-radius: 6px;
412
- background: #fdfcf9;
413
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
414
- font-size: 0.82rem;
415
- }
416
- .toc-mobile summary {
417
- cursor: pointer;
418
- padding: 0.5rem 0.8rem;
419
- font-weight: 600;
420
- color: #8b6914;
421
- font-size: 0.8rem;
422
- user-select: none;
423
- }
424
- .toc-mobile ul {
425
- list-style: none;
426
- padding: 0 0.8rem 0.5rem;
427
- margin: 0;
428
- }
429
- .toc-mobile li { margin-bottom: 0.2rem; }
430
- .toc-mobile a {
431
- color: #666;
432
- text-decoration: none;
433
- padding: 0.2rem 0;
434
- display: block;
435
- }
436
- .toc-mobile a:hover { color: #8b6914; }
437
- .toc-mobile .toc-h3 { padding-left: 0.8rem; }
438
- .toc-mobile .toc-h4 { padding-left: 1.4rem; }
439
-
440
402
  /* TOC drawer (swipe-to-reveal on mobile) */
441
403
  .toc-overlay {
442
404
  display: none;
@@ -768,7 +730,6 @@
768
730
 
769
731
  .page-with-toc { display: block; }
770
732
  .toc-sidebar { display: none; }
771
- .toc-mobile { display: block; }
772
733
 
773
734
  .meta-table th, .meta-table td {
774
735
  display: block;
data/views/markdown.erb CHANGED
@@ -11,17 +11,6 @@
11
11
  </div>
12
12
 
13
13
  <% if @has_toc %>
14
- <details class="toc-mobile">
15
- <summary>Table of Contents</summary>
16
- <ul>
17
- <% @toc.each do |entry| %>
18
- <li class="toc-h<%= entry[:level] %>">
19
- <a href="#<%= h(entry[:id]) %>"><%= h(entry[:text]) %></a>
20
- </li>
21
- <% end %>
22
- </ul>
23
- </details>
24
-
25
14
  <button class="toc-fab" id="toc-fab" aria-label="Table of Contents">&#9776;</button>
26
15
  <div class="toc-overlay" id="toc-overlay"></div>
27
16
  <nav class="toc-drawer" id="toc-drawer">
@@ -55,8 +44,8 @@
55
44
 
56
45
  <div class="page-main">
57
46
  <% if @meta && !@meta.empty? %>
58
- <details class="frontmatter" open>
59
- <summary>Metadata</summary>
47
+ <div class="frontmatter">
48
+ <div class="frontmatter-heading">Frontmatter</div>
60
49
  <table class="meta-table">
61
50
  <% @meta.each do |key, value| %>
62
51
  <tr>
@@ -65,7 +54,7 @@
65
54
  </tr>
66
55
  <% end %>
67
56
  </table>
68
- </details>
57
+ </div>
69
58
  <% end %>
70
59
 
71
60
  <div class="md-content" data-file="<%= h(@title) %>">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdownr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dunn