light_markuz 0.1.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 +7 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +27 -0
- data/bin/lightmarkuz +7 -0
- data/lib/defaultStyle.css +24 -0
- data/lib/light_markuz.rb +112 -0
- data/light_markuz.gemspec +27 -0
- metadata +93 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: dcc9c23f4b252d24869526b54064a2f38df96c28
         | 
| 4 | 
            +
              data.tar.gz: e8371eb15596d0e47bfcefb0258bdf30bf8df633
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 8a75213655848a94d25bd5708f0f94a9eb07997b7b68eb84b6d7cf1ad2e94dc9b91d115da1f771181be2d7cf5c54085c1710813e1fe3d604dc22a083f9e994a3
         | 
| 7 | 
            +
              data.tar.gz: ea960578d9cc3a9bd5e62f2207d4187838712266bd4e8730a0f5e534f81f5951c8d3bec605bae81fe0651e83f07a6dd0b564cbf07cd916e24a6809d6e895dfbb
         | 
    
        data/Gemfile
    ADDED
    
    | 
            File without changes
         | 
    
        data/LICENSE.txt
    ADDED
    
    | 
            File without changes
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            # LightMarkuz
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            LightMarkuz is a template language that exports to HTML and PDF
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## How to use
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ### In command line
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ```
         | 
| 10 | 
            +
            lightmarkuz inputFile.lmz -o outFile.html -w
         | 
| 11 | 
            +
            ```
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            - The output file is behind the argument `-o`
         | 
| 14 | 
            +
            - The output file can be a PDF
         | 
| 15 | 
            +
            - The argument `-w` is use to watch the input file
         | 
| 16 | 
            +
            - You can add the `-css` argument to add a css file
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            ### Ruby API
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            ```ruby
         | 
| 21 | 
            +
            require 'light_markuz'
         | 
| 22 | 
            +
            LightMarkuz.new ["input.lmz", "-o", "outPDF.pdf", "-w"]
         | 
| 23 | 
            +
            # Automatically it is going to generate the file outPDF.pdf
         | 
| 24 | 
            +
            ```
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            ## Known issues
         | 
