Permalink
Browse files

Say hi to the doctor

  • Loading branch information...
vmg committed Dec 17, 2012
1 parent 609c3b1 commit 320e6e081efcf27c087888de6d9e6eec6cf0e801
Showing with 10 additions and 366 deletions.
  1. +1 −0 Gemfile
  2. +4 −4 github-markup.gemspec
  3. +1 −1 lib/github-markup.rb
  4. +0 −119 lib/github/commands/asciidoc2html
  5. +0 −240 lib/github/commands/asciidocapi.py
  6. +4 −2 lib/github/markups.rb
View
@@ -6,4 +6,5 @@ gem "org-ruby", ">= 0.7.0"
gem "creole", "~>0.3.6"
gem "wikicloth", "=0.6.0"
gem "literati", "= 0.0.3"
+gem "asciidoctor", ">= 0.0.5"
gem "rake"
View
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
## If your rubyforge_project name is different, then edit it and comment out
## the sub! line in the Rakefile
s.name = 'github-markup'
- s.version = '0.7.4'
- s.date = '2012-07-19'
+ s.version = '0.7.5'
+ s.date = '2012-12-17'
s.executables = ['github-markup']
## Make sure your summary is short. The description may be as long
@@ -62,8 +62,6 @@ desc
bin/github-markup
github-markup.gemspec
lib/github-markup.rb
- lib/github/commands/asciidoc2html
- lib/github/commands/asciidocapi.py
lib/github/commands/rest2html
lib/github/markup.rb
lib/github/markup/rdoc.rb
@@ -73,6 +71,8 @@ desc
test/markups/README.asciidoc.html
test/markups/README.creole
test/markups/README.creole.html
+ test/markups/README.lhs
+ test/markups/README.lhs.html
test/markups/README.markdown
test/markups/README.markdown.html
test/markups/README.mediawiki
View
@@ -1,6 +1,6 @@
module GitHub
module Markup
- VERSION = '0.7.4'
+ VERSION = '0.7.5'
Version = VERSION
end
end
@@ -1,119 +0,0 @@
-#!/usr/bin/env python
-
-"""A small wrapper file for parsing AsciiDoc files at Github."""
-
-__author__ = "Devin Weaver"
-__copyright__ = "Copyright (C) 2009 Devin Weaver"
-__license__ = "Public Domain"
-__version__ = "0.1"
-
-"""
-github_asciidoc.py
-------------------
-
-This is a wrapper file for parsing AsciiDoc files at github. It wraps the
-current AsciiDoc API.
-
-AsciiDoc specifications suggest using the file extension of `.txt` however this
-causes conflict because there is no way to determine if a text file is an
-AsciiDoc or not without pre-processing the file. This gives us two simple
-options:
-
-1. **Parse all text files**. We could have all files ending in `.txt` or
- ``README.txt`` be parsed through AsciiDoc. It will print pretty text fine
- even if it isn't formatted as such. However this could be *not what the user
- expects*.
-2. **Pick a unique extension**. We could pick a unique extension (i.e.
- `.asciidoc`) to prevent clashing. Although not directly suggested by the
- author of AsciiDoc there is no standard or practice to the contrary.
-
-Option two is recommended by myself.
-
-Requirements
-~~~~~~~~~~~~
-
-The AsciiDoc API comes in two parts. The first is the system installation of
-AsciiDoc which has a simple install_. The second part is the API script. You
-can either copy this to the current directory or the application's lib folder.
-There is more information on the `API page`_
-
-The `re` package is imported here for the purpose to accomplish E-Mail address
-cloaking. AsciiDoc does not offer it's own cloaking algorithm like docutils
-does. So I made a simple one here to do the same. **If the expense of regex's
-is too high it can be easily commented out.**
-
-.. tip::
- AsciiDoc by default runs in *safe mode* which means it will not include
- external files that are **not** in the same directory as the `infile`.
- However since we use a StringIO through the API it should be based on the
- current working directory.
-
-.. _install: http://www.methods.co.nz/asciidoc/userguide.html
-.. _API page: http://www.methods.co.nz/asciidoc/asciidocapi.html
-"""
-
-try:
- import locale
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-import sys
-import cStringIO # faster then StringIO
-from asciidocapi import AsciiDocAPI
-from asciidocapi import AsciiDocError
-import re # only needed to simulate cloak_email_addresses
-
-def main():
- """
- Parses the given AsciiDoc file or the redirected string input and returns
- the HTML body.
-
- Usage: asciidoc2html < README.rst
- asciidoc2html README.rst
- """
- try:
- text = open(sys.argv[1], 'r').read()
- except IOError: # given filename could not be found
- return ''
- except IndexError: # no filename given
- text = sys.stdin.read()
-
- infile = cStringIO.StringIO(text)
- outfile = cStringIO.StringIO()
- asciidoc = AsciiDocAPI()
- asciidoc.options('-s')
-
- try:
- asciidoc.execute(infile, outfile, 'xhtml11')
- except AsciiDocError, strerror:
- str = "%s" % (strerror)
- str = str.replace("&", "&amp;") # Must be done first
- str = str.replace("<", "%lt;")
- str = str.replace(">", "%gt;")
- outfile.write ("<blockquote><strong>AsciiDoc ERROR: %s</strong></blockquote>" % (str))
-
- """
- Cloak email addresses
-
- AsciiDoc API does not have a `cloak_email_addresses` option. We can do the
- same with a set of regex but that can be expensive. Keep section commented
- to disable. So ``abc@mail.example.com`` becomes:
-
- -----------
- <a class="reference" href="mailto:abc&#37;&#52;&#48;mail&#46;example&#46;org">
- abc<span>&#64;</span>mail<span>&#46;</span>example<span>&#46;</span>org</a>
- -----------
- """
- def mangleEmail(matches):
- email1 = "%s&#37;&#52;&#48;%s" % (matches.group(1), matches.group(2))
- email1 = email1.replace(".", "&#46;")
- email2 = "%s<span>&#64;</span>%s" % (matches.group(1), matches.group(2))
- email2 = email2.replace(".", "<span>&#46;</span>")
- return "<a class=\"reference\" href=\"mailto:%s\">%s</a>" % (email1, email2)
-
- return re.sub(r'<a href="mailto:([^@]+)@([^@]+)">([^@]+)@([^@]+)</a>', mangleEmail, outfile.getvalue())
- #return outfile.getvalue()
-
-if __name__ == '__main__':
- print main()
Oops, something went wrong.

