github-markup 1.4.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e6ecef369a72fbef3cdd07bdf6da3653c43a1ba
4
- data.tar.gz: efc6c822663fa8cab86fa7dbce03980ca8dca994
3
+ metadata.gz: afc82c320a97a18e1f5b60f73dc24655e976a44b
4
+ data.tar.gz: 191b767ae24fda9f343857c6a74c308b87cb91f9
5
5
  SHA512:
6
- metadata.gz: 3da515fc4331f35270fc4ae775aa7fdf6f2c0864fe46a683fc5c95a57994f7ad8a784fa9ef8b941642a969ea22b12a1023c3cefee8226102d796a20e69468240
7
- data.tar.gz: c4b691d2758f7c8edebf80e01af332f48766f51135973aa609f1f17a98ad76e7f40e29d4ba88b52f9210c3a731c5c771c0c3b6290f70de97c09c487bd112570a
6
+ metadata.gz: 5e377067276eedcc237ad87a899b023308def31c966c6cc13ed038d5738d70a6a5536a551acf77d88094270fb23b1b4e12259d1c49a60f12cc0ba3ae55fc4f4c
7
+ data.tar.gz: 3a379abbdebf7fa103412865ebd0b702cd6b14ea3144720e12f6f6e4a1f48f95e79f8e1e6a5003878e074b41cd905530f1bf310e70dd95b6e30e40203b2b0986
@@ -1,7 +1,5 @@
1
1
  language: ruby
2
- before_install: sudo pip install docutils
3
2
  rvm:
4
- - 1.9.3
5
3
  - 2.0.0
6
4
  - 2.1.1
7
5
  - jruby-19mode
@@ -9,3 +7,15 @@ jdk:
9
7
  - oraclejdk8
10
8
  notifications:
11
9
  email: false
10
+ git:
11
+ depth: 10
12
+ before_install: sudo pip install docutils
13
+ cache:
14
+ - bundler
15
+ - pip
16
+ env:
17
+ global:
18
+ - "JRUBY_OPTS=-Xcext.enabled=true"
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: jruby-19mode
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
17
17
  s.require_paths = %w[lib]
18
18
 
19
+ s.add_development_dependency 'activesupport', '~> 4.0'
19
20
  s.add_development_dependency 'minitest', '~> 5.4.3'
20
21
  s.add_development_dependency 'html-pipeline', '~> 1.0'
21
22
  s.add_development_dependency 'sanitize', '~> 2.1.0'
@@ -1,6 +1,6 @@
1
1
  module GitHub
2
2
  module Markup
3
- VERSION = '1.4.0'
3
+ VERSION = '1.4.1'
4
4
  Version = VERSION
5
5
  end
6
6
  end
@@ -45,31 +45,45 @@ except:
45
45
  import codecs
46
46
 
47
47
  from docutils import nodes
48
- from docutils.parsers.rst import roles
48
+ from docutils.parsers.rst import directives, roles
49
+ from docutils.parsers.rst.directives.body import CodeBlock
49
50
  from docutils.core import publish_parts
50
51
  from docutils.writers.html4css1 import Writer, HTMLTranslator
51
52
 
52
53
  SETTINGS = {
53
54
  'cloak_email_addresses': False,
54
55
  'file_insertion_enabled': False,
55
- 'raw_enabled': False,
56
+ 'raw_enabled': True,
56
57
  'strip_comments': True,
57
58
  'doctitle_xform': True,
58
59
  'sectsubtitle_xform': True,
59
60
  'initial_header_level': 2,
60
61
  'report_level': 5,
61
- 'syntax_highlight' : 'none',
62
- 'math_output' : 'latex',
62
+ 'syntax_highlight': 'none',
63
+ 'math_output': 'latex',
63
64
  'field_name_limit': 50,
64
65
  }
65
66
 
67
+
68
+ class DoctestDirective(CodeBlock):
69
+ """Render Sphinx 'doctest:: [group]' blocks as 'code:: python'
70
+ """
71
+
72
+ def run(self):
73
+ """Discard any doctest group argument, render contents as python code
74
+ """
75
+ self.arguments = ['python']
76
+ return super(DoctestDirective, self).run()
77
+
78
+
66
79
  class GitHubHTMLTranslator(HTMLTranslator):
80
+
67
81
  # removes the <div class="document"> tag wrapped around docs
68
82
  # see also: http://bit.ly/1exfq2h (warning! sourceforge link.)
69
83
  def depart_document(self, node):
70
84
  HTMLTranslator.depart_document(self, node)
71
- self.html_body.pop(0) # pop the starting <div> off
72
- self.html_body.pop() # pop the ending </div> off
85
+ self.html_body.pop(0) # pop the starting <div> off
86
+ self.html_body.pop() # pop the ending </div> off
73
87
 
74
88
  # technique for visiting sections, without generating additional divs
75
89
  # see also: http://bit.ly/NHtyRx
@@ -102,36 +116,38 @@ class GitHubHTMLTranslator(HTMLTranslator):
102
116
  def visit_table(self, node):
103
117
  classes = ' '.join(['docutils', self.settings.table_style]).strip()
104
118
  self.body.append(
105
- self.starttag(node, 'table', CLASS=classes))
119
+ self.starttag(node, 'table', CLASS=classes))
106
120
 
107
121
  def depart_table(self, node):
108
122
  self.body.append('</table>\n')
109
123
 
110
124
  def depart_image(self, node):
111
- uri = node['uri']
112
- ext = os.path.splitext(uri)[1].lower()
113
- # we need to swap RST's use of `object` with `img` tags
114
- # see http://git.io/5me3dA
115
- if ext == ".svg":
116
- # preserve essential attributes
117
- atts = {}
118
- for attribute, value in node.attributes.items():
119
- # we have no time for empty values
120
- if value:
121
- if attribute == "uri":
122
- atts['src'] = value
123
- else:
124
- atts[attribute] = value
125
-
126
- # toss off `object` tag
127
- self.body.pop()
125
+ uri = node['uri']
126
+ ext = os.path.splitext(uri)[1].lower()
127
+ # we need to swap RST's use of `object` with `img` tags
128
+ # see http://git.io/5me3dA
129
+ if ext == ".svg":
130
+ # preserve essential attributes
131
+ atts = {}
132
+ for attribute, value in node.attributes.items():
133
+ # we have no time for empty values
134
+ if value:
135
+ if attribute == "uri":
136
+ atts['src'] = value
137
+ else:
138
+ atts[attribute] = value
139
+
140
+ # toss off `object` tag
141
+ self.body.pop()
128
142
  # add on `img` with attributes
129
- self.body.append(self.starttag(node, 'img', **atts))
130
- self.body.append(self.context.pop())
143
+ self.body.append(self.starttag(node, 'img', **atts))
144
+ self.body.append(self.context.pop())
145
+
131
146
 
132
147
  def kbd(name, rawtext, text, lineno, inliner, options=None, content=None):
133
148
 
134
- return [nodes.raw('', '<kbd>%s</kbd>' % text, format='html')], []
149
+ return [nodes.raw('', '<kbd>%s</kbd>' % text, format='html')], []
150
+
135
151
 
136
152
  def main():
137
153
  """
@@ -143,9 +159,9 @@ def main():
143
159
  """
144
160
  try:
145
161
  text = codecs.open(sys.argv[1], 'r', 'utf-8').read()
146
- except IOError: # given filename could not be found
162
+ except IOError: # given filename could not be found
147
163
  return ''
148
- except IndexError: # no filename given
164
+ except IndexError: # no filename given
149
165
  text = sys.stdin.read()
150
166
 
151
167
  writer = Writer()
@@ -153,6 +169,9 @@ def main():
153
169
 
154
170
  roles.register_canonical_role('kbd', kbd)
155
171
 
172
+ # Render source code in Sphinx doctest blocks
173
+ directives.register_directive('doctest', DoctestDirective)
174
+
156
175
  parts = publish_parts(text, writer=writer, settings_overrides=SETTINGS)
157
176
  if 'html_body' in parts:
158
177
  html = parts['html_body']
@@ -4,6 +4,9 @@ module GitHub
4
4
  module Markup
5
5
  class Markdown < Implementation
