Commit 1300ce70 authored by Sylvester Keil's avatar Sylvester Keil

added block quotes

parent 9c258e1c
......@@ -153,6 +153,27 @@ following blog post:
{% bibliography %}
For longer quotes, Jekyll-Scholar provides a `quote` tag:
{% quote derrida:purveyor %}
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor.
Lorem ipsum dolor sit amet, consectetur adipisicing.
{% endquote %}
For example, this could be rendered as:
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,<br/>
sed do eiusmod tempor.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing.</p>
<cite>
<a href="#derrida:purveyor">(Derrida, 1975)</a>
</cite>
</blockquote>
### Detail Pages
If your layouts directory contains a layout file for bibliography details
......
......@@ -2,7 +2,7 @@ Feature: Citations
As a scholar who likes to blog
I want to reference cool papers and books from my bibliography
@tags
@tags @cite
Scenario: A Simple Citation
Given I have a scholar configuration with:
| key | value |
......@@ -29,7 +29,7 @@ Feature: Citations
And the "_site/scholar.html" file should exist
And I should see "Flanagan" in "_site/scholar.html"
@tags
@tags @cite
Scenario: Missing references
Given I have a scholar configuration with:
| key | value |
......@@ -55,3 +55,32 @@ Feature: Citations
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "missing reference" in "_site/scholar.html"
@tags @quote
Scenario: A Simple Block-Quote
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
| bibliography | my_references |
And I have a "_bibliography" directory
And I have a file "_bibliography/my_references.bib":
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
"""
And I have a page "scholar.html":
"""
---
---
{% quote ruby %}
We <3 Ruby
{% endquote %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "<blockquote><p>We <3 Ruby</p><cite><a .*#ruby.+\(Flanagan" in "_site/scholar.html"
......@@ -11,4 +11,5 @@ require 'jekyll/scholar/utilities'
require 'jekyll/scholar/converters/bibtex'
require 'jekyll/scholar/tags/bibliography'
require 'jekyll/scholar/tags/cite'
require 'jekyll/scholar/tags/quote'
require 'jekyll/scholar/generators/details'
......@@ -4,7 +4,7 @@ module Jekyll
class CiteTag < Liquid::Tag
include Scholar::Utilities
attr_reader :key, :pages, :config
attr_reader :key, :pages
def initialize(tag_name, arguments, tokens)
super
......@@ -15,17 +15,7 @@ module Jekyll
def render(context)
set_context_to context
entry = bibliography[key]
if entry
citation = CiteProc.process entry.to_citeproc, :style => config['style'],
:locale => config['locale'], :format => 'html', :mode => :citation
link_to "##{entry.key}", citation
else
"(missing reference)"
end
cite key
end
end
......
module Jekyll
class Scholar
class QuoteTag < Liquid::Block
include Scholar::Utilities
attr_reader :key, :pages
def initialize(tag_name, arguments, tokens)
super
@config = Scholar.defaults.dup
@key = arguments.strip.split(/\s+/)[0]
end
def render(context)
set_context_to context
quote = super.strip.gsub(/\n\n/, '</p><p>').gsub(/\n/, '<br/>')
quote = content_tag :p, quote
citation = cite(key)
quote << content_tag(:cite, citation)
content_tag :blockquote, quote
end
end
end
end
Liquid::Template.register_tag('quote', Jekyll::Scholar::QuoteTag)
\ No newline at end of file
......@@ -53,14 +53,31 @@ module Jekyll
[name, 'html'].join('.')
end
def details_link_for(entry, base = site.config['baseurl'] || '/')
[base, details_path, details_file_for(entry)].compact.join('/')
def details_link_for(entry, base = base_url)
[base, details_path, details_file_for(entry)].join('/')
end
def base_url
@base_url ||= site.config['baseurl'] || nil
end
def details_path
config['details_dir']
end
def cite(key)
entry = bibliography[key]
if bibliography.key?(key)
citation = CiteProc.process entry.to_citeproc, :style => config['style'],
:locale => config['locale'], :format => 'html', :mode => :citation
link_to "##{entry.key}", citation.join
else
"(missing reference)"
end
end
def content_tag(name, content_or_attributes, attributes = {})
if content_or_attributes.is_a?(Hash)
content, attributes = nil, content_or_attributes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment