RbST 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "RbST"
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["William Melody"]
12
- s.date = "2012-11-01"
12
+ s.date = "2012-11-02"
13
13
  s.description = "A simple Ruby wrapper for processing reStructuredText via Python's Docutils"
14
14
  s.email = "hi@williammelody.com"
15
15
  s.extra_rdoc_files = [
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,4 +1,4 @@
1
- require 'open3'
1
+ # encoding: UTF-8
2
2
 
3
3
  class RbST
4
4
 
@@ -82,10 +82,10 @@ protected
82
82
 
83
83
  def execute(command)
84
84
  output = ''
85
- Open3::popen3(command) do |stdin, stdout, stderr|
86
- stdin.puts @target
87
- stdin.close
88
- output = stdout.read.strip
85
+ IO.popen(command, "w+") do |f|
86
+ f.puts @target
87
+ f.close_write
88
+ output = f.read
89
89
  end
90
90
  output
91
91
  end
@@ -106,4 +106,4 @@ protected
106
106
  string + (flag.length == 1 ? " -#{flag} #{val}" : " --#{flag}=#{val}")
107
107
  end
108
108
  end
109
- end
109
+ end
@@ -6,6 +6,7 @@ try:
6
6
  except:
7
7
  pass
8
8
 
9
+ import sys
9
10
  from transform import transform
10
11
  from docutils.writers.html4css1 import Writer
11
12
 
@@ -13,4 +14,4 @@ def main():
13
14
  return transform(writer=Writer(), part='html_body')
14
15
 
15
16
  if __name__ == '__main__':
16
- print(main())
17
+ sys.stdout.write(main())
@@ -36,5 +36,5 @@ def transform(writer=None, part=None):
36
36
  )
37
37
 
38
38
  if opts.part in parts:
39
- return parts[opts.part]
39
+ return parts[opts.part].encode(parts["encoding"])
40
40
  return ''
@@ -332,4 +332,4 @@ with role</em>; <tt class="docutils literal">inline literal text</tt>; standalon
332
332
  </tbody>
333
333
  </table>
334
334
  </div>
335
- </div>
335
+ </div>
@@ -1,19 +1,24 @@
1
+ \documentclass[a4paper]{article}
1
2
  % generated by Docutils <http://docutils.sourceforge.net/>
2
- \documentclass[a4paper,english]{article}
3
3
  \usepackage{fixltx2e} % LaTeX patches, \textsubscript
4
- \usepackage{cmap} % fix search and cut-and-paste in PDF
5
- \usepackage{babel}
4
+ \usepackage{cmap} % fix search and cut-and-paste in Acrobat
5
+ \usepackage{ifthen}
6
6
  \usepackage[T1]{fontenc}
7
7
  \usepackage[utf8]{inputenc}
8
- \usepackage{ifthen}
9
8
  \usepackage{graphicx}
10
9
  \usepackage{multirow}
11
- \usepackage{longtable}
12
- \usepackage{array}
10
+ \setcounter{secnumdepth}{0}
11
+ \usepackage{longtable,ltcaption,array}
13
12
  \setlength{\extrarowheight}{2pt}
14
13
  \newlength{\DUtablewidth} % internal use in tables
15
14
  \usepackage{tabularx}
16
15
 
16
+ %%% Custom LaTeX preamble
17
+ % PDF Standard Fonts
18
+ \usepackage{mathptmx} % Times
19
+ \usepackage[scaled=.90]{helvet}
20
+ \usepackage{courier}
21
+
17
22
  %%% User specified packages and stylesheets
18
23
 
19
24
  %%% Fallback definitions for Docutils-specific commands
@@ -82,28 +87,29 @@
82
87
  % hyperlinks:
83
88
  \ifthenelse{\isundefined{\hypersetup}}{
84
89
  \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
90
+ \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
85
91
  }{}
86
92
  \hypersetup{
87
93
  pdftitle={The reStructuredText Cheat Sheet: Syntax Reminders},
88
94
  pdfauthor={David Goodger <goodger@python.org>}
89
95
  }
