jekyll-spaceship 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +18 -1
- data/jekyll-spaceship.gemspec +2 -0
- data/lib/jekyll-spaceship.rb +2 -6
- data/lib/jekyll-spaceship/cores/config.rb +65 -0
- data/lib/jekyll-spaceship/cores/logger.rb +7 -4
- data/lib/jekyll-spaceship/cores/manager.rb +11 -10
- data/lib/jekyll-spaceship/cores/processor.rb +23 -0
- data/lib/jekyll-spaceship/cores/register.rb +1 -1
- data/lib/jekyll-spaceship/processors/emoji-processor.rb +14 -43
- data/lib/jekyll-spaceship/processors/mathjax-processor.rb +2 -7
- data/lib/jekyll-spaceship/processors/plantuml-processor.rb +23 -10
- data/lib/jekyll-spaceship/processors/table-processor.rb +6 -5
- data/lib/jekyll-spaceship/processors/video-processor.rb +1 -0
- data/lib/jekyll-spaceship/utils/.keep +0 -0
- data/lib/jekyll-spaceship/version.rb +1 -1
- metadata +32 -3
- data/lib/jekyll-spaceship/utils/plantuml/plantuml.jar +0 -0
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2abfd1cf82bdc535d470ecc9e5397dca1e1e82456897fdf7ee2035bb62ae19f4
         | 
| 4 | 
            +
              data.tar.gz: bab5a4df56d4ac49a1f9b2838b9a05d1ef5e720e9a0cb7838cc9db23a0a211a0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ddb2c1c75889ada85e605ee06db3f67aa11392c2774d8db3115ced6fafecd4dcdb3d60bef85677502f511926cfaf358227bfe12aad10d622a0726e7e9d3802a2
         | 
| 7 | 
            +
              data.tar.gz: 00c0d8b4656c3c14db2a78742033cb7cb9d0b41d86bce8a45b7f332175ce1ec24a55aa32c3bf811d506b4ba07a354ae391ac46f06f71d2e5a790f0025648eae1
         | 
    
        data/.travis.yml
    CHANGED
    
    | @@ -27,6 +27,8 @@ deploy: | |
| 27 27 | 
             
                secure: AqjHemFJsIxFuudjWzYbUGBpA5wpAB9Ate6oDZMGMnpaoSD2VgfkBDklyFfEh5uuHrh+rU6U9MPv4wknXVIV7gTTY18ATgzciLa+JCVjhAaSoPGSkORT15/kKpVp4IXIoEytj5T9D+8Wc8czd/B1+lMGGu7n7d7gMvg0HsjOLzJtAOYPrRUTaTXDLeIA+rPnsI1IzbvfHzcZvuD70XkBJWN9kiu0djlI6o51XQNumWMJrFAD/NDD3h3tZ0kkI0TalAYbWVRkZ/ZeABKAod3IRAXGt4L2MM2eYqE5KaXb/GE5wISib3I/iTCjjwrNlM+wM9a+mnOkC+elaCJm1LENqP5Ocy9wbOLYmC8i1VpPDXm2bskbj32oy1wf5zeQUf6bnPB+wDmwgCirYb7z2jQlV4BzRRkDCTftfNTa8FIi03kf+i7phjHuj18j/JC3Ww1ApRq71JAuqEnUY0wBaaN3M5abrJsYOxCRnYVPcBn/w8gfkXuhv9xvDG2OgwqIjDiECPjmbeK8Apo9kgKSrfjBQ43q62Ore6SuVCS+PZOOxVnHmfphfT4xc1atyVeMLkSvnWOa/sWTwgOSXqt1TYAEEhb734AsfXeRMzxU/LN1Y4nZ0otuEv+HVHA/XeHLA1Skq9vHhtZaORhJ58Jmwv5oMwA8KC/wPrn0gGtSBPe8zxw=
         | 
| 28 28 | 
             
              gem: jekyll-spaceship
         | 
| 29 29 | 
             
              on:
         | 
| 30 | 
            +
                rvm: 2.3
         | 
| 30 31 | 
             
                tags: true
         | 
| 31 32 | 
             
                repo: jeffreytse/jekyll-spaceship
         | 
| 33 | 
            +
              edge: true
         | 
| 32 34 | 
             
              cleanup: false
         | 
    
        data/README.md
    CHANGED
    
    | @@ -82,6 +82,13 @@ | |
| 82 82 |  | 
| 83 83 | 
             
            A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji, youtube, vimeo, dailymotion, etc.
         | 
| 84 84 |  | 
| 85 | 
            +
            <p align="center">
         | 