6
6
  MARKDOWN_GEMS = {
7
+ "commonmarker" => proc { |content|
8
+ CommonMarker.render_html(content, :default, %i[tagfilter autolink table strikethrough])
9
+ },
7
10
  "github/markdown" => proc { |content|
8
11
  GitHub::Markdown.render(content)
9
12
  },
@@ -22,7 +22,9 @@ markup(:creole, /creole/) do |content|
22
22
  end
23
23
 
24
24
  markup(:wikicloth, /mediawiki|wiki/) do |content|
25
- WikiCloth::WikiCloth.new(:data => content).to_html(:noedit => true)
25
+ wikicloth = WikiCloth::WikiCloth.new(:data => content)
26
+ WikiCloth::WikiBuffer::HTMLElement::ESCAPED_TAGS << 'tt'
27
+ wikicloth.to_html(:noedit => true)
26
28
  end
27
29
 
28
30
  markup(:asciidoctor, /adoc|asc(iidoc)?/) do |content|
@@ -6,6 +6,9 @@ __TOC__
6
6
 
7
7
  = Red Bridge (JRuby Embed) =
8
8
 
9
+ <tt>one-<two</tt>
10
+ <pre>a-b</pre>
11
+
9
12
  JRuby has long had a private embedding API, which was closely tied to the runtime's internals and therefore changed frequently as JRuby evolved. Since version 1.4, however, we have also provided a more stable public API, known as Red Bridge or JRuby Embed. Existing Java programs written to the [[DirectJRubyEmbedding|legacy API]] should still work, but we strongly recommend Red Bridge for all new projects.
10
13
 
11
14
  == Features of Red Bridge ==
@@ -18,6 +18,9 @@ Using Java from Ruby is JRuby's best-known feature---but you can also go in the
18
18
  <a name="Red_Bridge_JRuby_Embed"></a>Red Bridge (JRuby Embed)</h1>
19
19
 
20
20
 
21
+ <p><tt>one-&lt;two</tt>
22
+ </p><pre>a-b</pre>
23
+
21
24
 
22
25
  <p>JRuby has long had a private embedding API, which was closely tied to the runtime's internals and therefore changed frequently as JRuby evolved. Since version 1.4, however, we have also provided a more stable public API, known as Red Bridge or JRuby Embed. Existing Java programs written to the <a href="DirectJRubyEmbedding">legacy API</a> should still work, but we strongly recommend Red Bridge for all new projects.
23
26
  </p>
@@ -31,6 +31,19 @@ The UTF-8 quote character in this table used to cause python to go boom. Now doc
31
31
  Tabular Data, 5
32
32
  Made up ratings, 11
33
33
 
34
+ .. code::
35
+
36
+ A block of code
37
+
38
+ .. code:: python
39
+
40
+ python.code('hooray')
41
+
42
+ .. doctest:: ignored
43
+
44
+ >>> some_function()
45
+ 'result'
46
+
34
47
  ============== ==========================================================
35
48
  Travis http://travis-ci.org/tony/pullv
36
49
  Docs http://pullv.rtfd.org
@@ -59,3 +72,8 @@ Field list
59
72
  someone@somewhere.org
60
73
 
61
74
  Press :kbd:`Ctrl+C` to quit
75
+
76
+
77
+ .. raw:: html
78
+
79
+ <p><strong>RAW HTML!</strong></p><style> p {color:blue;} </style>
@@ -16,6 +16,16 @@
16
16
  <li>Somé UTF-8°</li>
17
17
  </ol>
18
18
  <p>The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it.</p>
19
+ <pre>
20
+ A block of code
21
+ </pre>
22
+ <pre lang="python">
23
+ python.code('hooray')
24
+ </pre>
25
+ <pre lang="python">
26
+ &gt;&gt;&gt; some_function()
27
+ 'result'
28
+ </pre>
19
29
  <table>
20
30
 
21
31
 
@@ -77,3 +87,5 @@ but no problem!</td>
77
87
  <p><a href="mailto:someone@somewhere.org">someone@somewhere.org</a></p>
78
88
 
79
89
  <p>Press <kbd>Ctrl+C</kbd> to quit</p>
90
+
91
+ <p><strong>RAW HTML!</strong></p> p {color:blue;}
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-31 00:00:00.000000000 Z
11
+ date: 2017-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: minitest
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
176
  version: '0'
163
177
  requirements: []
164
178
  rubyforge_project:
165
- rubygems_version: 2.2.3
179
+ rubygems_version: 2.5.1
166
180
  signing_key:
167
181
  specification_version: 4
168
182
  summary: The code GitHub uses to render README.markup