10 comments on commit 320e6e0

@herve-quiroz

This comment has been minimized.

Show comment Hide comment
@herve-quiroz

herve-quiroz Dec 18, 2012

Not 100% sure it is related to this commit but it seems like the line breaks from code block in asciidoc-generated files are broken again. And I seem to recall they were fine yesterday.

See github/markup#108 for the previous line break issue (that was fixed).

See https://github.com/herve-quiroz/tc-opts for an example of an asciidoc README where there should be line breaks in most of the code blocks.

Not 100% sure it is related to this commit but it seems like the line breaks from code block in asciidoc-generated files are broken again. And I seem to recall they were fine yesterday.

See github/markup#108 for the previous line break issue (that was fixed).

See https://github.com/herve-quiroz/tc-opts for an example of an asciidoc README where there should be line breaks in most of the code blocks.

@jakoch

This comment has been minimized.

Show comment Hide comment
@jakoch

jakoch Dec 23, 2012

Seems, that this breaks the AsciiDoc rendering.
For instance tables are not rendered: http://i.imgur.com/b57fu.png
https://github.com/jakoch/asciidoc-cheatsheet/blob/master/asciidoc-866_tables.asciidoc

Seems, that this breaks the AsciiDoc rendering.
For instance tables are not rendered: http://i.imgur.com/b57fu.png
https://github.com/jakoch/asciidoc-cheatsheet/blob/master/asciidoc-866_tables.asciidoc

@herve-quiroz

This comment has been minimized.

Show comment Hide comment
@herve-quiroz

herve-quiroz Dec 23, 2012

In case anyone cares, I created an issue for this: github/markup#175