| 86 | 
            +
                <img alt="Jekyll Spaceship Demo" src="https://user-images.githubusercontent.com/9413601/82250463-15451780-997e-11ea-8809-f411586d9508.gif" alt="Donate (Ko-fi)" />
         | 
| 87 | 
            +
            </p>
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            **💡 Tip:** I hope you enjoy using this plugin. If you like this project, **a little star** for it is your way make a clear statement: **My work is valued**. I would appreciate your support! _Thank you!_
         | 
| 90 | 
            +
             | 
| 91 | 
            +
             | 
| 85 92 | 
             
            ## Table of Contents
         | 
| 86 93 |  | 
| 87 94 | 
             
            - [Requirements](#requirements)
         | 
| @@ -121,13 +128,15 @@ Add jekyll-spaceship plugin in your site's `Gemfile`, and run `bundle install`. | |
| 121 128 | 
             
            gem 'jekyll-spaceship'
         | 
| 122 129 | 
             
            ```
         | 
| 123 130 |  | 
| 124 | 
            -
            Add jekyll-spaceship to the ` | 
| 131 | 
            +
            Add jekyll-spaceship to the `plugins:` section in your site's `_config.yml`.
         | 
| 125 132 |  | 
| 126 133 | 
             
            ```yml
         | 
| 127 134 | 
             
            plugins:
         | 
| 128 135 | 
             
              - jekyll-spaceship
         | 
| 129 136 | 
             
            ```
         | 
| 130 137 |  | 
| 138 | 
            +
            **💡 Tip:** Note that GitHub Pages runs in `safe` mode and only allows [a set of whitelisted plugins](https://pages.github.com/versions/). To use the gem in GitHub Pages, you need to build locally or use CI (e.g. [travis](https://travis-ci.org/), [github workflow](https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow)) and deploy to your `gh-pages` branch. [Click here for more information.](https://jekyllrb.com/docs/continuous-integration/github-actions/) (e.g. [https://github.com/jeffreytse/jekyll-jeffreytse-blog](https://github.com/jeffreytse/jekyll-jeffreytse-blog))
         | 
| 139 | 
            +
             | 
| 131 140 | 
             
            ## Usage
         | 
| 132 141 |  | 
| 133 142 | 
             
            ### 1. Table Usage
         | 
| @@ -492,6 +501,10 @@ $ 2^{\frac{n-1}{3}} $ | |
| 492 501 | 
             
            $ \int\_a^b f(x)\,dx. $
         | 
| 493 502 | 
             
            ```
         | 
| 494 503 |  | 
| 504 | 
            +
            Code above would be parsed as:
         | 
| 505 | 
            +
             | 
| 506 | 
            +
            <image alt="MathJax Expression" height="180" src="https://user-images.githubusercontent.com/9413601/82814245-5a5ed180-9ec9-11ea-9d5b-fba303c627ac.png"></image>
         | 
| 507 | 
            +
             | 
| 495 508 | 
             
            ### 3. PlantUML Usage
         | 
| 496 509 |  | 
| 497 510 | 
             
            [PlantUML](http://plantuml.sourceforge.net/) is a component that allows to quickly write:
         | 
| @@ -520,6 +533,10 @@ Bob -> Alice : hello | |
| 520 533 | 
             
            @enduml
         | 
| 521 534 | 
             
            ```
         | 
| 522 535 |  | 
| 536 | 
            +
            Code above would be parsed as:
         | 
| 537 | 
            +
             | 
| 538 | 
            +
            
         | 
| 539 | 
            +
             | 
| 523 540 | 
             
            ### 4. Video Usage
         | 
| 524 541 |  | 
| 525 542 | 
             
            How often did you find yourself googling "**How to embed a video in markdown?**"
         | 
    
        data/jekyll-spaceship.gemspec
    CHANGED
    
    | @@ -20,6 +20,8 @@ Gem::Specification.new do |spec| | |
| 20 20 |  | 
| 21 21 | 
             
              spec.add_dependency "jekyll", ">= 3.6", "< 5.0"
         | 
| 22 22 | 
             
              spec.add_dependency "nokogiri", "~> 1.6"
         | 
| 23 | 
            +
              spec.add_dependency "gemoji", "~> 3.0"
         | 
| 24 | 
            +
              spec.add_dependency "rainbow", "~> 3.0"
         | 
| 23 25 |  | 
| 24 26 | 
             
              spec.add_development_dependency "bundler"
         | 
| 25 27 | 
             
              spec.add_development_dependency "rake", "~> 12.0"
         | 
    
        data/lib/jekyll-spaceship.rb
    CHANGED
    
    | @@ -1,16 +1,12 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'jekyll-spaceship/cores/logger'
         | 
| 4 | 
            +
            require 'jekyll-spaceship/cores/config'
         | 
| 4 5 | 
             
            require 'jekyll-spaceship/cores/manager'
         | 
| 5 6 | 
             
            require 'jekyll-spaceship/cores/processor'
         | 
| 6 7 | 
             
            require 'jekyll-spaceship/cores/register'
         | 
| 7 8 |  | 
| 8 9 | 
             
            module Jekyll::Spaceship
         | 
| 9 10 | 
             
              Logger.display_info
         | 
| 10 | 
            -
               | 
| 11 | 
            -
              Register.use 'mathjax-processor'
         | 
| 12 | 
            -
              Register.use 'plantuml-processor'
         | 
| 13 | 
            -
              Register.use 'polyfill-processor'
         | 
| 14 | 
            -
              Register.use 'video-processor'
         | 
| 15 | 
            -
              Register.use 'emoji-processor'
         | 
| 11 | 
            +
              Config.load
         | 
| 16 12 | 
             
            end
         | 
| @@ -0,0 +1,65 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'yaml'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Jekyll::Spaceship
         | 
| 6 | 
            +
              class Config
         | 
| 7 | 
            +
                CONFIG_NAME = 'jekyll-spaceship'
         | 
| 8 | 
            +
                DEFAULT_CONFIG = {
         | 
| 9 | 
            +
                  'processors' => [
         | 
| 10 | 
            +
                    'table-processor',
         | 
| 11 | 
            +
                    'mathjax-processor',
         | 
| 12 | 
            +
                    'plantuml-processor',
         | 
| 13 | 
            +
                    'polyfill-processor',
         | 
| 14 | 
            +
                    'video-processor',
         | 
| 15 | 
            +
                    'emoji-processor'
         | 
| 16 | 
            +
                  ],
         | 
| 17 | 
            +
                  'mathjax-processor' => {
         | 
| 18 | 
            +
                    'src' => '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
         | 
| 19 | 
            +
                    'config' => {
         | 
| 20 | 
            +
                      'tex2jax' => { 'inlineMath' => [['$','$'], ['\\(','\\)']] }
         | 
| 21 | 
            +
                    }
         | 
| 22 | 
            +
                  },
         | 
| 23 | 
            +
                  'plantuml-processor' => {
         | 
| 24 | 
            +
                    'src' => 'http://www.plantuml.com/plantuml/png/'
         | 
| 25 | 
            +
                  },
         | 
| 26 | 
            +
                  'emoji-processor' => {
         | 
| 27 | 
            +
                    'src' => 'https://github.githubassets.com/images/icons/emoji/'
         | 
| 28 | 
            +
                  }
         | 
| 29 | 
            +
                }
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                @@store = {}
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def self.deep_merge(first, second)
         | 
| 34 | 
            +
                  merger = proc do |_, f, s|
         | 
| 35 | 
            +
                    if Hash === f && Hash === s
         | 
| 36 | 
            +
                      f.merge(s, &merger)
         | 
| 37 | 
            +
                    elsif Array === f && Array === s
         | 
| 38 | 
            +
                      s || f
         | 
| 39 | 
            +
                    else
         | 
| 40 | 
            +
                      [:undefined, nil, :nil].include?(s) ? f : s
         | 
| 41 | 
            +
                    end
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                  first.merge(second.to_h, &merger)
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                def self.store(section)
         | 
| 47 | 
            +
                  @@store[section]
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                def self.load(filename = '_config.yml')
         | 
| 51 | 
            +
                  config = deep_merge(
         | 
| 52 | 
            +
                    { CONFIG_NAME => DEFAULT_CONFIG },
         | 
| 53 | 
            +
                    YAML.load_file(File.expand_path(filename))
         | 
| 54 | 
            +
                  )[CONFIG_NAME]
         | 
| 55 | 
            +
                  @@store = config
         | 
| 56 | 
            +
                  self.use_processors(config)
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                def self.use_processors(config)
         | 
| 60 | 
            +
                  config['processors'].each do |processor|
         | 
| 61 | 
            +
                    Register.use processor
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
            end
         | 
| @@ -1,6 +1,9 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'jekyll-spaceship/version'
         | 
| 4 | 
            +
            require 'rainbow/refinement'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            using Rainbow
         | 
| 4 7 |  | 
| 5 8 | 
             
            module Jekyll::Spaceship
         | 
| 6 9 | 
             
              class Logger
         | 
| @@ -9,13 +12,13 @@ module Jekyll::Spaceship | |
| 9 12 | 
             
                end
         | 
| 10 13 |  | 
| 11 14 | 
             
                def self.display_info
         | 
| 12 | 
            -
                  self.log "Jekyll-Spaceship #{Jekyll::Spaceship::VERSION}"
         | 
| 13 | 
            -
                  self.log 'A Jekyll plugin to provide powerful supports.'
         | 
| 14 | 
            -
                  self.log 'https://github.com/jeffreytse/jekyll-spaceship'
         | 
| 15 | 
            +
                  self.log "🚀 Jekyll-Spaceship #{Jekyll::Spaceship::VERSION}"
         | 
| 16 | 
            +
                  self.log '🎉 A Jekyll plugin to provide powerful supports.'
         | 
| 17 | 
            +
                  self.log '👉 ' + 'https://github.com/jeffreytse/jekyll-spaceship'.underline
         | 
| 15 18 | 
             
                end
         | 
| 16 19 |  | 
| 17 20 | 
             
                def self.log(content)
         | 
| 18 | 
            -
                  self.output 'Jekyll Spaceship', content
         | 
| 21 | 
            +
                  self.output 'Jekyll Spaceship', content.bright
         | 
| 19 22 | 
             
                end
         | 
| 20 23 |  | 
| 21 24 | 
             
                def self.output(title, content)
         | 
| @@ -6,7 +6,7 @@ require __dir__ + '/type' | |
| 6 6 | 
             
            module Jekyll::Spaceship
         | 
| 7 7 | 
             
              class Manager
         | 
| 8 8 | 
             
                @@_hooks = {}
         | 
| 9 | 
            -
                @@ | 
| 9 | 
            +
                @@_processors = []
         | 
| 10 10 |  | 
| 11 11 | 
             
                def self.add(processor)
         | 
| 12 12 | 
             
                  # register for listening event
         | 
| @@ -15,14 +15,14 @@ module Jekyll::Spaceship | |
| 15 15 | 
             
                    events = _register.last.uniq
         | 
| 16 16 | 
             
                    events = events.select do |event|
         | 
| 17 17 | 
             
                      next true if event.match(/^post/)
         | 
| 18 | 
            -
                      next  | 
| 18 | 
            +
                      next events.index(event.to_s.gsub(/^pre/, 'post').to_sym).nil?
         | 
| 19 19 | 
             
                    end
         | 
| 20 20 | 
             
                    events.each do |event|
         | 
| 21 21 | 
             
                      self.hook container, event
         | 
| 22 22 | 
             
                    end
         | 
| 23 23 | 
             
                  end
         | 
| 24 | 
            -
                  @@ | 
| 25 | 
            -
                  @@ | 
| 24 | 
            +
                  @@_processors.push(processor)
         | 
| 25 | 
            +
                  @@_processors = @@_processors.sort { |a, b| b.priority <=> a.priority }
         | 
| 26 26 | 
             
                end
         | 
| 27 27 |  | 
| 28 28 | 
             
                def self.hook(container, event, &block)
         | 
| @@ -57,19 +57,20 @@ module Jekyll::Spaceship | |
| 57 57 | 
             
                end
         | 
| 58 58 |  | 
| 59 59 | 
             
                def self.dispatch(page, container, event)
         | 
| 60 | 
            -
                  @@ | 
| 60 | 
            +
                  @@_processors.each do |processor|
         | 
| 61 61 | 
             
                    processor.dispatch page, container, event
         | 
| 62 62 | 
             
                  end
         | 
| 63 63 | 
             
                  if event.to_s.start_with?('post') and Type.html? output_ext(page)
         | 
| 64 64 | 
             
                    self.dispatch_html_block(page)
         | 
| 65 65 | 
             
                  end
         | 
| 66 | 
            -
                  @@ | 
| 66 | 
            +
                  @@_processors.each do |processor|
         | 
| 67 67 | 
             
                    processor.on_handled if processor.handled
         | 
| 68 68 | 
             
                  end
         | 
| 69 69 | 
             
                end
         | 
| 70 70 |  | 
| 71 71 | 
             
                def self.ext(page)
         | 
| 72 | 
            -
                  page. | 
| 72 | 
            +
                  ext = page.path.match(/\.\S+$/)
         | 
| 73 | 
            +
                  ext.to_s.rstrip
         | 
| 73 74 | 
             
                end
         | 
| 74 75 |  | 
| 75 76 | 
             
                def self.output_ext(page)
         | 
| @@ -91,7 +92,7 @@ module Jekyll::Spaceship | |
| 91 92 | 
             
                    next if type.nil?
         | 
| 92 93 |  | 
| 93 94 | 
             
                    # dispatch to on_handle_html_block
         | 
| 94 | 
            -
                    @@ | 
| 95 | 
            +
                    @@_processors.each do |processor|
         | 
| 95 96 | 
             
                      next unless processor.process?
         | 
| 96 97 | 
             
                      content = processor.on_handle_html_block content, type
         | 
| 97 98 | 
             
                      # dispatch to type handlers
         | 
| @@ -106,13 +107,13 @@ module Jekyll::Spaceship | |
| 106 107 | 
             
                    content = cvter.convert content unless cvter.nil?
         | 
| 107 108 |  | 
| 108 109 | 
             
                    # dispatch to on_handle_html
         | 
| 109 | 
            -
                    @@ | 
| 110 | 
            +
                    @@_processors.each do |processor|
         | 
| 110 111 | 
             
                      next unless processor.process?
         | 
| 111 112 | 
             
                      content = processor.on_handle_html content
         | 
| 112 113 | 
             
                    end
         | 
| 113 114 | 
             
                    node.replace Nokogiri::HTML.fragment content
         | 
| 114 115 | 
             
                  end
         | 
| 115 | 
            -
                  page.output = doc.to_html
         | 
| 116 | 
            +
                  page.output = Processor.escape_html doc.to_html
         | 
| 116 117 | 
             
                end
         | 
| 117 118 | 
             
              end
         | 
| 118 119 | 
             
            end
         | 
| @@ -18,6 +18,7 @@ module Jekyll::Spaceship | |
| 18 18 |  | 
| 19 19 | 
             
                attr_reader :page
         | 
| 20 20 | 
             
                attr_reader :logger
         | 
| 21 | 
            +
                attr_reader :config
         | 
| 21 22 | 
             
                attr_reader :priority
         | 
| 22 23 | 
             
                attr_reader :registers
         | 
| 23 24 | 
             
                attr_reader :exclusions
         | 
| @@ -27,11 +28,20 @@ module Jekyll::Spaceship | |
| 27 28 | 
             
                  self.class.name.split('::').last
         | 
| 28 29 | 
             
                end
         | 
| 29 30 |  | 
| 31 | 
            +
                def filename
         | 
| 32 | 
            +
                  self.name
         | 
| 33 | 
            +
                    .gsub(/([A-Z]+)([A-Z][a-z])/,'\1-\2')
         | 
| 34 | 
            +
                    .gsub(/([a-z\d])([A-Z])/,'\1-\2')
         | 
| 35 | 
            +
                    .tr("_", "-")
         | 
| 36 | 
            +
                    .downcase
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 30 39 | 
             
                def initialize()
         | 
| 31 40 | 
             
                  self.initialize_priority
         | 
| 32 41 | 
             
                  self.initialize_register
         | 
| 33 42 | 
             
                  self.initialize_exclusions
         | 
| 34 43 | 
             
                  @logger = Logger.new(self.name)
         | 
| 44 | 
            +
                  @config = Config.store(self.filename)
         | 
| 35 45 | 
             
                end
         | 
| 36 46 |  | 
| 37 47 | 
             
                def initialize_priority
         | 
| @@ -112,6 +122,9 @@ module Jekyll::Spaceship | |
| 112 122 | 
             
                    end
         | 
| 113 123 | 
             
                    if self.respond_to? method
         | 
| 114 124 | 
             
                      @page.output = self.send method, @page.output
         | 
| 125 | 
            +
                      if Type.html? output_ext
         | 
| 126 | 
            +
                        @page.output = self.class.escape_html(@page.output)
         | 
| 127 | 
            +
                      end
         | 
| 115 128 | 
             
                    end
         | 
| 116 129 | 
             
                  end
         | 
| 117 130 | 
             
                end
         | 
| @@ -158,5 +171,15 @@ module Jekyll::Spaceship | |
| 158 171 | 
             
                  @exclusion_store = []
         | 
| 159 172 | 
             
                  content
         | 
| 160 173 | 
             
                end
         | 
| 174 | 
            +
             | 
| 175 | 
            +
                def self.escape_html(content)
         | 
| 176 | 
            +
                  # escape link
         | 
| 177 | 
            +
                  content.scan(/((https?:)?\/\/\S+\?[a-zA-Z0-9%\-_=\.&;]+)/) do |result|
         | 
| 178 | 
            +
                    result = result[0]
         | 
| 179 | 
            +
                    link = result.gsub('&', '&')
         | 
| 180 | 
            +
                    content = content.gsub(result, link)
         | 
| 181 | 
            +
                  end
         | 
| 182 | 
            +
                  content
         | 
| 183 | 
            +
                end
         | 
| 161 184 | 
             
              end
         | 
| 162 185 | 
             
            end
         | 
| @@ -24,7 +24,7 @@ module Jekyll::Spaceship | |
| 24 24 | 
             
                    filename = File.basename(path, '.rb')
         | 
| 25 25 | 
             
                    next if filename.gsub(/-/, '').downcase != name
         | 
| 26 26 |  | 
| 27 | 
            -
                    Logger.log "use #{filename}"
         | 
| 27 | 
            +
                    Logger.log "🗂  use #{filename}"
         | 
| 28 28 | 
             
                    require path
         | 
| 29 29 | 
             
                    constants = Jekyll::Spaceship.constants.select do |c|
         | 
| 30 30 | 
             
                      c.downcase.to_s == name
         | 
| @@ -1,65 +1,36 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'net/http'
         | 
| 4 | 
            -
            require 'uri'
         | 
| 5 4 | 
             
            require 'json'
         | 
| 5 | 
            +
            require 'gemoji'
         | 
| 6 6 |  | 
| 7 7 | 
             
            module Jekyll::Spaceship
         | 
| 8 8 | 
             
              class EmojiProcessor < Processor
         | 
| 9 | 
            -
                EMOJI_MARKUP_HOST = 'https://api.github.com/emojis'
         | 
| 10 | 
            -
                EMOJI_MARKUP_DATA = {}
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                def initialize
         | 
| 13 | 
            -
                  super()
         | 
| 14 | 
            -
                  self.initialize_emoji_data
         | 
| 15 | 
            -
                end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                def initialize_emoji_data
         | 
| 18 | 
            -
                  EMOJI_MARKUP_DATA.update get_emoji_markup_data
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 9 | 
             
                def on_handle_html(content)
         | 
| 22 | 
            -
                  return content if EMOJI_MARKUP_DATA.size.zero?
         | 
| 23 10 | 
             
                  # handle emoji markup
         | 
| 24 | 
            -
                  content.scan(/:([\w+-]+):/) do | | 
| 25 | 
            -
                     | 
| 26 | 
            -
                     | 
| 27 | 
            -
                    next if emoji_image.nil?
         | 
| 11 | 
            +
                  content.scan(/:([\w\d+-]+):/) do |match|
         | 
| 12 | 
            +
                    emoji = Emoji.find_by_alias match[0]
         | 
| 13 | 
            +
                    next if emoji.nil?
         | 
| 28 14 | 
             
                    self.handled = true
         | 
| 29 15 |  | 
| 30 | 
            -
                    #  | 
| 31 | 
            -
                     | 
| 32 | 
            -
                    if unicode[1]
         | 
| 33 | 
            -
                      unicode = "0x#{unicode[1]}".to_i(16)
         | 
| 34 | 
            -
                      alt = [unicode].pack('U*')
         | 
| 35 | 
            -
                    end
         | 
| 36 | 
            -
                    alt = emoji_markup if alt.nil?
         | 
| 16 | 
            +
                    # escape plus sign
         | 
| 17 | 
            +
                    emoji_name = emoji.name.gsub('+', '\\\+')
         | 
| 37 18 |  | 
| 38 19 | 
             
                    content = content.gsub(
         | 
| 39 | 
            -
                      " | 
| 40 | 
            -
                      "< | 
| 41 | 
            -
                        title=\" | 
| 42 | 
            -
                        alt=\" | 
| 43 | 
            -
                         | 
| 20 | 
            +
                      /(?<!\=")\s*:#{emoji_name}:\s*(?!"\s)/,
         | 
| 21 | 
            +
                      "<img class=\"emoji\" \
         | 
| 22 | 
            +
                        title=\":#{emoji.name}:\" \
         | 
| 23 | 
            +
                        alt=\":#{emoji.name}:\" \
         | 
| 24 | 
            +
                        raw=\"#{emoji.raw}\" \
         | 
| 25 | 
            +
                        src=\"#{config['src']}#{emoji.image_filename}\" \
         | 
| 44 26 | 
             
                        style=\"vertical-align: middle; \
         | 
| 45 27 | 
             
                        max-width: 1em; visibility: hidden;\" \
         | 
| 46 28 | 
             
                        onload=\"this.style.visibility='visible'\" \
         | 
| 47 | 
            -
                        onerror=\"this.replaceWith(this. | 
| 48 | 
            -
                      </ | 
| 29 | 
            +
                        onerror=\"this.replaceWith(this.getAttribute('raw'))\"> \
         | 
| 30 | 
            +
                      </img>"
         | 
| 49 31 | 
             
                    )
         | 
| 50 32 | 
             
                  end
         | 
| 51 33 | 
             
                  content
         | 
| 52 34 | 
             
                end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                def get_emoji_markup_data
         | 
| 55 | 
            -
                  data = {}
         | 
| 56 | 
            -
                  begin
         | 
| 57 | 
            -
                    source = Net::HTTP.get URI(EMOJI_MARKUP_HOST)
         | 
| 58 | 
            -
                    data = JSON.parse(source)
         | 
| 59 | 
            -
                  rescue StandardError => msg
         | 
| 60 | 
            -
                    logger.log msg
         | 
| 61 | 
            -
                  end
         | 
| 62 | 
            -
                  data
         | 
| 63 | 
            -
                end
         | 
| 64 35 | 
             
              end
         | 
| 65 36 | 
             
            end
         | 
| @@ -18,13 +18,8 @@ module Jekyll::Spaceship | |
| 18 18 |  | 
| 19 19 | 
             
                  self.handled = true
         | 
| 20 20 |  | 
| 21 | 
            -
                   | 
| 22 | 
            -
                  src | 
| 23 | 
            -
                  config = "MathJax.Hub.Config({ \
         | 
| 24 | 
            -
                    tex2jax: { inlineMath: [['$','$'], ['\\\\(','\\\\)']] } \
         | 
| 25 | 
            -
                  });"
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                  head.add_child("<script src=\"#{src}\">#{config}</script>")
         | 
| 21 | 
            +
                  cfg = "MathJax.Hub.Config(#{config['config'].to_json});"
         | 
| 22 | 
            +
                  head.add_child("<script src=\"#{config['src']}\">#{cfg}</script>")
         | 
| 28 23 |  | 
| 29 24 | 
             
                  doc.to_html
         | 
| 30 25 | 
             
                end
         | 
| @@ -1,7 +1,10 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            +
            require "net/http"
         | 
| 4 | 
            +
            require "base64"
         | 
| 5 | 
            +
             | 
| 3 6 | 
             
            module Jekyll::Spaceship
         | 
| 4 | 
            -
              class  | 
| 7 | 
            +
              class PlantumlProcessor < Processor
         | 
| 5 8 | 
             
                exclude :none
         | 
| 6 9 |  | 
| 7 10 | 
             
                def on_handle_markdown(content)
         | 
| @@ -35,18 +38,28 @@ module Jekyll::Spaceship | |
| 35 38 |  | 
| 36 39 | 
             
                def handle_plantuml(code)
         | 
| 37 40 | 
             
                  # wrap plantuml code
         | 
| 38 | 
            -
                   | 
| 39 | 
            -
             | 
| 40 | 
            -
                  dir = File.dirname(__FILE__)
         | 
| 41 | 
            -
                  jar = dir + "/../utils/plantuml/plantuml.jar"
         | 
| 42 | 
            -
                  echo = "echo -e \"#{uml.gsub('"', '\"')}\""
         | 
| 43 | 
            -
                  plantuml = "java -jar \"#{jar}\" -pipe 2>/dev/null"
         | 
| 41 | 
            +
                  code = "@startuml#{code}@enduml".encode('UTF-8')
         | 
| 44 42 |  | 
| 45 | 
            -
                  #  | 
| 46 | 
            -
                   | 
| 43 | 
            +
                  # encode to hex string
         | 
| 44 | 
            +
                  code = '~h' + code.unpack("H*").first
         | 
| 45 | 
            +
                  data = self.get_plantuml_img_data(code)
         | 
| 47 46 |  | 
| 48 47 | 
             
                  # return img tag
         | 
| 49 | 
            -
                  "<img src=\" | 
| 48 | 
            +
                  "<img class=\"plantuml\" src=\"#{data}\">"
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                def get_plantuml_img_data(code)
         | 
| 52 | 
            +
                  data = ''
         | 
| 53 | 
            +
                  url = "#{config['src']}#{code}"
         | 
| 54 | 
            +
                  begin
         | 
| 55 | 
            +
                    data = Net::HTTP.get URI(url)
         | 
| 56 | 
            +
                    data = Base64.encode64(data)
         | 
