jekyll-zettel 0.6.10 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/jekyll-zettel.gemspec +1 -0
- data/lib/jekyll/zettel/citedown.rb +125 -0
- data/lib/jekyll/zettel/reference.rb +3 -2
- data/lib/jekyll/zettel/references.rb +21 -5
- data/lib/jekyll/zettel/tags.rb +32 -7
- data/lib/jekyll/zettel/version.rb +1 -1
- data/lib/jekyll/zettel.rb +4 -1
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dc8ae8e1d8e9f8b35d24f2a711c77e1cac2bf42a8a7b3dd33d363a23fee5518
|
4
|
+
data.tar.gz: 79ef605ddec8abf5b96258b743f5c15772ffcf4c029d32d67dd45c654442fe1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49dfaef4d13597586bd7c198440e2bf81de9beecf9820b75321925fac61b2dd2390546f4e62510e94de8831eff84402c352e347e14fdf58f742b9ec83b36af9a
|
7
|
+
data.tar.gz: 41b2e42ac0ab78a5f8b28f3261aaa502e3d2fd42ddbd22e1b7fdbe0a80ef04600f6ffa022e0fb274d7af8725b6ef65b545277915d59ed80559156606429dae8c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
1
|
## 0.1.0
|
2
2
|
|
3
3
|
- Initial Import
|
4
|
+
|
5
|
+
## 0.7.x
|
6
|
+
|
7
|
+
- Added inline citations
|
8
|
+
|
9
|
+
### 0.7.1
|
10
|
+
|
11
|
+
- Changed inline citation regex to be compatible with pandoc [@<key>…]
|
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
|
+
-
|
data/jekyll-zettel.gemspec
CHANGED
@@ -31,4 +31,5 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_runtime_dependency 'csl-styles', '>= 2.0', '< 3.0'
|
32
32
|
spec.add_runtime_dependency 'fileutils', '>= 1.4', '< 2.0'
|
33
33
|
spec.add_runtime_dependency 'jekyll', '>= 3.8', '< 5.0'
|
34
|
+
spec.add_runtime_dependency 'kramdown', '>=2.0', '< 3.0'
|
34
35
|
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module Kramdown
|
2
|
+
module Parser
|
3
|
+
# Kramdown Parser mit inline Zitationen
|
4
|
+
class Citedown < Kramdown
|
5
|
+
|
6
|
+
def initialize(source, options)
|
7
|
+
super
|
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)
|
19
|
+
end
|
20
|
+
|
21
|
+
CITATION = /\[@([\w,:]+)(;\s*(.*))?\]/.freeze
|
22
|
+
|
23
|
+
def parse_citation
|
24
|
+
start_line_number = @src.current_line_number
|
25
|
+
@src.pos += @src.matched_size
|
26
|
+
|
27
|
+
cite_key = @src[1]
|
28
|
+
note = @src[3]
|
29
|
+
|
30
|
+
if @references.key?(cite_key)
|
31
|
+
add_citation(cite_key, note, start_line_number)
|
32
|
+
else
|
33
|
+
log_warning('cite-key', cite_key)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_citation(cite_key, note, start_line_number)
|
38
|
+
citation = @citeproc.render :citation, id: cite_key, locator: note, label: :note
|
39
|
+
attributes = {
|
40
|
+
'href' => "/zettel/#{@references[cite_key]['id']}/",
|
41
|
+
'title' => @zettel[@references[cite_key]['id']]['title'],
|
42
|
+
'class' => 'citation'
|
43
|
+
}
|
44
|
+
link = Element.new(:a, nil, attributes, location: start_line_number)
|
45
|
+
|
46
|
+
link.children << Element.new(:raw, "<sup>#{citation}</sup>")
|
47
|
+
@tree.children << link
|
48
|
+
end
|
49
|
+
|
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
|
64
|
+
end
|
65
|
+
|
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
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
# options => {
|
89
|
+
# :template => "",
|
90
|
+
# :auto_ids => true,
|
91
|
+
# :auto_id_stripping => false,
|
92
|
+
# :auto_id_prefix => "",
|
93
|
+
# :transliterated_header_ids => false,
|
94
|
+
# :parse_block_html => true,
|
95
|
+
# :parse_span_html => true,
|
96
|
+
# :html_to_native => false,
|
97
|
+
# :link_defs => {},
|
98
|
+
# :footnote_nr => 1,
|
99
|
+
# :entity_output => :as_char,
|
100
|
+
# :toc_levels => [1, 2, 3, 4, 5, 6],
|
101
|
+
# :line_width => 72,
|
102
|
+
# :latex_headers => ["section", "subsection", "subsubsection", "paragraph", "subparagraph", "subparagraph"],
|
103
|
+
# :smart_quotes => ["lsquo", "rsquo", "ldquo", "rdquo"],
|
104
|
+
# :typographic_symbols => {},
|
105
|
+
# :remove_block_html_tags => true,
|
106
|
+
# :remove_span_html_tags => false,
|
107
|
+
# :header_offset => 0,
|
108
|
+
# :syntax_highlighter => :rouge,
|
109
|
+
# :syntax_highlighter_opts => {
|
110
|
+
# :default_lang => "plaintext",
|
111
|
+
# :guess_lang => true
|
112
|
+
# },
|
113
|
+
# :math_engine => :mathjax,
|
114
|
+
# :math_engine_opts => {},
|
115
|
+
# :footnote_backlink => "▲",
|
116
|
+
# :footnote_backlink_inline => false,
|
117
|
+
# :footnote_prefix => "",
|
118
|
+
# :remove_line_breaks_for_cjk => false,
|
119
|
+
# :forbidden_inline_options => [:template],
|
120
|
+
# :input => "Citedown",
|
121
|
+
# :hard_wrap => false,
|
122
|
+
# :guess_lang => true,
|
123
|
+
# :show_warnings => false,
|
124
|
+
# :coderay => {}
|
125
|
+
# }
|
@@ -4,9 +4,10 @@ module Jekyll
|
|
4
4
|
class Reference < Liquid::Tag
|
5
5
|
|
6
6
|
def render(context)
|
7
|
-
|
7
|
+
doc = context.registers[:page]
|
8
|
+
return unless doc.key?('reference') && doc['reference'].key?('citation-key')
|
8
9
|
|
9
|
-
context.registers[:site].config['citeproc'].render :bibliography, id:
|
10
|
+
context.registers[:site].config['citeproc'].render :bibliography, id: doc['reference']['citation-key']
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -42,13 +42,29 @@ module Jekyll
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def register_reference(doc, file)
|
45
|
-
if doc.data['reference'].include?('id')
|
46
|
-
|
45
|
+
if doc.data['reference'].include?('citation-key') && doc.data['reference'].include?('id')
|
46
|
+
#
|
47
|
+
# Citeproc erwartet sich eine id, die dem citation-key entspricht,
|
48
|
+
# in den References (references.json) brauche ich jedoch die id des
|
49
|
+
# Zettels, um in diversen Anwendungen darauf referenzieren zu können.
|
50
|
+
# Also wird die id des Zettels zwischengespeichert und für die
|
51
|
+
# Registrierung bei Citeproc durch den citation-key ersetzt.
|
52
|
+
#
|
53
|
+
# ACHTUNG!
|
54
|
+
# Beim Übernehmen einer Reference aus Citavi muss die id manuell auf
|
55
|
+
# die id des Zettels gesetzt werden!
|
56
|
+
#
|
57
|
+
# store
|
58
|
+
id = doc.data['reference']['id']
|
59
|
+
@site.data['references'][doc.data['reference']['citation-key']] = doc.data['reference']
|
60
|
+
# set id for Citeproc and register Item
|
61
|
+
doc.data['reference']['id'] = doc.data['reference']['citation-key']
|
47
62
|
@site.config['citeproc'].register doc.data['reference']
|
48
|
-
|
63
|
+
# restore
|
64
|
+
doc.data['reference']['id'] = id
|
49
65
|
else
|
50
|
-
Jekyll.logger.warn LOG_KEY, 'missing property @
|
51
|
-
Jekyll.logger.warn '',
|
66
|
+
Jekyll.logger.warn LOG_KEY, 'missing property @citation-key'
|
67
|
+
Jekyll.logger.warn '', file
|
52
68
|
end
|
53
69
|
end
|
54
70
|
|
data/lib/jekyll/zettel/tags.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
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
|
data/lib/jekyll/zettel.rb
CHANGED
@@ -3,6 +3,7 @@ require 'securerandom'
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'citeproc'
|
5
5
|
require 'csl/styles'
|
6
|
+
require 'kramdown/parser/kramdown'
|
6
7
|
|
7
8
|
module Jekyll
|
8
9
|
# Jekyll zettel to your service
|
@@ -15,7 +16,7 @@ module Jekyll
|
|
15
16
|
class Error < StandardError; end
|
16
17
|
|
17
18
|
def write_catalog(object)
|
18
|
-
Jekyll.logger.
|
19
|
+
Jekyll.logger.debug LOG_KEY, "Created references in `#{@site.in_dest_dir('.objects', "#{object}.json")}`"
|
19
20
|
|
20
21
|
page = Jekyll::PageWithoutAFile.new(@site, @site.source, '.objects', "#{object}.json").tap do |file|
|
21
22
|
file.content = JSON.pretty_generate(@site.data[object.to_s])
|
@@ -89,6 +90,7 @@ end
|
|
89
90
|
require 'jekyll/commands/scaffold'
|
90
91
|
require 'jekyll/zettel/akteur'
|
91
92
|
require 'jekyll/zettel/blatt'
|
93
|
+
require 'jekyll/zettel/citedown'
|
92
94
|
require 'jekyll/zettel/globals'
|
93
95
|
require 'jekyll/zettel/glosse'
|
94
96
|
require 'jekyll/zettel/reference'
|
@@ -98,3 +100,4 @@ require 'jekyll/zettel/timeline'
|
|
98
100
|
require 'jekyll/zettel/zeitleiste'
|
99
101
|
require 'jekyll/zettel/zettel'
|
100
102
|
require 'jekyll/zettel/zettelkasten'
|
103
|
+
|
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.
|
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-
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citeproc-ruby
|
@@ -90,6 +90,26 @@ dependencies:
|
|
90
90
|
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '5.0'
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: kramdown
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '2.0'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.0'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.0'
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '3.0'
|
93
113
|
description: Coming soon…
|
94
114
|
email:
|
95
115
|
- michael.gerzabek@gmail.com
|
@@ -115,6 +135,7 @@ files:
|
|
115
135
|
- lib/jekyll/zettel.rb
|
116
136
|
- lib/jekyll/zettel/akteur.rb
|
117
137
|
- lib/jekyll/zettel/blatt.rb
|
138
|
+
- lib/jekyll/zettel/citedown.rb
|
118
139
|
- lib/jekyll/zettel/globals.rb
|
119
140
|
- lib/jekyll/zettel/glosse.rb
|
120
141
|
- lib/jekyll/zettel/reference.rb
|