Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9caebff

Browse files
author
m
committed
.
1 parent7cb83d3 commit9caebff

File tree

8 files changed

+141
-56
lines changed

8 files changed

+141
-56
lines changed

‎LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(The MIT License)
2+
3+
Copyright (c) mori_dev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the 'Software'), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,29 @@ Installation
2626

2727
gem install markup-preview-command
2828

29-
3029
Usage
3130
-----
3231

33-
markup-preview --filepath foo --markup markdown
34-
markup-preview --filepath foo.md
35-
markup-preview --f foo.md
32+
markup-preview --filepath foo --markup markdown --output browser
33+
markup-preview --filepath foo.md --output browser
34+
markup-preview --f foo.md -o browser
3635
cat bar.md | markup-preview -m markdown
3736

3837
Or, more realistically:
3938

39+
Put markup-preview.el in your load-path.
4040
cp path/to/markup-preview-command/etc/markup-preview.el ${HOME}/.emacs.d/elisp/markup-preview.el
4141

42-
And in your emacs config file,
43-
44-
(add-to-list 'load-path "~/.emacs.d/elisp")
42+
Add following code.
4543
(require 'markup-preview)
44+
(global-set-key (kbd "M--") 'markup-preview) ; key bind example
4645

47-
Then
46+
Contributing
47+
------------
4848

49-
M-x markup-preview
49+
Fork, fix, then send me a pull request.
5050

51-
Contributing
51+
Copyright
5252
------------
5353

54-
Fork it.
54+
Copyright (c) mori_dev. See LICENSE for details.

‎bin/markup-preview

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ def main
1010

1111
help=<<-EOF
1212
useage:
13-
markup-preview -ffilepath
14-
Or,
15-
catsome.md | markup-preview -m markdown
13+
markup-preview -fpath/to/foo.md -o browser
14+
or,
15+
catfoo.md | markup-preview -m markdown -o browser
1616
EOF
1717

1818
opts=Slop.parsedo
@@ -22,7 +22,7 @@ cat some.md | markup-preview -m markdown
2222
end
2323
on:m,:markup=,'markup'
2424
on:f,:filepath=,'filepath'
25-
on:d,:debug,'Enable debug'
25+
on:o,:output=,'set "-o browser" if see result by browser'
2626
end
2727

2828
Markup::Preview::Command::Render.execute(opts)

‎etc/markup-preview.el

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
;;; markup-preview.el
1+
;;; markup-preview.el --- Emacs Interface for markup-preview-command
22

33
;; Copyright (C) 2012 mori_dev
44

55
;; Author: mori_dev <mori.dev.asdf@gmail.com>
6-
;; Keywords: utility
7-
;; Prefix: anything-howm-
6+
;; Version: 1.0
7+
;; Keywords: markup, convenience
8+
;; Prefix: mp:
89

910
;; This program is free software; you can redistribute it and/or modify
1011
;; it under the terms of the GNU General Public License as published by
@@ -19,15 +20,28 @@
1920
;; You should have received a copy of the GNU General Public License
2021
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
2122

22-
;;; Setting Sample
23+
;;; Installation:
24+
25+
;; This program is dependent on followings:
26+
;; - markup-preview-command (https://github.com/wakaran/markup-preview-command)
27+
28+
;; Put markup-preview.el in your load-path, and add following code.
2329

2430
;; (require 'markup-preview)
25-
;;
31+
;;
32+
;; M-x markup-preview
33+
;; Or,
34+
;; (global-set-key (kbd "M--") 'markup-preview) ; key bind example
35+
36+
;;; History:
2637

38+
;; Revision 1.0 2012/01/08 mori_dev
39+
;; Initial revision
2740

28-
(defvarpreferred-formatnil)
2941

30-
(setq extension-markup-alist
42+
(defvarmp:preferred-formatnil)
43+
44+
(defvarmp:extension-markup-alist
3145
'(("md"."Markdown")
3246
("mkd"."Markdown")
3347
("mkdn"."Markdown")
@@ -42,34 +56,31 @@
4256
("rdoc"."rdoc")
4357
("mediawiki"."MediaWiki")))
4458

45-
(defunget-markup (extension)
46-
(if preferred-format
47-
preferred-format
48-
(cdr (assoc extension extension-markup-alist))))
49-
50-
(defunmarkup-preview ()
51-
(interactive)
52-
(let ((str (get-target-string))
53-
(temp-file (make-temp-file"markup-preview-region-"))
54-
(markup (get-markup (file-name-extension (buffer-file-name)))))
55-
(unless temp-file (error"fail to get temp-file"))
56-
(unless markup (error"fail to get markup"))
57-
(with-temp-file temp-file (insert str))
58-
(call-markup-preview-command temp-file markup)))
59+
(defunmp:get-markup (extension)
60+
(if mp:preferred-format
61+
mp:preferred-format
62+
(cdr (assoc extension mp:extension-markup-alist))))
5963

60-
(defunget-target-string ()
64+
(defunmp:get-target-string ()
6165
(if (region-active-p)
6266
(buffer-substring-no-properties (region-beginning) (region-end))
6367
(buffer-substring-no-properties (point-min) (point-max))))
6468

65-
(defuncall-markup-preview-command (temp-filemarkup)
69+
(defunmp:call-markup-preview-command (temp-filemarkup)
70+
(unless (executable-find"markup-preview")
71+
(error"markup-preview not found"))
6672
(call-process-shell-command
67-
(concat"markup-preview""--filepath" temp-file" --markup" markup" -d"))
73+
(concat"markup-preview""--filepath" temp-file" --markup" markup" --output browser"))
6874
(delete-file temp-file))
69-
;; (call-process-shell-command "gnome-open /tmp/markup-preview-region-2273Qtu")
70-
;; (unless (executable-find "markup-preview")
71-
;; (error "markup-preview not found"))
72-
;; (call-process-shell-command
73-
;; (concat "markup-preview " "--filepath " temp-file " -m")))
75+
76+
(defunmarkup-preview ()
77+
(interactive)
78+
(let ((str (mp:get-target-string))
79+
(temp-file (make-temp-file"markup-preview-region-"))
80+
(markup (mp:get-markup (file-name-extension (buffer-file-name)))))
81+
(unless temp-file (error"fail to get temp-file"))
82+
(unless markup (error"fail to get markup"))
83+
(with-temp-file temp-file (insert str))
84+
(mp:call-markup-preview-command temp-file markup)))
7485

7586
(provide'markup-preview)

‎lib/markup-preview-command.rb

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
require'rubygems'unlessdefined?Gem
22
require'markup-preview-command/version'
3-
require'markup-preview-command/util'
3+
require'markup-preview-command/util/util'
44

55
moduleMarkup::Preview::Command
66
classRender
77

8-
require'markup/markup'
8+
require'github/markup'
99
require'fileutils'
1010
require'tmpdir'
1111

@@ -18,6 +18,7 @@ class Render
1818
definitialize(opts)
1919
@content=nil
2020
@format=nil
21+
@browser=false
2122
parse_options(opts)
2223
end
2324

@@ -27,15 +28,20 @@ def self.execute(opts)
2728

2829
defexecute
2930
create_html
30-
open_browser
31-
exit($?.exitstatus ||0)
31+
if@browser
32+
open_browser
33+
exit($?.exitstatus ||0)
34+
else
35+
putsFile.read(TMPFILE)
36+
exit0
37+
end
3238
end
3339

3440

3541
private
3642

3743
defcreate_html
38-
render_result=Markup::Markup.render("dummy.#{@format}",@content)
44+
render_result=GitHub::Markup.render("dummy.#{@format}",@content)
3945
template_css=File.read(File.join(File.dirname(__FILE__),'markup-preview-command','css','template.css'))
4046
gollum_css=File.read(File.join(File.dirname(__FILE__),'markup-preview-command','css','gollum.css'))
4147
html=ERB.new(File.read(File.join(File.dirname(__FILE__),'markup-preview-command','view','template.erb')))
@@ -53,8 +59,11 @@ def parse_options(opts)
5359
extensions=['md','mkd','mkdn','mkdn','mdown','markdown','org','pod',
5460
'creole','rst','rest','textile','rdoc','mediawiki']
5561

56-
ifopts.markup?
57-
@format=opts[:markup].downcase
62+
63+
@format=opts[:markup].downcaseifopts.markup?
64+
65+
ifopts.output? &&(opts[:output] ==='browser')
66+
@browser=true
5867
end
5968

6069
ifopts.filepath? &&(File::extname(opts[:filepath]) !="")
@@ -65,11 +74,7 @@ def parse_options(opts)
6574
end
6675
end
6776

68-
ifopts.filepath?
69-
@content=File.read(opts[:filepath])
70-
else
71-
@content= $stdin.read
72-
end
77+
@content=opts.filepath? ?File.read(opts[:filepath]) : $stdin.read
7378

7479
end
7580
end

‎licenses/gollum/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(The MIT License)
2+
3+
Copyright (c) Tom Preston-Werner, Rick Olson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the 'Software'), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎licenses/licenses.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
markup-preview-command (MIT License)
2+
https://github.com/wakaran/markup-preview-command/blob/master/LICENSE
3+
4+
--
5+
Gollum (MIT License)
6+
https://github.com/github/gollum/blob/master/LICENSE
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(The MIT License)
2+
3+
Copyright (c) mori_dev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the 'Software'), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp