Giter Club home page Giter Club logo

markup's Introduction

GitHub Markup

This library is the first step of a journey that every markup file in a repository goes on before it is rendered on GitHub.com:

  1. github-markup selects an underlying library to convert the raw markup to HTML. See the list of supported markup formats below.
  2. The HTML is sanitized, aggressively removing things that could harm you and your kin—such as script tags, inline-styles, and class or id attributes.
  3. Syntax highlighting is performed on code blocks. See github/linguist for more information about syntax highlighting.
  4. The HTML is passed through other filters that add special sauce, such as emoji, task lists, named anchors, CDN caching for images, and autolinking.
  5. The resulting HTML is rendered on GitHub.com.

Please note that only the first step is covered by this gem — the rest happens on GitHub.com. In particular, markup itself does no sanitization of the resulting HTML, as it expects that to be covered by whatever pipeline is consuming the HTML.

Please see our contributing guidelines before reporting an issue.

Markups

The following markups are supported. The dependencies listed are required if you wish to run the library. You can also run script/bootstrap to fetch them all.

Installation

gem install github-markup

or

bundle install

from this directory.

Usage

Basic form:

require 'github/markup'

GitHub::Markup.render('README.markdown', "* One\n* Two")

More realistic form:

require 'github/markup'

GitHub::Markup.render(file, File.read(file))

And a convenience form:

require 'github/markup'

GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "* One\n* Two")

Contributing

See Contributing.

markup's People

Contributors

aharpole avatar bartkamphorst avatar bkeepers avatar brianmario avatar bryanveloso avatar cobyism avatar defunkt avatar djdefi avatar flying-sheep avatar gjtorikian avatar jinhucheung avatar jj avatar jmeridth avatar kakwa avatar kenyonj avatar kivikakk avatar lee-dohm avatar mojavelinux avatar nickborromeo avatar pchaigno avatar pmaupin avatar rtomayko avatar sr avatar technoweenie avatar tekkub avatar terencehonles avatar theory avatar tokibito avatar vmg avatar wallyqs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

markup's Issues

reStructuredText renders badly (causes two H1)

GitHub uses following line, I presume:

rst2html.py README.rst > README.html

which if you ask me is incorrect, it causes two H1 to appear. Instead please make an option if not default to be able to use this:

rst2html.py --no-doc-title README.rst > README.html

The name implies that it drops title, that is not correct it just makes the Header levels correct, using that there is only one H1.

Mediawiki autotoc left on

If the mediawiki parser sees more than four sections in the current mediawiki document it automatically renders a TOC. As this behaviour is not consistent across all parsers (only mediawiki does this), it should be turned off by default.

One way is to pass the NOTOC markup along with the page content

markup(:wikicloth, /mediawiki|wiki/) do |content|
  WikiCloth::WikiCloth.new(:data => "__NOTOC__" + content).to_html(:noedit => true)
end

But there's probably a better way to do this...

I wrote a nokogiri based TOC generator that could be easily integrated if such functionality is needed:
https://github.com/arr2036/gollum/blob/toc_extension/lib/extensions/toc.rb

files larger than 65,535 bytes cause markup to hang

There seems to be a problem with Ruby's open3 or the operating system's pipe buffer that causes a puts of more than 65,535 bytes to hang open3. The following code does basically the same thing markup does:

#!/usr/bin/ruby

require 'open3'

command = "cat"
target  = "x" * 65535
out     = ""

Open3.popen3(command) do |stdin, stdout, _|
    stdin.puts target
    stdin.close
    out = stdout.read
end

puts out.length

target  = "x" * 65536
out     = ""

puts "1"
Open3.popen3(command) do |stdin, stdout, _|
    puts "2"
    stdin.puts target
    puts "3"
    stdin.close
    out = stdout.read
end

puts out.length

How do I get involed with this?

Doing this because i play all musical instruments too well for anyone to have me play and overshadow them. o I figure if I can get good at this then I might be able to make musical codes.
NEED TO KNOW WHERE IS A GOOD POINT TO START FROM, WILLING TO LEARN MORE THAN A DOCTOR ON THE ENTERPRISE

Add GitHub Flavored Markdown

I can't seem to find a connection between GitHub's markup support and GitHub Flavored Markdown anywhere. It'd be nice to have though. Even if it uses a new .gfm extension so it doesn't break existing .md README files.

Does it not exist because it ties repos to GitHub?

trac wiki markup

I find myself often converting trac projects to github, and there's a lot of wiki pages. To date I've been converting the trac pages to something Github supports, but having github support the trac wiki format might be easier for a lot of projects.

Would you be interested in a program to handle trac?

trouble with inline html

I am having trouble with inline html tags in my README.md file.

From what I have read about Daring Fireball's Markdown, Redcarpet and Upskirt, a simple span element should suffice for adding styles, like this.

<span style="color:#F00;background-color:#555">TODO</span>: Fix inline-html in README.md

However, these tags are removed from html output. What am I missing?

Thanks, -S.

Force parsing of markdown inside div elements when markdown attribute is present

