jekyll-zettel 0.7.1 → 0.7.2

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: 1b6da890e13652de4456d21ad0d8f880dff08e04e1a26fab37a6d14cb9ba81bf
4
- data.tar.gz: f7bbaa9687435ed01409d8fde19f71e7ca19020e25c60eb261ba49c3ff938518
3
+ metadata.gz: 6dc8ae8e1d8e9f8b35d24f2a711c77e1cac2bf42a8a7b3dd33d363a23fee5518
4
+ data.tar.gz: 79ef605ddec8abf5b96258b743f5c15772ffcf4c029d32d67dd45c654442fe1f
5
5
  SHA512:
6
- metadata.gz: a4d14c20181512d33bbf3bec360cb9a8ab7e5582d4f8ba38d8cfaee5558d604c3685501ad08db20a3c01c48cdbec8a638f29a9f67d055eaaeba8928f66f14a32
7
- data.tar.gz: 51f95e04a356377ac683e0421c587d263d830acd55d1396be9f10b4cdf2b35fbc4124e52c17b7b99ae30340e54c26ea127ea803e67d39eacefc59d4c541d0132
6
+ metadata.gz: 49dfaef4d13597586bd7c198440e2bf81de9beecf9820b75321925fac61b2dd2390546f4e62510e94de8831eff84402c352e347e14fdf58f742b9ec83b36af9a
7
+ data.tar.gz: 41b2e42ac0ab78a5f8b28f3261aaa502e3d2fd42ddbd22e1b7fdbe0a80ef04600f6ffa022e0fb274d7af8725b6ef65b545277915d59ed80559156606429dae8c
data/CHANGELOG.md CHANGED
@@ -10,3 +10,10 @@
10
10
 
11
11
  - Changed inline citation regex to be compatible with pandoc [@<key>…]
12
12
  - Emit warning when no reference for given _cite-key_ is found
13
+
14
+ ### 0.7.2
15
+
16
+ - Objektkatalog aliases.json mit Mapping von Tag Klarnamen und Alternativen wird jetzt generiert
17
+ - Log-Level beim Serialisieren der Objektkataloge auf debug gestellt
18
+ - Jetzt werden auch Links auf Keywords erkannt und automatisch mit der jeweiligen Glosse verlinkt
19
+ -
@@ -5,10 +5,17 @@ module Kramdown
5
5
 
6
6
  def initialize(source, options)
7
7
  super
8
- @citeproc = Jekyll.sites[0].config['citeproc']
9
- @references = Jekyll.sites[0].data['references']
10
- @zettel = Jekyll.sites[0].data['zettelkasten']
11
- @span_parsers.unshift(:citation)
8
+ site = Jekyll.sites[0]
9
+
10
+ @citeproc = site.config['citeproc']
11
+ @references = site.data['references']
12
+ @keywords = site.data['aliases']
13
+ @zettel = site.data['zettelkasten']
14
+
15
+ @span_parsers.unshift(:citation, :keyword)
16
+
17
+ # So geht’s mit <i>, <b>, <em> und <strong> weiter
18
+ # @span_parsers.delete(:emphasis)
12
19
  end
13
20
 
14
21
  CITATION = /\[@([\w,:]+)(;\s*(.*))?\]/.freeze
@@ -23,7 +30,7 @@ module Kramdown
23
30
  if @references.key?(cite_key)
24
31
  add_citation(cite_key, note, start_line_number)
25
32
  else
26
- add_error(cite_key)
33
+ log_warning('cite-key', cite_key)
27
34
  end
28
35
  end
29
36
 
@@ -31,8 +38,8 @@ module Kramdown
31
38
  citation = @citeproc.render :citation, id: cite_key, locator: note, label: :note
32
39
  attributes = {
33
40
  'href' => "/zettel/#{@references[cite_key]['id']}/",
34
- 'title' => @zettel[@references[cite_key]['id']]['description'],
35
- 'style' => 'box-shadow: initial; border: none;'
41
+ 'title' => @zettel[@references[cite_key]['id']]['title'],
42
+ 'class' => 'citation'
36
43
  }
37
44
  link = Element.new(:a, nil, attributes, location: start_line_number)
38
45
 
@@ -40,12 +47,40 @@ module Kramdown
40
47
  @tree.children << link
41
48
  end
42
49
 
