diff --git a/Gemfile b/Gemfile index e4ff462..048f21a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,8 @@ source 'https://rubygems.org' gem 'jekyll-paginate' -gem 'jekyll-paginate' gem 'kramdown' gem 'redcarpet' gem 'rouge' -gem 'pygments.rb' \ No newline at end of file +gem 'pygments.rb' +gem 'text-hyphen' +gem 'nokogiri' \ No newline at end of file diff --git a/_config.yml b/_config.yml index 074b0ca..99b5b16 100644 --- a/_config.yml +++ b/_config.yml @@ -5,6 +5,7 @@ asset_prefix: /asset static_prefix: /static # variables +language: nl title: Rik @ St Andrews author: Rik Veenboer email: rik.veenboer@gmail.com diff --git a/_includes/caption.html b/_includes/caption.html index c8e0fb5..e47bf3f 100644 --- a/_includes/caption.html +++ b/_includes/caption.html @@ -1,6 +1,6 @@
{% if include.text %} - {{ include.text|markdownify }} + {{ include.text | markdownify | hyphenate }} {% endif %}
\ No newline at end of file diff --git a/_includes/disqus.html b/_includes/disqus.html index 5a0948d..1335846 100644 --- a/_includes/disqus.html +++ b/_includes/disqus.html @@ -5,7 +5,6 @@ var disqus_identifier = '{{ page.id }}'; var disqus_title = '{{ page.title|replace:"'":"\\'" }}'; var disqus_url = '{{ site.absolute }}{{ page.url }}'; - (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; diff --git a/_includes/post.html b/_includes/post.html deleted file mode 100644 index ab7a496..0000000 --- a/_includes/post.html +++ /dev/null @@ -1,22 +0,0 @@ -
-
-
- {% if post.date %} - - {% endif %} - {% if post.location %} - map - {% endif %} - {% if post.code %} - code - {% endif %} -
-

- {{ post.title }} - -

-
-
- {{ post.content }} -
-
diff --git a/_includes/post_detail.html b/_includes/post_detail.html index 073b141..7cf5d37 100644 --- a/_includes/post_detail.html +++ b/_includes/post_detail.html @@ -17,16 +17,16 @@
- {{ post.excerpt }} + {{ post.excerpt | hyphenate }} {% capture content_words %} {{ post.content | number_of_words }} - {% endcapture %} + {% endcapture %} {% capture excerpt_words %} {{ post.excerpt | number_of_words }} - {% endcapture %} + {% endcapture %} {% if excerpt_words != content_words %}

- {{ site.read_more }} + {{ site.read_more }}

{% endif %}
diff --git a/_layouts/post.html b/_layouts/post.html index fe390e7..4b2c6ef 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -21,7 +21,7 @@ {% endif %}
- {{ content }} + {{ content | hyphenate }}
{% if false != page.comments %} {% include disqus.html %} diff --git a/_plugins/hyphenate.rb b/_plugins/hyphenate.rb new file mode 100644 index 0000000..b443462 --- /dev/null +++ b/_plugins/hyphenate.rb @@ -0,0 +1,41 @@ +# adapted from +# - https://raw.githubusercontent.com/aucor/jekyll-plugins/master/hyphenate.rb + +require 'nokogiri' +require 'text/hyphen' + +module Jekyll + module HyphenateFilter + def hyphenate(content) + # Initialize Hyphen + hh = Text::Hyphen.new(:language => @context.registers[:site].config['language'], :left => 2, :right => 2) + + # Parse html with Nokogiri + fragment = Nokogiri::HTML::DocumentFragment.parse(content) + + # Grab the html as it is + html = fragment.inner_html + + # Loop through every paragraph + fragment.css('p').each do |p| + h = p.content + + # Loop through every word + p.content.split.each do |w| + # Replace original word with a hyphenated one unless it is the last word in a paragraph + if w != p.content.split.last + h = h.gsub(w, hh.visualize(w, '­')) + end + end + + # Replace original paragraph with a hyphenated one + html = html.gsub(p, h) + end + + # Return hyphenated html + html + end + end +end + +Liquid::Template.register_filter(Jekyll::HyphenateFilter) \ No newline at end of file diff --git a/index.html b/index.html index 131fdf8..d35979a 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ tags: blog scotland chemistry phd ---

- In dit blog houd ik jullie zo goed mogelijk op de hoogte van mijn belevenissen in St Andrews, Schotland. Daar ben ik in november 2013 begonnen aan een vierjarige PhD in de scheikunde, met als uiteindelijk doel het halen van de doctor titel. Nostalgicie zijn misschien verknocht aan de oude versie van dit blog. + In dit blog houd ik jullie zo goed mogelijk op de hoogte van mijn belevenissen in St Andrews, Schotland. Daar ben ik in november 2013 begonnen aan een vierjarige PhD in de scheikunde, met als uiteindelijk doel het halen van de doctor titel. Om het voor iedereen leuk te houden zal ik niet uitweiden over ontwikkelingen op academisch gebied. Nostalgicie zijn misschien verknocht aan de oude versie van dit blog.