mtlite 0.3.2 → 0.4.1
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mtlite.rb +36 -12
- metadata +36 -31
- metadata.gz.sig +0 -0
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 287458fbd384815faecca342f0b7138ad8c8efcd32e2fbc593d15dc62c120693
         | 
| 4 | 
            +
              data.tar.gz: 568dae5601d898528f8fb497c494d1a72171d4216e2552273e3c5c65d14660ba
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 992fae9a36ca694d417312360e01e34efeb0a639b3d5cd5475da38dc779a19a68206eb802b1e7dc0c742aaf15809178526af7764ce5ab189bfa98a7d5c576819
         | 
| 7 | 
            +
              data.tar.gz: 38ce325e7523ac459a05f4a69a77bb7657c0af9fa1c41f50fce35e11f66426e64de846d38bc70340401b4c7cf33caee2c13f259c9ba99a0da1f434a1aa6ed9e5
         | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | Binary file | 
    
        data.tar.gz.sig
    CHANGED
    
    | Binary file | 
    
        data/lib/mtlite.rb
    CHANGED
    
    | @@ -7,19 +7,28 @@ require 'embiggen' | |
| 7 7 |  | 
| 8 8 | 
             
            class MTLite
         | 
| 9 9 |  | 
| 10 | 
            -
              def initialize(raw_msg)
         | 
| 10 | 
            +
              def initialize(raw_msg, debug: false)
         | 
| 11 11 |  | 
| 12 | 
            +
                @debug = debug
         | 
| 13 | 
            +
                
         | 
| 12 14 | 
             
                # reveal the expanded URL from a shortened URL
         | 