43
- def add_error(cite_key)
44
- Jekyll.logger.warn 'Zettel:', "Missing entry for cite-key @#{cite_key}"
45
- @tree.children << Element.new(:raw, "<span class=\"error\">Missing entry for cite-key @#{cite_key}</span>")
50
+ define_parser(:citation, CITATION, '\[@')
51
+
52
+ KEYWORD = /\[#([\w]+)\]/.freeze
53
+
54
+ def parse_keyword
55
+ start_line_number = @src.current_line_number
56
+ @src.pos += @src.matched_size
57
+
58
+ keyword = @src[1]
59
+ if @keywords.key?(keyword)
60
+ add_keyword(keyword, start_line_number)
61
+ else
62
+ log_warning('keyword', keyword)
63
+ end
46
64
  end
47
65
 
48
- define_parser(:citation, CITATION, '\[@')
66
+ def add_keyword(keyword, start_line_number)
67
+ attributes = {
68
+ 'href' => "/glosse/#{@keywords[keyword]['slug']}/",
69
+ 'title' => @keywords[keyword]['tag'],
70
+ 'class' => 'keyword'
71
+ }
72
+ link = Element.new(:a, nil, attributes, location: start_line_number)
73
+
74
+ link.children << Element.new(:raw, keyword)
75
+ @tree.children << link
76
+ end
77
+
78
+ define_parser(:keyword, KEYWORD, '\[#')
79
+
80
+ def log_warning(catalog, entry)
81
+ Jekyll.logger.warn 'Zettel:', "Missing entry for #{catalog} `#{entry}`"
82
+ @tree.children << Element.new(:raw, "<span class=\"error\">Missing entry for #{catalog} `#{entry}`</span>")
83
+ end
49
84
 
50
85
  end
51
86
  end
@@ -10,17 +10,26 @@ module Jekyll
10
10
 
11
11
  def generate(site)
12
12
  @site = site
13
+
14
+ @site.data['aliases'] = {}
13
15
  @site.data['tags'] = {}
14
16
  @site.data['tag2glosse'] = {}
15
17
 
16
- site.pages.each do |page|
18
+ register
19
+
20
+ write_catalog 'aliases'
21
+ write_catalog 'tags'
22
+ write_catalog 'tag2glosse'
23
+ end
24
+
25
+ def register
26
+ @site.pages.each do |page|
17
27
  next unless SLUG_FORMAT.match?(page.path.to_s)
18
28
 
19
29
  register_tag(page)
30
+ register_tags(page)
31
+ register_aliases(page)
20
32
  end
21
-
22
- write_catalog 'tags'
23
- write_catalog 'tag2glosse'
24
33
  end
25
34
 
26
35
  def register_tag(doc)
@@ -33,17 +42,33 @@ module Jekyll
33
42
  'tags' => doc.data['tags']
34
43
  }
35
44
  doc.data['slug'] = parts[:slug]
36
- register_tags(doc)
45
+ end
46
+
47
+ def register_aliases(doc)
48
+ @site.data['aliases'][doc.data['tag']] = {
49
+ 'slug' => doc.data['slug'],
50
+ 'tag' => doc.data['tag'],
51
+ 'description' => doc.data['description']
52
+ }
53
+ return unless doc.data.key?('aliases')
54
+
55
+ doc.data['aliases'].each do |item|
56
+ @site.data['aliases'][item] = {
57
+ 'slug' => doc.data['slug'],
58
+ 'tag' => doc.data['tag'],
59
+ 'description' => doc.data['description']
60
+ }
61
+ end
37
62
  end
38
63
 
39
64
  def register_tags(doc)
40
65
  return unless doc.data.key?('tags')
41
66
 
42
- doc.data['tags'].each { |tag|
67
+ doc.data['tags'].each do |tag|
43
68
  @site.data['tag2glosse'][tag] = [] unless @site.data['tag2glosse'].key?(tag)
44
69
 
45
70
  @site.data['tag2glosse'][tag] << doc.data['slug']
46
- }
71
+ end
47
72
  end
48
73
  end
49
74
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Zettel
3
- VERSION = '0.7.1'.freeze
3
+ VERSION = '0.7.2'.freeze
4
4
  end
5
5
  end
data/lib/jekyll/zettel.rb CHANGED
@@ -16,7 +16,7 @@ module Jekyll
16
16
  class Error < StandardError; end
17
17
 
18
18
  def write_catalog(object)
19
- Jekyll.logger.info LOG_KEY, "Created references in `#{@site.in_dest_dir('.objects', "#{object}.json")}`"
19
+ Jekyll.logger.debug LOG_KEY, "Created references in `#{@site.in_dest_dir('.objects', "#{object}.json")}`"
20
20
 
21
21
  page = Jekyll::PageWithoutAFile.new(@site, @site.source, '.objects', "#{object}.json").tap do |file|
22
22
  file.content = JSON.pretty_generate(@site.data[object.to_s])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-zettel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Gerzabek
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-21 00:00:00.000000000 Z
11
+ date: 2022-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: citeproc-ruby