| 57 | 
            +
                    data = "data:image/png;base64, #{data}"
         | 
| 58 | 
            +
                  rescue StandardError => msg
         | 
| 59 | 
            +
                    data = url
         | 
| 60 | 
            +
                    logger.log msg
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                  data
         | 
| 50 63 | 
             
                end
         | 
| 51 64 | 
             
              end
         | 
| 52 65 | 
             
            end
         | 
| @@ -113,16 +113,17 @@ module Jekyll::Spaceship | |
| 113 113 |  | 
| 114 114 | 
             
                  # handle colspan
         | 
| 115 115 | 
             
                  if cell == cells.last and scope.row.colspan > 0
         | 
| 116 | 
            -
                     | 
| 117 | 
            -
             | 
| 118 | 
            -
                       | 
| 116 | 
            +
                    cells.count.downto(cells.count - scope.row.colspan + 1) do |i|
         | 
| 117 | 
            +
                      c = cells[i - 1]
         | 
| 118 | 
            +
                      return unless c.get_attribute('colspan').nil?
         | 
| 119 | 
            +
                      c.remove
         | 
| 119 120 | 
             
                    end
         | 
| 120 121 | 
             
                  end
         | 
| 121 122 |  | 
| 122 | 
            -
                  result = cell.content.match(/( | 
| 123 | 
            +
                  result = cell.content.match(/(\|)+$/)
         | 
| 123 124 | 
             
                  return if result.nil?
         | 
| 124 125 |  | 
| 125 | 
            -
                  cell.content = cell.content.gsub(/( | 
| 126 | 
            +
                  cell.content = cell.content.gsub(/(\|)+$/, '')
         | 
| 126 127 | 
             
                  result = result[0]
         | 
| 127 128 | 
             
                  colspan = result.scan(/\|/).count
         | 
| 128 129 | 
             
                  scope.row.colspan += colspan
         | 
| 
            File without changes
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: jekyll-spaceship
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.6.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - jeffreytse
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020-05- | 
| 11 | 
            +
            date: 2020-05-26 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: jekyll
         | 
| @@ -44,6 +44,34 @@ dependencies: | |
| 44 44 | 
             
                - - "~>"
         | 
| 45 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 46 46 | 
             
                    version: '1.6'
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            +
              name: gemoji
         | 
| 49 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - "~>"
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '3.0'
         | 
| 54 | 
            +
              type: :runtime
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                requirements:
         | 
| 58 | 
            +
                - - "~>"
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: '3.0'
         | 
| 61 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 62 | 
            +
              name: rainbow
         | 
| 63 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 64 | 
            +
                requirements:
         | 
| 65 | 
            +
                - - "~>"
         | 
| 66 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 67 | 
            +
                    version: '3.0'
         | 
| 68 | 
            +
              type: :runtime
         | 
| 69 | 
            +
              prerelease: false
         | 
| 70 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 71 | 
            +
                requirements:
         | 
| 72 | 
            +
                - - "~>"
         | 
| 73 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 74 | 
            +
                    version: '3.0'
         | 
| 47 75 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 76 | 
             
              name: bundler
         | 
| 49 77 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -103,6 +131,7 @@ files: | |
| 103 131 | 
             
            - Rakefile
         | 
| 104 132 | 
             
            - jekyll-spaceship.gemspec
         | 
| 105 133 | 
             
            - lib/jekyll-spaceship.rb
         | 
| 134 | 
            +
            - lib/jekyll-spaceship/cores/config.rb
         | 
| 106 135 | 
             
            - lib/jekyll-spaceship/cores/logger.rb
         | 
| 107 136 | 
             
            - lib/jekyll-spaceship/cores/manager.rb
         | 
| 108 137 | 
             
            - lib/jekyll-spaceship/cores/processor.rb
         | 
| @@ -114,7 +143,7 @@ files: | |
| 114 143 | 
             
            - lib/jekyll-spaceship/processors/polyfill-processor.rb
         | 
| 115 144 | 
             
            - lib/jekyll-spaceship/processors/table-processor.rb
         | 
| 116 145 | 
             
            - lib/jekyll-spaceship/processors/video-processor.rb
         | 
| 117 | 
            -
            - lib/jekyll-spaceship/utils | 
| 146 | 
            +
            - lib/jekyll-spaceship/utils/.keep
         | 
| 118 147 | 
             
            - lib/jekyll-spaceship/version.rb
         | 
| 119 148 | 
             
            - logos/jekyll-spaceship-logo.png
         | 
| 120 149 | 
             
            - script/cibuild
         | 
| Binary file |