| 13 | 
            -
                raw_msg.gsub!(/https?:\/\/[ | 
| 15 | 
            +
                raw_msg.gsub!(/https?:\/\/[^ ]+/) do |url|      
         | 
| 16 | 
            +
                  
         | 
| 17 | 
            +
                  puts 'url: ' + url.inspect if @debug
         | 
| 18 | 
            +
                  
         | 
| 14 19 | 
             
                  Embiggen::URI(url).expand.to_s
         | 
| 15 20 | 
             
                end
         | 
| 16 21 |  | 
| 22 | 
            +
                puts 'raw_msg: ' + raw_msg.inspect if @debug
         | 
| 23 | 
            +
                
         | 
| 17 24 | 
             
                # make the smartlinks into Markdown links        
         | 
| 18 25 | 
             
                @raw_msg = smartlink(raw_msg)
         | 
| 19 26 |  | 
| 27 | 
            +
                puts '@raw_msg: '  + @raw_msg.inspect if @debug
         | 
| 28 | 
            +
                
         | 
| 20 29 | 
             
              end
         | 
| 21 30 |  | 
| 22 | 
            -
              def to_html()
         | 
| 31 | 
            +
              def to_html(para: false, ignore_domainlabel: false)
         | 
| 23 32 |  | 
| 24 33 | 
             
                raw_msg = @raw_msg.clone    
         | 
| 25 34 | 
             
                # if it looks like an MtLite list make it an MtLite list
         | 
| @@ -37,7 +46,7 @@ class MTLite | |
| 37 46 | 
             
                # convert square brackets to unicode check boxes
         | 
| 38 47 | 
             
                # replaces a [] with a unicode checkbox, 
         | 
| 39 48 | 
             
                #                         and [x] with a unicode checked checkbox
         | 
| 40 | 
            -
                raw_msg = raw_msg.gsub(/\[\s*\]/,'☐').gsub(/\[x\]/,'☑')
         | 
| 49 | 
            +
                raw_msg = raw_msg.gsub(/\[\s*\](?= )/,'☐').gsub(/\[x\]/,'☑')
         | 
| 41 50 |  | 
| 42 51 | 
             
                # convert fractions using their associated unicode character
         | 
| 43 52 | 
             
                # i.e. 1/4, 1/2, 3/4 
         | 
| @@ -50,11 +59,15 @@ class MTLite | |
| 50 59 | 
             
                  x.sub(/-([&\w]+.*\w+)-/,'<del>\1</del>')
         | 
| 51 60 | 
             
                end
         | 
| 52 61 |  | 
| 53 | 
            -
                 | 
| 54 | 
            -
             | 
| 55 | 
            -
                   | 
| 56 | 
            -
                   | 
| 57 | 
            -
             | 
| 62 | 
            +
                unless ignore_domainlabel then
         | 
| 63 | 
            +
                  
         | 
| 64 | 
            +
                  # append a domain label after the URL
         | 
| 65 | 
            +
                  raw_msg.gsub!(/(?:^\[|\s\[)[^\]]+\]\((https?:\/\/[^\s]+)/) do |x|
         | 
| 66 | 
            +
                    s2 = x[/https?:\/\/([^\/]+)/,1].split(/\./)
         | 
| 67 | 
            +
                    r = s2.length >= 3 ? s2[1..-1] :  s2
         | 
| 68 | 
            +
                    "%s [%s]" % [x, r.join('.')]
         | 
| 69 | 
            +
                  end
         | 
| 70 | 
            +
                  
         | 
| 58 71 | 
             
                end
         | 
| 59 72 |  | 
| 60 73 | 
             
                # generate html lists from mtlite 1-liner lists
         | 
| @@ -74,11 +87,22 @@ class MTLite | |
| 74 87 |  | 
| 75 88 | 
             
                end
         | 
| 76 89 |  | 
| 77 | 
            -
                msg = RDiscount.new(raw_msg).to_html | 
| 90 | 
            +
                msg = RDiscount.new(raw_msg).to_html
         | 
| 91 | 
            +
                msg.gsub!(/<\/?p[^>]*>/,'') unless para
         | 
| 78 92 |  | 
| 79 | 
            -
                regex = %r([ | 
| 93 | 
            +
                regex = %r([^ <]+)
         | 
| 80 94 | 
             
                # generate anchor tags for URLs which don't have anchor tags
         | 
| 81 95 | 
             
                msg.gsub!(/(?:^(https?:#{regex})|\s(https?:#{regex}))/,' <a href="\2">\2</a>')    
         | 
| 96 | 
            +
                
         | 
| 97 | 
            +
                msg.gsub!(/(?<=\>)https?:#{regex}/) do |x|
         | 
| 98 | 
            +
                  
         | 
| 99 | 
            +
                  # unescapeHTML will transform & to &
         | 
| 100 | 
            +
                  url = CGI.unescapeHTML x
         | 
| 101 | 
            +
                  url2 = url.sub(/^https?:\/\//,'').sub(/^www\./,'')
         | 
| 102 | 
            +
                  url3 = url2.length > 33 ? url2[0..33] + '...' : url2
         | 
| 103 | 
            +
                  #" <a href='#{url}'>#{url3}</a>"
         | 
| 104 | 
            +
                end
         | 
| 105 | 
            +
             | 
| 82 106 | 
             
                # add the target attribute to make all hyperlinks open in a new browser tab
         | 
| 83 107 | 
             
                msg.gsub!(/<a /,'<a target="_blank" ')
         | 
| 84 108 |  | 
| @@ -129,4 +153,4 @@ class MTLite | |
| 129 153 |  | 
| 130 154 | 
             
              end  
         | 
| 131 155 |  | 
| 132 | 
            -
            end
         | 
| 156 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: mtlite
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.4.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - James Robertson
         | 
| @@ -10,28 +10,32 @@ bindir: bin | |
| 10 10 | 
             
            cert_chain:
         | 
| 11 11 | 
             
            - |
         | 
| 12 12 | 
             
              -----BEGIN CERTIFICATE-----
         | 
| 13 | 
            -
               | 
| 14 | 
            -
               | 
| 15 | 
            -
               | 
| 16 | 
            -
               | 
| 17 | 
            -
               | 
| 18 | 
            -
               | 
| 19 | 
            -
               | 
| 20 | 
            -
               | 
| 21 | 
            -
               | 
| 22 | 
            -
               | 
| 23 | 
            -
               | 
| 24 | 
            -
               | 
| 25 | 
            -
               | 
| 26 | 
            -
               | 
| 27 | 
            -
               | 
| 28 | 
            -
               | 
| 29 | 
            -
               | 
| 30 | 
            -
               | 
| 31 | 
            -
               | 
| 32 | 
            -
               | 
| 13 | 
            +
              MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
         | 
| 14 | 
            +
              YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwMjIzMTQ1MzMwWhcN
         | 
| 15 | 
            +
              MjIwMjIzMTQ1MzMwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
         | 
| 16 | 
            +
              cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDPICvX
         | 
| 17 | 
            +
              ekFtCC7T84fjH1kM3eAgM4M8+0D/nWMUTL+aZjmNJUhnknZLGX+ltHYMoj+1jX8E
         | 
| 18 | 
            +
              x0HJqxkKpbOmr1oIj6/iF6Ns1bOamtn9qin5fpvfk6Db9e33Wb0qsC4iNy6IWCEW
         | 
| 19 | 
            +
              azjrGhBaKrawH/qTIHVpzRqhGAwjDslsT8WEXjMGppRFmQqXoBh/gKa17AuZx1Kb
         | 
| 20 | 
            +
              oLS1xfdKa8cnRCyMvNfD3tBWxTuQ04lY2IfIuuB2/O4iWs3CvtD2QQI/XC4poDG4
         | 
| 21 | 
            +
              Fgcocl21w5ALwN33m/5PbA0adYn+wxy9vPwJ45xB10pjB7FYlBK4BBcb8hylUEP2
         | 
| 22 | 
            +
              OEQqx8MDeTCCUBdz9/cZY4SdpBur6YYmvwth2fFG3dDjQa0RA/JnmanECPdV17jQ
         | 
| 23 | 
            +
              342UQRcsPBrq0B5//HjdiS7xOFFP/Lec4B1NLD9tnyrbCQsC1asUwhyTKnZN6Gv4
         | 
| 24 | 
            +
              ZoOFAEpBN8pHUX7R0zZB0OpwY+HxV7FWvKAiOaKfpHZ8VL20PpWMi7DZ2Q0CAwEA
         | 
| 25 | 
            +
              AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUUdTDzYti
         | 
| 26 | 
            +
              v2oK6sH4SxOAL4wBGhIwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
         | 
| 27 | 
            +
              c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
         | 
| 28 | 
            +
              BgkqhkiG9w0BAQsFAAOCAYEAkc9hOBwHoSh3zxQqUT0L1U7A3qrPgL9v3zHVJj7v
         | 
| 29 | 
            +
              b8lfFtTAZ70yFnmjhDKKJezTxGOg/4gbxskiO4Kf2jdKwV4Of43N9Ag6YCrz5eA5
         | 
| 30 | 
            +
              6inRvvjKOnXYdO22Y/eAPTficdlkj5QZw0Qe9Zd9WxhjDWulBaToqwdrZdeeq0/s
         | 
| 31 | 
            +
              mWYzhQYWrPOS8ozdFSlcAG/QED7txpx50dYzrcafL7oP83wM2bAX4XtZIqbOgZft
         | 
| 32 | 
            +
              iSNANuPrW+VhvqGo3M8+f+5yYYyS67whR5w85z9TcUT+dPyTGYl6ClNUXFt0vR1i
         | 
| 33 | 
            +
              HG+QtV9hBiE8GRODZL0uFwL4Cl2EjDBAIbjtqh2fUy1T6A/u7Y23eVL+cnelk/YT
         | 
| 34 | 
            +
              f6uxrTojqd8rUrVvqz0lhaTd1eoT6kd/u2r7YbzLnvraDnBwiuFAPticmw7JuVpZ
         | 
| 35 | 
            +
              RpkfFZne43vM6SRQRvmVREEMpk57Mub1ccA9v5eElBuZbfyEO5eMYSc88DkxHCkr
         | 
| 36 | 
            +
              sfZbXuL/o5TgPyPL7UYvUyoJ
         | 
| 33 37 | 
             
              -----END CERTIFICATE-----
         | 
| 34 | 
            -
            date:  | 
| 38 | 
            +
            date: 2021-03-08 00:00:00.000000000 Z
         | 
| 35 39 | 
             
            dependencies:
         | 
| 36 40 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 41 | 
             
              name: rdiscount
         | 
| @@ -57,24 +61,24 @@ dependencies: | |
| 57 61 | 
             
              name: embiggen
         | 
| 58 62 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 59 63 | 
             
                requirements:
         | 
| 60 | 
            -
                - - "~>"
         | 
| 61 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            -
                    version: '0.1'
         | 
| 63 64 | 
             
                - - ">="
         | 
| 64 65 | 
             
                  - !ruby/object:Gem::Version
         | 
| 65 66 | 
             
                    version: 0.1.0
         | 
| 67 | 
            +
                - - "~>"
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '0.1'
         | 
| 66 70 | 
             
              type: :runtime
         | 
| 67 71 | 
             
              prerelease: false
         | 
| 68 72 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 69 73 | 
             
                requirements:
         | 
| 70 | 
            -
                - - "~>"
         | 
| 71 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 72 | 
            -
                    version: '0.1'
         | 
| 73 74 | 
             
                - - ">="
         | 
| 74 75 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 76 | 
             
                    version: 0.1.0
         | 
| 77 | 
            +
                - - "~>"
         | 
| 78 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 79 | 
            +
                    version: '0.1'
         | 
| 76 80 | 
             
            description: 
         | 
| 77 | 
            -
            email:  | 
| 81 | 
            +
            email: digital.robertson@gmail.com
         | 
| 78 82 | 
             
            executables: []
         | 
| 79 83 | 
             
            extensions: []
         | 
| 80 84 | 
             
            extra_rdoc_files: []
         | 
| @@ -100,8 +104,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 100 104 | 
             
                  version: '0'
         | 
| 101 105 | 
             
            requirements: []
         | 
| 102 106 | 
             
            rubyforge_project: 
         | 
| 103 | 
            -
            rubygems_version: 2. | 
| 107 | 
            +
            rubygems_version: 2.7.10
         | 
| 104 108 | 
             
            signing_key: 
         | 
| 105 109 | 
             
            specification_version: 4
         | 
| 106 | 
            -
            summary:  | 
| 110 | 
            +
            summary: Martile Lite generates HTML ideally from 1 line of a condensed kind of markdown
         | 
| 111 | 
            +
              language.
         | 
| 107 112 | 
             
            test_files: []
         | 
    
        metadata.gz.sig
    CHANGED
    
    | Binary file |