| 27 | 
            +
            1. The images with a relative url don't charge in PDF
         | 
    
        data/bin/lightmarkuz
    ADDED
    
    
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            @charset "UTF-8";
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            @import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Lato', sans-serif; width: auto; line-height: 1.5em; }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            @media screen { body { margin: 3.25% 5%; width: auto; } }
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            h1 { text-align: center; width: auto; margin: 2.5vh 0; border-bottom: 1px solid #000; color: #000; font-variant: small-caps; }
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            h2, h3 { text-align: left; }
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            p { margin: .75% 6.5%; text-align: justify; text-indent: 1cm; }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            img { width: 14em; margin: 2.5vmax; float: right; }
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            li { margin: .75% 9.75%; list-style-type: disc; list-style-position: inside; }
         | 
| 18 | 
            +
            li.indent { margin: .75% 14.25%; }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            h2 { margin: .75% 0; color: #333; font-variant: small-caps; }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            h3 { font-style: italic; margin: .75% 3.25%; color: #666; }
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            a { text-decoration: none; color: #22A7F0; }
         | 
    
        data/lib/light_markuz.rb
    ADDED
    
    | @@ -0,0 +1,112 @@ | |
| 1 | 
            +
            require 'date'
         | 
| 2 | 
            +
            require 'colorize'
         | 
| 3 | 
            +
            require 'filewatcher'
         | 
| 4 | 
            +
            require 'pdfkit'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class LightMarkuz
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            	VERSION = '0.1.1'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            	attr_accessor :urlInFile,
         | 
| 11 | 
            +
            				  :urlOutFile,
         | 
| 12 | 
            +
            				  :fileData,
         | 
| 13 | 
            +
            				  :cssFile,
         | 
| 14 | 
            +
            				  :outFileExtension
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            	def initialize arrArgs
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            		if arrArgs == nil
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            			self.urlInFile  = ARGV.grep( /\b.*\.lmz/ )[0]
         | 
| 21 | 
            +
            			raise "You must declare a input file".colorize(:red).bold if self.urlInFile == nil
         | 
| 22 | 
            +
            			self.urlOutFile = ARGV[ ARGV.index("-o") + 1] if ARGV.include? "-o"
         | 
| 23 | 
            +
            			self.outFileExtension = File.extname self.urlOutFile if ARGV.include? "-o"
         | 
| 24 | 
            +
            			self.cssFile 	= "#{File.expand_path(File.dirname(__FILE__))}/defaultStyle.css"
         | 
| 25 | 
            +
            			self.cssFile 	= ARGV[ ARGV.index("-css") + 1] if ARGV.include? "-css"
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            			self.compileLightMarkuz
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            			puts "Convert file #{File.basename(self.urlInFile)}".colorize(:green).bold, "Thanks for use LightMarkuz!".colorize(:cyan).bold unless (ARGV.include? "-w") || (ARGV.include? "--watch")
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            			puts "Watching file #{File.basename(self.urlInFile)}".bold if (ARGV.include? "-w") || (ARGV.include? "--watch")
         | 
| 32 | 
            +
            			self.watchFile if (ARGV.include? "-w") || (ARGV.include? "--watch")
         | 
| 33 | 
            +
            		
         | 
| 34 | 
            +
            		else
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            			self.urlInFile  = arrArgs.grep( /\b.*\.lmz/ )[0]
         | 
| 37 | 
            +
            			raise "You must declare a input file".colorize(:red).bold if self.urlInFile == nil
         | 
| 38 | 
            +
            			self.urlOutFile = arrArgs[ arrArgs.index("-o") + 1] if arrArgs.include? "-o"
         | 
| 39 | 
            +
            			self.outFileExtension = File.extname self.urlOutFile if ARGV.include? "-o"
         | 
| 40 | 
            +
            			self.cssFile 	= "#{File.expand_path(File.dirname(__FILE__))}/defaultStyle.css"
         | 
| 41 | 
            +
            			self.cssFile 	= arrArgs[ arrArgs.index("-css") + 1] if arrArgs.include? "-css"
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            			self.compileLightMarkuz
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            			puts "Convert file #{File.basename(self.urlInFile)}".colorize(:green).bold, "Thanks for use LightMarkuz!".colorize(:cyan).bold unless (arrArgs.include? "-w") || (arrArgs.include? "--watch")
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            			puts "Watching file #{File.basename(self.urlInFile)}".bold if (arrArgs.include? "-w") || (arrArgs.include? "--watch")
         | 
| 48 | 
            +
            			self.watchFile if (arrArgs.include? "-w") || (arrArgs.include? "--watch")
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            		end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            	end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            	def compileLightMarkuz
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            		self.fileData = IO.readlines self.urlInFile unless self.urlInFile == nil
         | 
| 57 | 
            +
            		self.fileData.unshift "<meta charset='utf-8'/>\n<link rel='stylesheet' type='text/css' href='#{self.cssFile}' />\n"
         | 
| 58 | 
            +
            		self.fileData = self.fileData * ""
         | 
| 59 | 
            +
            		
         | 
| 60 | 
            +
            		regExes = {
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            		  body: [/\A(.*)\z/m, "<body>\n\\1\n</body>"], 
         | 
| 63 | 
            +
            		   img: [/\bimg\((.*?)\)/, "<img src='\\1'>"],
         | 
| 64 | 
            +
            			h1: [/^# (.*)$/, "<h1>\\1</h1>"],
         | 
| 65 | 
            +
            			h2: [/^## (.*)$/, "<h2>\\1</h2>"],
         | 
| 66 | 
            +
            			h3: [/^### (.*)$/, "<h3>\\1</h3>"],
         | 
| 67 | 
            +
            			li: [/^[\*|\-] (.*?)$/, "<li>\\1</li>"],
         | 
| 68 | 
            +
            			l2: [/^\t*[\*|\-] (.*?)$/, "<li class='indent'>\\1</li>"],
         | 
| 69 | 
            +
            			 p: [/^(\w.*)$/, "<p>\\1</p>"],
         | 
| 70 | 
            +
            			 b: [/\bb\((.*?)\)/, "<strong>\\1</strong>"],
         | 
| 71 | 
            +
            			 i: [/\bi\((.*?)\)/, "<i>\\1</i>"],
         | 
| 72 | 
            +
            			 u: [/\bu\((.*?)\)/, "<u>\\1</u>"],
         | 
| 73 | 
            +
            			 s: [/\bs\((.*?)\)/, "<s>\\1</s>"],
         | 
| 74 | 
            +
            			 a: [/\ba\((.*?) ?\| ?(.*?)\)/, "<a href='\\2'>\\1</a>"],
         | 
| 75 | 
            +
            		
         | 
| 76 | 
            +
            		}
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            		for index, regEx in regExes
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            			self.fileData.gsub!(regEx[0], regEx[1])
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            		end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
            		rootUrl = "#{File.expand_path(File.dirname(self.urlInFile))}"
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            		IO.write self.urlOutFile, self.fileData if (self.urlOutFile != nil) && (self.outFileExtension == ".html")
         | 
| 87 | 
            +
            		PDFKit.new(self.fileData, { page_size: 'A4'}).to_file(self.urlOutFile) if (self.urlOutFile != nil) && (self.outFileExtension == ".pdf")
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            	end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
            	def watchFile
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            		FileWatcher.new(urlInFile).watch() do |file, event|
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            			case event
         | 
| 96 | 
            +
            				when :deleted
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            					puts "\n\tGoodbye!\n".colorize(:blue).bold.on_red
         | 
| 99 | 
            +
            					exit
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            				when :changed
         | 
| 102 | 
            +
             | 
| 103 | 
            +
            					compileLightMarkuz
         | 
| 104 | 
            +
            					print "\t[%02i:%02i]".bold % [Time.now.hour, Time.now.min], "\t>> File #{File.basename(self.urlInFile)} changed".colorize(:blue).bold, "\n"
         | 
| 105 | 
            +
             | 
| 106 | 
            +
            			end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            		end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            	end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'light_markuz'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Gem::Specification.new do |s|
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            	s.name        = 'light_markuz'
         | 
| 10 | 
            +
            	s.version     = LightMarkuz::VERSION
         | 
| 11 | 
            +
            	s.date        = '2016-05-14'
         | 
| 12 | 
            +
            	s.summary     = "LightMarkuz!"
         | 
| 13 | 
            +
            	s.description = "A template language that exported to HTML and PDF"
         | 
| 14 | 
            +
            	s.authors     = ["Daviz"]
         | 
| 15 | 
            +
            	s.email       = 'roman.daco.st@gmail.com'
         | 
| 16 | 
            +
            	s.homepage    = 'http://rubygems.org/gems/light_markuz'
         | 
| 17 | 
            +
            	s.license     = 'MIT'
         | 
| 18 | 
            +
            	
         | 
| 19 | 
            +
            	s.files       = `git ls-files`.split("\n")
         | 
| 20 | 
            +
            	s.executables = `git ls-files -- bin/*`.split("\n").map!{ |f| File.basename(f) }
         | 
| 21 | 
            +
            	s.require_paths = ["lib"]
         | 
| 22 | 
            +
            	
         | 
| 23 | 
            +
            	s.add_dependency 'colorize', '~> 0.7.7'
         | 
| 24 | 
            +
            	s.add_dependency 'filewatcher', '~> 0.5.3'
         | 
| 25 | 
            +
            	s.add_dependency 'pdfkit', '~> 0.8.2'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,93 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: light_markuz
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Daviz
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2016-05-14 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: colorize
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 0.7.7
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: 0.7.7
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: filewatcher
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: 0.5.3
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: 0.5.3
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: pdfkit
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: 0.8.2
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: 0.8.2
         | 
| 55 | 
            +
            description: A template language that exported to HTML and PDF
         | 
| 56 | 
            +
            email: roman.daco.st@gmail.com
         | 
| 57 | 
            +
            executables:
         | 
| 58 | 
            +
            - lightmarkuz
         | 
| 59 | 
            +
            extensions: []
         | 
| 60 | 
            +
            extra_rdoc_files: []
         | 
| 61 | 
            +
            files:
         | 
| 62 | 
            +
            - Gemfile
         | 
| 63 | 
            +
            - LICENSE.txt
         | 
| 64 | 
            +
            - README.md
         | 
| 65 | 
            +
            - bin/lightmarkuz
         | 
| 66 | 
            +
            - lib/defaultStyle.css
         | 
| 67 | 
            +
            - lib/light_markuz.rb
         | 
| 68 | 
            +
            - light_markuz.gemspec
         | 
| 69 | 
            +
            homepage: http://rubygems.org/gems/light_markuz
         | 
| 70 | 
            +
            licenses:
         | 
| 71 | 
            +
            - MIT
         | 
| 72 | 
            +
            metadata: {}
         | 
| 73 | 
            +
            post_install_message: 
         | 
| 74 | 
            +
            rdoc_options: []
         | 
| 75 | 
            +
            require_paths:
         | 
| 76 | 
            +
            - lib
         | 
| 77 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 78 | 
            +
              requirements:
         | 
| 79 | 
            +
              - - ">="
         | 
| 80 | 
            +
                - !ruby/object:Gem::Version
         | 
| 81 | 
            +
                  version: '0'
         | 
| 82 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 83 | 
            +
              requirements:
         | 
| 84 | 
            +
              - - ">="
         | 
| 85 | 
            +
                - !ruby/object:Gem::Version
         | 
| 86 | 
            +
                  version: '0'
         | 
| 87 | 
            +
            requirements: []
         | 
| 88 | 
            +
            rubyforge_project: 
         | 
| 89 | 
            +
            rubygems_version: 2.5.1
         | 
| 90 | 
            +
            signing_key: 
         | 
| 91 | 
            +
            specification_version: 4
         | 
| 92 | 
            +
            summary: LightMarkuz!
         | 
| 93 | 
            +
            test_files: []
         |