Git Product home page Git Product logo

premonition's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

premonition's Issues

Improve unit and integration tests

The test coverage in here is really not that good.

It would be nice to have a test that actually runs the plugin up against different versions of Jekyll and tested the generated output.

Add demo site

Create a jekyll demo repo and publish to github pages.

Collections

I've been trying to use it in a collection, which failed. I'm not very familiar with plugins, but did a hack to get it to work. I thought I'd share here for feedback or to see if there was a better way or if there will be unpleasant side effects.

I had to make two mods:

  1. in hook.rb I changed Hooks.register [:pages], :pre_render do |doc| to Hooks.register [:documents], :pre_render do |doc|. (Update: I actually created multiple loops. One for pages and one for documents. I don't use "posts". This bears further scrutiny)
  2. In processor.rb I changed line references = load_references(content) on line 20 to references = nil and then added references = load_references(content) right above where references would be used (the first call to render_block). This really needs review...I haven't spent anytime to understand what references are or how they work.
  3. I also changed refs << l if l.strip!.match(/^\[.*\]:.*\".*\"$/i) to refs << l if l.strip.length>0 && l.strip.match(/^\[.*\]:.*\".*\"$/i)

Thanks for a great plugin!

More advanced templates

Upon request we have decided to come up with a bit more powerful templating, with support for if-blocks. This is because people might want different styling for blocks with and without a header.

Documentation specifies custom types as an array, instead of hash

In the README.md the following snippet is used in Configuration > Adding custom types:

premonition:
  types:
    - id: custombox
      meta:
        fa-icon: fa-exclamation-circle
    - id: advanced
      template: 'Liquid template goes here'
      default_title: 'MY BLOCK'
      meta:
        fa-icon: fa-exclamation-triangle

This results in a Ruby error (LoadError: types must be a hash).

Instead the following works:

premonition:
  types:
    custombox:
      meta:
        fa-icon: fa-exclamation-circle
    advanced:
      template: 'Liquid template goes here'
      default_title: 'MY BLOCK'
      meta:
        fa-icon: fa-exclamation-triangle

I'd suggest the documentation is updated. If you are busy I am happy to do it for you.

Block title not taken into account when block type is not defined in _config.yml

The current implementation of create_resource does not use the title of a block if the block type is not a "default block", and is not defined in the _config.yml

For instance, if I don't specify any configuration in _config.yml and write the following block:

> test "hello"
> This is a test

Then the following will be output:

<div class="premonition test">
	<div class="fa fa-check-square"></div>
	<div class="content">
		<p>This is a test</p>
	</div>
</div>

Seeing that the default template is:

<div class="premonition {{type}}">
  <div class="fa {{meta.fa-icon}}"></div>
  <div class="content">{% if header %}<p class="header">{{title}}</p>{% endif %}{{content}}</div></div>

I would expect a <p class="header"> to be generated as well, but it isn't. Is this intended behavior?

To fix this in the short term, I'm able to do the following config, which makes the plugin generate a <p class="header">.

premonition:
  types:
    test:
      id: test

Add tests

We should test as much as possible to make sure we don't break stuff in the future.

How to get premonition to work with themes?

Hi all,

first off: I am a complete Jekyll-Noob, but have some experience in HTML, CSS and PHP. I am currently trying out Jekyll and found this awesome plugin.
How do i get premonition to work with a Gem-Theme? When using a theme the SASS-Support is non-existent and trying to shoehorn it in gets rid of the theme. I even tried to modify the installed theme (Adding a stylesheet-link to premonition.css in the ) but that didn't help. Quotes are still displayed as quotes without the premonition-boxes.

I am using the theme "beautiful-jekyll-theme".

I would appreciate every tip! Thanks

Doesn't render in post excerpts

Premonition blocks aren't rendered in Jekyll post excerpts. I've added a minimal bug repro below.

Post:

---
title: This is a test
excerpt_separator: <!--more-->
---

> note ""
> This is a test of Premonition notes

This text is in the excerpt.

<!--more-->

This text is not, it's in the full body.

Page:

{% for post in site.posts %}
<article>
	<h1>{{ post.title }}</h1>
	{{ post.excerpt }}
</article>
{% endfor %}

This outputs the following HTML for the test post:

<article class="post">
	<h1>This is a test</h1>
	<blockquote>
  <p>note “”
This is a test of Premonition notes</p>
</blockquote>
Screenshots

In the full post:

image

In the excerpt:

image

/processor.rb:55:in `block in load_references': undefined method `match' for nil:NilClass (NoMethodError)

I getting this error when build the site

 bundle exec jekyll serve --trace
Configuration file: D:/NOPE/robbinespu.gitlab.io/_config.yml
 Theme Config file: C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/octoflavor-ee4be458ed67/_config.yml
            Source: D:/NOPE/robbinespu.gitlab.io
       Destination: D:/NOPE/robbinespu.gitlab.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       Jekyll Feed: Generating feed for posts
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/premonition-4.0.0/lib/premonition/processor.rb:55:in `block in load_references': undefined method `match' for nil:NilClass (NoMethodError)
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/premonition-4.0.0/lib/premonition/processor.rb:54:in `each_line'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/premonition-4.0.0/lib/premonition/processor.rb:54:in `load_references'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/premonition-4.0.0/lib/premonition/processor.rb:19:in `adder'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/premonition-4.0.0/lib/premonition/hook.rb:29:in `block in generate'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/hooks.rb:99:in `block in trigger'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/hooks.rb:98:in `each'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/hooks.rb:98:in `trigger'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/document.rb:384:in `trigger_hooks'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/renderer.rb:61:in `run'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/site.rb:525:in `render_regenerated'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/site.rb:510:in `block (2 levels) in render_docs'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/site.rb:509:in `each'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/site.rb:509:in `block in render_docs'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/site.rb:508:in `each_value'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/site.rb:508:in `render_docs'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/site.rb:202:in `render'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/site.rb:77:in `process'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/command.rb:28:in `process_site'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/commands/build.rb:65:in `build'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/commands/build.rb:36:in `process'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/command.rb:91:in `each'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bundler/gems/jekyll-18f04c61adc8/exe/jekyll:15:in `<top (required)>'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bin/jekyll:23:in `load'
        from C:/Ruby26-x64/lib/ruby/gems/2.6.0/bin/jekyll:23:in `<main>'

Reference links aren't resolved

Hello, thanks for the neat plugin!

If you include reference links in the premonition container [x][y], where y is defined at the end of the document, the markdown-to-html converter does not render the link; i believe this could be because when rendering the content of the blockquote, only the blockquote text is fed to the markdown converter (i.e. without the link definition). (I use kramdown.)

> warning "not linked"
> This should have been a [link][example].

[example]: https://www.example.com/

yields

<div class="premonition warning">
 <div class="fa fa-exclamation-circle"></div>
 <div class="content">
  <p class="header">not linked</p>
  <p>This should have been a [link][example].</p>
 </div>
</div>

Workaround: don't use reference links in the premonition containers; but this requires our authors to know about this limitation. Perhaps there are ways to make the markdown converter aware of some wider context?

Premonition render in included markdown file

I have the following markdown code in a page...

---
layout: default
title: blah
permalink: /blah/
redirect_from: "/"
order: 2
---

{% include blah1.md %}

File _includes/blah.md contains...

# Title1

## Subtitle1

> error ""
> Be aware

The premonition doesn't render. The page just renders as error “” Be aware

I need these includes to be here since we have many pages that converge to the same set of sections.

Add support for Kramdown?

I would be fairly easy to add support for Kramdown. Let us know if you are interested in contributing to that.

Admonitions not on first column of line

Seems that if the admonition is not defined as the first line for each line, it's not recognized.

For example, if you have an ordered list and want to use premotion there, the formatting is ignored and the text is seen as paragraph like:

info “Information” To upload

image

premonition not working with windows line separator

When the file uses \r\n as line separator, the code will be rendered as usual block-quote instead of a note. Not every editor lets you choose the line separator, so it would be nice if the plugin supports the windows line separator, too

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.