Markdown can be turned off by surrounding the content in a

. This comes in handy when pasting chunks of HTML like counters or comment widgets. To force Markdown to interpret markup in
's, add a markdown="1" attribute to the div.

this will not be rendered


* oh
* look
* a list

while this will

* oh
* look
* a list

Textile already does that. It'd be nice to have that here too.

add creole support

creole is a wiki format designed by committee. What could be better?

In it's defence the committee process was a bit like the microformats process: balancing the features and syntaxes of exiting wiki markups to produce one that is as lacking in eccentricity as possible.

Here's my fork of markup

Unify Markup and Gollum (and GitHub flavored Markdown)

Is there any chance that markup and gollum will have equal features/syntax.
For example I'm really missing the ``` syntax in markup, so we could use it in READMEs.
Additionally allowing GitHub flavored Markdown everywhere would be great too.

The best alternative seems to be integrating Markup into Gollum, although this is non-trivial for sure. Maybe there are even reasons that completely prevent such an integration.

Two of the install commands don't work

Markdown's install command (gem install markdown) and Org-mode's install command (gem install org-mode) don't work on a relatively clean install of OS X 10.6.4. Out put is as follows:

cowens@amans:~$ gem install markdown
ERROR:  Could not find a valid gem 'markdown' (>= 0) in any repository 
cowens@amans:~$ gem install org-mode
ERROR:  Could not find a valid gem 'org-mode' (>= 0) in any repository

AsciiDoc Theme

Would it be feasible to set the asciidoc theme or include custom stylesheet?

I realize that it would be most undesirable to have side effects to any elements outside of div.wikistyle but I guess it could be possible hopeful

Support ronn format

http://github.com/rtomayko/ronn
http://github.com/sfiera/github-markup/tree/ronn

As stated in the commit message, this is missing an appropriate stylesheet. I don't know what the preferred method for fixing that is; style information must go in , but there isn't a hook for that exposed in the markup module, nor do I know if such a thing would be practical within the github infrastructure.

From the looks of it, hpricot would make it relatively easy to compose the stylesheet with the HTML, but it's enough work that I'd prefer to see if there's another way first.

Bullets cause indentation for code to be non-standard

If I have

Foo

code

Bar

  • list1

  • list2

    Rails.application.routes.draw do
    resource :foo
    end

Notice that the Rails.application.routes is not recognized as code. However both code and Rails.application.routes.draw ... are indented four spaces.

Symbolic links and other methods of indicating the README format

This may be in the wrong issue queue; if so, I apologize in advance, and humbly request to be redirected to the proper facility.

I've discovered to my chagrin that README* files which are symlinks do not get recognized by github, or at least they are not being displayed as the README file for the branch page.

This would be quite useful, since I usually write my documentation in markdown, but for some projects, e.g. Python modules, it's important to have a README file with a name other than README.markdown. Since markdown is text, ln -s README.txt README.markdown && git add README.markdown would work quite well, except that the markup system doesn't seem to follow symlinks.

I guess I could rebuild (i.e. copy) the README.txt file in a commit/merge hook, but it's sort of a hassle to have to write a commit hook to do this, and it's somewhat confusing for people to have two files in their cloned repo or download which are exactly the same. It's also in violation, I'm sure, of some fundamental rule of source control management theory, the one about not committing generated files.

This issue is related to issue 3, in that if that feature were implemented in a way that allowed for reliable detection of markdown within *.txt files it wouldn't be necessary. It's not really clear that that's possible, though, and assuming that somebody is writing markdown when they just want their file displayed as plain text would be an annoying way to do things.

That issue is also related because somebody mentioned this approach in a comment on the issue.

There was also a suggestion made to allow the repo maintainer to indicate what format the README should be parsed as; this was responded to to the effect that such a feature was unlikely to be put into place because it "gains nothing over just adding the correct extension." Hopefully my above statements serve as a sensible objection to this assertion.

Another option, not mentioned in the comments thread for that issue, could be to use a metadata file in the repo to save github-related options, e.g. /.github:

[README]
        file = README.txt
        format = markdown

I leave it to your graces to make a wise ruling on this matter.

None

Sorry, wrong project

textile unescapes html

when editing a github wiki page, the & lt ; and & gt ; html entities get converted to their corresponding characters.

to reproduce try this:

edit or add a wiki page, and add & lt ; (without spaces) in it.
press 'update' and it will look alright. now press 'edit' again. instead of & lt ; you'll have the less than character, which is not what you entered initially. probably needs html escaping between the textarea tags.

markdown headers should have anchors

Anchors are great for usability in long documentation.

# Install
blah blah

<h1 name="INSTALL">Install</h1>
<p>blah blah</p>

http://github.com/user/repo#INSTALL

RDoc doesn't render in Ruby 1.9.2

RDoc is not rendered when using Ruby 1.9.2, even if the rdoc gem is properly installed. This can be reproduced with a call to:

GitHub::Markup.render("foo.rdoc")

Assuming foo.rdoc exists and the rdoc gem is installed, this will render the RDoc to HTML in Ruby 1.8.7. But in Ruby 1.9.2, this will just return the original RDoc text.

It looks like SM::SimpleMarkup is not available in Ruby 1.9.2 (is a new gem needed?). Possibly RDoc::Markup::ToHtml could be used instead. I'd be happy to contribute a patch if you are interested in having this fixed. Please let me know.

reStructuredText (.rst) text files not displaying content

There is a problem with reStructuredText files (.rst) not displaying in the code browser. reStructuredText is just a text format, I know it's not markdown but they are just plain text (like markdown) so the content should at least be displayed if it cant be rendered. Normally what happens is parts of the file are simply omitted. I think what really should happen, at the least, is that they are treated as normal text files with all the content shown.

I give an extreme example of what's happening: https://github.com/doctrine/orm-documentation/blob/master/en/index.rst
Notice file has 67 lines, but github's viewer just shows 7 lines.

For reference, reStructuredText - http://docutils.sourceforge.net/rst.html
Used by Sphinx document generator - http://sphinx.pocoo.org/

The reason OSS projects use .rst files is because it's more or less like Markdown but it can be used to generated structured documentation with TOC/Index/Search etc with zero extra cost. I'm not asking that you guys render it, but at least display the content in the repo viewer.

Intelligently determine what file to render a README from if README.* isn't present

(It doesn't look like this is part of the github/markup code, so I couldn't patch this)

Currently a lot of projects have some sort of embedded documentation that's easy to find, but GitHub doesn't find and display it.

Examples include:

  • This project, which has only a single file, which includes embedded POD.
  • This project. Which has a README.pod generated from lib/Hailo.pm

It would be nice if GitHub's logic for finding documentation to display in the main page of the project was a bit more permissive than just displaying glob("README_"). E.g. by seeing that the project has one main file that has embedded docs, or that the "main module" of a project has docs (e.g. for Perl code figure out that it's the top-level class in lib/, which could be just find lib -type f -name '_.pm' | head -n 1 for the common case).

Symbolic links and other methods of indicating the README format

This may be in the wrong issue queue; if so, I apologize in advance, and humbly request to be redirected to the proper facility.

I've discovered to my chagrin that README* files which are symlinks do not get recognized by github, or at least they are not being displayed as the README file for the branch page.

This would be quite useful, since I usually write my documentation in markdown, but for some projects, e.g. Python modules, it's important to have a README file with a name other than README.markdown. Since markdown is text, ln -s README.txt README.markdown && git add README.markdown would work quite well, except that the github web system doesn't seem to follow symlinks.

I guess I could rebuild (i.e. copy) the README.txt file in a commit/merge hook, but it's sort of a hassle to have to write a commit hook to do this, and it's somewhat confusing for people to have two files in their cloned repo or download which are exactly the same. It's also in violation, I'm sure, of some fundamental rule of source control management theory, the one about not committing generated files.

This issue is related to issue #3, in that if that feature were implemented in a way that allowed for reliable detection of markdown within *.txt files it wouldn't be necessary. It's not really clear that that's possible, though, and assuming that somebody is writing markdown when they just want their file displayed as plain text would be an annoying way to do things.

That issue is also related because somebody mentioned this approach in a comment on the issue.

There was also a suggestion made to allow the repo maintainer to indicate what format the README should be parsed as; this was responded to to the effect that such a feature was unlikely to be put into place because it "gains nothing over just adding the correct extension." Hopefully my above statements serve as a sensible objection to this assertion.

Another option, not mentioned in the comments thread for that issue, could be to use a metadata file in the repo to save github-related options, e.g. /.github:

[README]
        file = README.txt
        format = markdown

I leave it to your graces to make a wise ruling on this matter.

asciidoc document title not rendered

asciidoc readme files do not render the document header correctly. example

According to the asciidoc cheat sheet, the document header is supposed to be specified like this:

Main Header Here
================

In a github readme, the header just disappears completely instead of showing up in large title font.

Add maruku support.

I just added some support for Maruku: Wilhansen/markup@039f72d690ca1ad9a17b

Ideally, markup would have some configuration mechanism that allows one to override which processor to use for what file format. Unfortunately, that might require a non-trivial overhaul so what I did was just to add another file extension, *.maruku.

support pandoc markdown

hi,

could you add support for pandoc markdown1? it has some extra features like definition lists, which are useful for README documentation.

to distinguish between pandoc markdown and regular markdown, you could note the pandoc support for document metadata ("title blocks"2) which makes the file start with '%', an extremely unusual first character for a regular markdown document.

Disable RestructuredText rendering?

I'm working on a documentation project that uses Sphinx + RestructuredText. See e.g.:

https://github.com/python4astronomers/python4astronomers/blob/master/source/installation/installation.rst

The problem is that in this case I do not want to have the *.rst files automatically rendered to HTML, instead I want to see the raw RestructuredText. I hope I'm not missing something obvious but I cannot see a way to just see the raw file content. The "raw" button is quite a tease since it looks like what I want but it just gives me a file download.

Thanks, Tom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.