In case anyone cares, I created an issue for this: github/markup#175

@haad

This comment has been minimized.

Show comment Hide comment
@haad

haad Dec 31, 2012

Afaik asciidoctor is not full replacement for asciidoc and it doest support all features yet.

haad replied Dec 31, 2012

Afaik asciidoctor is not full replacement for asciidoc and it doest support all features yet.

@herve-quiroz

This comment has been minimized.

Show comment Hide comment
@herve-quiroz

herve-quiroz Jan 1, 2013

The issue has been fixed in asciidoctor: erebor/asciidoctor#36

The issue has been fixed in asciidoctor: erebor/asciidoctor#36

@mojavelinux

This comment has been minimized.

Show comment Hide comment
@mojavelinux

mojavelinux Jan 14, 2013

Collaborator

Asciidoctor now supports nearly every feature of AsciiDoc, including tables (as soon as pull request https://github.com/erebor/asciidoctor/pull/73 is merged).

Collaborator

mojavelinux replied Jan 14, 2013

Asciidoctor now supports nearly every feature of AsciiDoc, including tables (as soon as pull request https://github.com/erebor/asciidoctor/pull/73 is merged).

@herve-quiroz

This comment has been minimized.

Show comment Hide comment
@herve-quiroz

herve-quiroz Jan 14, 2013

Well in any case the Asciidoc rendering is currently not happening at all (i.e. it's not just an issue with tables or code blocks). It's been broken for more than a week now. Strange that it hasn't been fixed earlier. See github/markup#180 for the related issue.

Well in any case the Asciidoc rendering is currently not happening at all (i.e. it's not just an issue with tables or code blocks). It's been broken for more than a week now. Strange that it hasn't been fixed earlier. See github/markup#180 for the related issue.

@jakoch

This comment has been minimized.

Show comment Hide comment
@jakoch

jakoch Jan 14, 2013

Very good work, Dan! 👍

Regarding the broken rendering, i guess, Github needs to update their Asciidoctor package.
Also setting up some WebTestCases for testing features, like "Asciidoc Rendering" or "Markdown Rendering" would be good.
But that's another story and not related to Asciidoctor at all.

Very good work, Dan! 👍

Regarding the broken rendering, i guess, Github needs to update their Asciidoctor package.
Also setting up some WebTestCases for testing features, like "Asciidoc Rendering" or "Markdown Rendering" would be good.
But that's another story and not related to Asciidoctor at all.

@herve-quiroz

This comment has been minimized.

Show comment Hide comment
@herve-quiroz

herve-quiroz Jan 14, 2013

I believe the tests are already there:
https://github.com/github/markup/blob/master/test/markups/README.asciidoc
https://github.com/github/markup/blob/master/test/markups/README.asciidoc.html

So if the tests still pass it means the current issue is more related to Website itself, not the markup library.

I believe the tests are already there:
https://github.com/github/markup/blob/master/test/markups/README.asciidoc
https://github.com/github/markup/blob/master/test/markups/README.asciidoc.html

So if the tests still pass it means the current issue is more related to Website itself, not the markup library.

@mojavelinux

This comment has been minimized.

Show comment Hide comment
@mojavelinux

mojavelinux Jan 15, 2013

Collaborator

AFAIK, the current issue is that the Asciidoctor code needed to be carefully reviewed and audited before it could be used in production at GitHub (as you would expect any organization would do with a library going into production, totally understandable). For some reason, though--perhaps because there were concerns about the original AsciiDoc integration code--we got stuck with no AsciiDoc rendering in the interim.

When it comes back, and it's using Asciidoctor, I'm confident it's going to be please :)

Collaborator

mojavelinux replied Jan 15, 2013

AFAIK, the current issue is that the Asciidoctor code needed to be carefully reviewed and audited before it could be used in production at GitHub (as you would expect any organization would do with a library going into production, totally understandable). For some reason, though--perhaps because there were concerns about the original AsciiDoc integration code--we got stuck with no AsciiDoc rendering in the interim.

When it comes back, and it's using Asciidoctor, I'm confident it's going to be please :)

Please sign in to comment.