90
96
 
91
- %%% Body
92
- \begin{document}
93
-
94
- % Document title
95
- \title{The reStructuredText Cheat Sheet: Syntax Reminders%
96
- \phantomsection%
97
+ %%% Title Data
98
+ \title{\phantomsection%
99
+ The \href{http://docutils.sf.net/rst.html}{reStructuredText} Cheat Sheet: Syntax Reminders%
97
100
  \label{the-restructuredtext-cheat-sheet-syntax-reminders}}
98
101
  \author{}
99
102
  \date{}
103
+
104
+ %%% Body
105
+ \begin{document}
100
106
  \maketitle
101
107
 
102
108
  % Docinfo
103
109
  \begin{center}
104
110
  \begin{tabularx}{\DUdocinfowidth}{lX}
105
111
  \textbf{Info}: &
106
- See <\href{http://docutils.sf.net/rst.html}{http://docutils.sf.net/rst.html}> for introductory docs.
112
+ See <\url{http://docutils.sf.net/rst.html}> for introductory docs.
107
113
  \\
108
114
  \textbf{Author}: &
109
115
  David Goodger <\href{mailto:goodger@python.org}{goodger@python.org}> \\
@@ -118,30 +124,21 @@ This is a ``docinfo block'', or bibliographic field list
118
124
  \end{center}
119
125
 
120
126
 
121
- %___________________________________________________________________________
122
-
123
- \section*{Section Structure%
124
- \phantomsection%
125
- \addcontentsline{toc}{section}{Section Structure}%
127
+ \section{Section Structure%
126
128
  \label{section-structure}%
127
129
  }
128
130
 
129
131
  Section titles are underlined or overlined \& underlined.
130
132
 
131
133
 
132
- %___________________________________________________________________________
133
-
134
- \section*{Body Elements%
135
- \phantomsection%
136
- \addcontentsline{toc}{section}{Body Elements}%
134
+ \section{Body Elements%
137
135
  \label{body-elements}%
138
136
  }
139
137
 
140
138
  Grid table:
141
139
 
142
- \leavevmode
143
140
  \setlength{\DUtablewidth}{\linewidth}
144
- \begin{longtable}[c]{|p{0.389\DUtablewidth}|p{0.424\DUtablewidth}|}
141
+ \begin{longtable*}[c]{|p{0.389\DUtablewidth}|p{0.424\DUtablewidth}|}
145
142
  \hline
146
143
 
147
144
  Paragraphs are flush-left,
@@ -173,7 +170,7 @@ Doctest~block
173
170
  }
174
171
  & \\
175
172
  \hline
176
- \multicolumn{2}{|l|}{
173
+ \multicolumn{2}{|p{0.81\DUtablewidth}|}{
177
174
  \begin{DUlineblock}{0em}
178
175
  \item[] Line blocks preserve line breaks \& indents. {[}new in 0.3.6{]}
179
176
  \item[]
@@ -184,13 +181,12 @@ lines can be wrapped with continuation lines.
184
181
  \end{DUlineblock}
185
182
  } \\
186
183
  \hline
187
- \end{longtable}
184
+ \end{longtable*}
188
185
 
189
186
  Simple tables:
190
187
 
191
- \leavevmode
192
188
  \setlength{\DUtablewidth}{\linewidth}
193
- \begin{longtable}[c]{|p{0.203\DUtablewidth}|p{0.714\DUtablewidth}|}
189
+ \begin{longtable*}[c]{|p{0.203\DUtablewidth}|p{0.714\DUtablewidth}|}
194
190
  \hline
195
191
  \textbf{%
196
192
  List Type
@@ -266,11 +262,10 @@ Option list
266
262
  \end{DUoptionlist}
267
263
  \\
268
264
  \hline
269
- \end{longtable}
265
+ \end{longtable*}
270
266
 
271
- \leavevmode
272
267
  \setlength{\DUtablewidth}{\linewidth}
273
- \begin{longtable}[c]{|p{0.203\DUtablewidth}|p{0.714\DUtablewidth}|}
268
+ \begin{longtable*}[c]{|p{0.203\DUtablewidth}|p{0.714\DUtablewidth}|}
274
269
  \hline
275
270
  \textbf{%
276
271
  Explicit Markup
@@ -293,7 +288,7 @@ Examples (visible in the \href{cheatsheet.txt}{text source})
293
288
 
294
289
  Footnote
295
290
  & %
296
- \DUfootnotetext{id1}{id3}{1}{
291
+ \DUfootnotetext{id1}{id3}{1}{%
297
292
  Manually numbered or {[}\#{]} auto-numbered
298
293
  (even {[}\#labelled{]}) or {[}*{]} auto-symbol
299
294
  }
@@ -337,38 +332,29 @@ Empty Comment
337
332
  used to separate indentation contexts)
338
333
  \\
339
334
  \hline
340
- \end{longtable}
341
-
335
+ \end{longtable*}
342
336
 
343
- %___________________________________________________________________________
344
337
 
345
- \section*{Inline Markup%
346
- \phantomsection%
347
- \addcontentsline{toc}{section}{Inline Markup}%
338
+ \section{Inline Markup%
348
339
  \label{inline-markup}%
349
340
  }
350
341
 
351
342
  \emph{emphasis}; \textbf{strong emphasis}; \DUroletitlereference{interpreted text}; \emph{interpreted text
352
343
  with role}; \texttt{inline literal text}; standalone hyperlink,
353
- \href{http://docutils.sourceforge.net}{http://docutils.sourceforge.net}; named reference, \href{http://docutils.sf.net/rst.html}{reStructuredText};
344
+ \url{http://docutils.sourceforge.net}; named reference, \href{http://docutils.sf.net/rst.html}{reStructuredText};
354
345
  \href{http://docutils.sf.net/docs/ref/rst/restructuredtext.html}{anonymous reference}; footnote reference,\DUfootnotemark{id3}{id1}{1}; citation reference,
355
- [\hyperlink{cit2002}{CIT2002}]; like an inline directive; %
346
+ \hyperlink{cit2002}{[CIT2002]}; like an inline directive; %
356
347
  \phantomsection\label{inline-internal-target}inline internal target.
357
348
 
358
349
 
359
- %___________________________________________________________________________
360
-
361
- \section*{Directive Quick Reference%
362
- \phantomsection%
363
- \addcontentsline{toc}{section}{Directive Quick Reference}%
350
+ \section{Directive Quick Reference%
364
351
  \label{directive-quick-reference}%
365
352
  }
366
353
 
367
- See <\href{http://docutils.sf.net/docs/ref/rst/directives.html}{http://docutils.sf.net/docs/ref/rst/directives.html}> for full info.
354
+ See <\url{http://docutils.sf.net/docs/ref/rst/directives.html}> for full info.
368
355
 
369
- \leavevmode
370
356
  \setlength{\DUtablewidth}{\linewidth}
371
- \begin{longtable}[c]{|p{0.203\DUtablewidth}|p{0.714\DUtablewidth}|}
357
+ \begin{longtable*}[c]{|p{0.203\DUtablewidth}|p{0.714\DUtablewidth}|}
372
358
  \hline
373
359
  \textbf{%
374
360
  Directive Name
@@ -569,22 +555,17 @@ title
569
555
  Set the metadata document title {[}0.3.10{]}
570
556
  \\
571
557
  \hline
572
- \end{longtable}
573
-
558
+ \end{longtable*}
574
559
 
575
- %___________________________________________________________________________
576
560
 
577
- \section*{Interpreted Text Role Quick Reference%
578
- \phantomsection%
579
- \addcontentsline{toc}{section}{Interpreted Text Role Quick Reference}%
561
+ \section{Interpreted Text Role Quick Reference%
580
562
  \label{interpreted-text-role-quick-reference}%
581
563
  }
582
564
 
583
- See <\href{http://docutils.sf.net/docs/ref/rst/roles.html}{http://docutils.sf.net/docs/ref/rst/roles.html}> for full info.
565
+ See <\url{http://docutils.sf.net/docs/ref/rst/roles.html}> for full info.
584
566
 
585
- \leavevmode
586
567
  \setlength{\DUtablewidth}{\linewidth}
587
- \begin{longtable}[c]{|p{0.203\DUtablewidth}|p{0.726\DUtablewidth}|}
568
+ \begin{longtable*}[c]{|p{0.203\DUtablewidth}|p{0.726\DUtablewidth}|}
588
569
  \hline
589
570
  \textbf{%
590
571
  Role Name
@@ -658,6 +639,7 @@ title
658
639
  Title reference (book, etc.); standard default role
659
640
  \\
660
641
  \hline
661
- \end{longtable}
642
+ \end{longtable*}
643
+
644
+ \end{document}
662
645
 
663
- \end{document}
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'helper'
2
4
  require 'mocha'
3
5
 
@@ -58,23 +60,28 @@ class TestRbST < Test::Unit::TestCase
58
60
 
59
61
  should "recognize strip_comments option" do
60
62
  html_with_comment = RbST.convert(".. comment")
61
- assert_equal html_with_comment, %Q{<div class="document">\n<!-- comment -->\n</div>}
63
+ assert_equal html_with_comment, %Q{<div class=\"document\">\n<!-- comment -->\n</div>\n}
62
64
  html_without_comment = RbST.convert(".. comment", 'strip-comments')
63
- assert_equal html_without_comment, %Q{<div class="document">\n</div>}
65
+ assert_equal html_without_comment, %Q{<div class=\"document\">\n</div>\n}
64
66
  end
65
67
 
66
68
  should "recognize cloak_email_addresses option" do
67
69
  html_with_uncloaked_email = RbST.convert("steve@mac.com")
68
- assert_equal %Q{<div class="document">\n<p><a class="reference external" href="mailto:steve&#64;mac.com">steve&#64;mac.com</a></p>\n</div>}, html_with_uncloaked_email
70
+ assert_equal %Q{<div class=\"document\">\n<p><a class=\"reference external\" href=\"mailto:steve&#64;mac.com\">steve&#64;mac.com</a></p>\n</div>\n}, html_with_uncloaked_email
69
71
  html_with_cloaked_email = RbST.convert("steve@mac.com", 'cloak-email-addresses')
70
- assert_equal %Q{<div class="document">\n<p><a class="reference external" href="mailto:steve&#37;&#52;&#48;mac&#46;com">steve<span>&#64;</span>mac<span>&#46;</span>com</a></p>\n</div>}, html_with_cloaked_email
72
+ assert_equal %Q{<div class=\"document\">\n<p><a class=\"reference external\" href=\"mailto:steve&#37;&#52;&#48;mac&#46;com\">steve<span>&#64;</span>mac<span>&#46;</span>com</a></p>\n</div>\n}, html_with_cloaked_email
71
73
  end
72
74
 
73
75
  should "recognize part option" do
74
76
  html_body = RbST.convert("hello world", :part => :html_body)
75
- assert_equal %Q{<div class="document">\n<p>hello world</p>\n</div>}, html_body
77
+ assert_equal %Q{<div class=\"document\">\n<p>hello world</p>\n</div>\n}, html_body
76
78
  fragment = RbST.convert("hello world", :part => :fragment)
77
- assert_equal %Q{<p>hello world</p>}, fragment
79
+ assert_equal %Q{<p>hello world</p>\n}, fragment
80
+ end
81
+
82
+ should "convert unicode" do
83
+ output = RbST.convert("Hello ☃", :part => :fragment)
84
+ assert_equal %Q{<p>Hello ☃</p>\n}, output
78
85
  end
79
86
 
80
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RbST
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2012-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jeweler
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: 679996262089713862
119
+ hash: 2317176860731085124
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  none: false
122
122
  requirements: