diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..2fd9384d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,133 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[Qiita Support](https://support.qiita.com/hc/ja/requests/new). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available +at [https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CODE_OF_CONDUCT.txt b/CODE_OF_CONDUCT.txt deleted file mode 100644 index dbc5f31c..00000000 --- a/CODE_OF_CONDUCT.txt +++ /dev/null @@ -1,87 +0,0 @@ -Contributor Covenant Code of Conduct - -Our Pledge - -We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -Our Standards - -Examples of behavior that contributes to a positive environment for our community include: - - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall community - - -Examples of unacceptable behavior include: - - -* The use of sexualized language or imagery, and sexual attention or -advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others’ private information, such as a physical or email -address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a -professional setting - - -Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. - -Scope - -This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. - -Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at gjtorikian@gmail.com. All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the reporter of any incident. - -Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: - -1. Correction - -Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. - -Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. - -2. Warning - -Community Impact: A violation through a single incident or series of actions. - -Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. - -3. Temporary Ban - -Community Impact: A serious violation of community standards, including sustained inappropriate behavior. - -Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. - -4. Permanent Ban - -Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. - -Consequence: A permanent ban from any sort of public interaction within the community. - -Attribution - -This Code of Conduct is adapted from the Contributor Covenant, version 2.0, -available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. - -Community Impact Guidelines were inspired by Mozilla’s code of conduct enforcement ladder. - -For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. - diff --git a/README.md b/README.md index 84fcd07b..0cd974c3 100644 --- a/README.md +++ b/README.md @@ -1,288 +1,16 @@ -# CommonMarker +# Qiita Marker - [](http://badge.fury.io/rb/commonmarker) +[](https://github.com/increments/qiita-marker/actions/workflows/test.yml) -Ruby wrapper for [libcmark-gfm](https://github.com/github/cmark), -GitHub's fork of the reference parser for CommonMark. It passes all of the C tests, and is therefore spec-complete. It also includes extensions to the CommonMark spec as documented in the [GitHub Flavored Markdown spec](http://github.github.com/gfm/), such as support for tables, strikethroughs, and autolinking. +:warning: This library is still in the testing phase. As such, development may be halted. -For more information on available extensions, see [the documentation below](#extensions). - -## Installation - -Add this line to your application's Gemfile: - - gem 'commonmarker' - -And then execute: - - $ bundle - -Or install it yourself as: - - $ gem install commonmarker +Qiita Marker is a Ruby library for Markdown processing, based on [CommonMarker](https://github.com/gjtorikian/commonmarker). +It will be a core module of [Qiita Markdown](https://github.com/increments/qiita-markdown) gem and not intended for direct use. If you are looking for Qiita-specified markdown processor, use [Qiita Markdown](https://github.com/increments/qiita-markdown) gem. ## Usage -### Converting to HTML - -Call `render_html` on a string to convert it to HTML: - -``` ruby -require 'commonmarker' -CommonMarker.render_html('Hi *there*', :DEFAULT) -#
Hi there
\n -``` - -The second argument is optional--[see below](#options) for more information. - -### Generating a document - -You can also parse a string to receive a `Document` node. You can then print that node to HTML, iterate over the children, and other fun node stuff. For example: - -``` ruby -require 'commonmarker' - -doc = CommonMarker.render_doc('*Hello* world', :DEFAULT) -puts(doc.to_html) #Hi there
\n - -doc.walk do |node| - puts node.type # [:document, :paragraph, :text, :emph, :text] -end -``` - -The second argument is optional--[see below](#options) for more information. - -#### Example: walking the AST - -You can use `walk` or `each` to iterate over nodes: - -- `walk` will iterate on a node and recursively iterate on a node's children. -- `each` will iterate on a node and its children, but no further. - -``` ruby -require 'commonmarker' - -# parse the files specified on the command line -doc = CommonMarker.render_doc("# The site\n\n [GitHub](https://www.github.com)") - -# Walk tree and print out URLs for links -doc.walk do |node| - if node.type == :link - printf("URL = %s\n", node.url) - end -end - -# Capitalize all regular text in headers -doc.walk do |node| - if node.type == :header - node.each do |subnode| - if subnode.type == :text - subnode.string_content = subnode.string_content.upcase - end - end - end -end - -# Transform links to regular text -doc.walk do |node| - if node.type == :link - node.insert_before(node.first_child) - node.delete - end -end -``` - -### Creating a custom renderer - -You can also derive a class from CommonMarker's `HtmlRenderer` class. This produces slower output, but is far more customizable. For example: - -``` ruby -class MyHtmlRenderer < CommonMarker::HtmlRenderer - def initialize - super - @headerid = 1 - end - - def header(node) - block do - out("` for fenced code blocks. |
-| `:LIBERAL_HTML_TAG` | Support liberal parsing of inline HTML tags. |
-| `:FOOTNOTES` | Render footnotes. |
-| `:STRIKETHROUGH_DOUBLE_TILDE` | Parse strikethroughs by double tildes (compatibility with [redcarpet](https://github.com/vmg/redcarpet)) |
-| `:TABLE_PREFER_STYLE_ATTRIBUTES` | Use `style` insted of `align` for table cells. |
-| `:FULL_INFO_STRING` | Include full info strings of code blocks in separate attribute. |
-
-### Passing options
-
-To apply a single option, pass it in as a symbol argument:
-
-``` ruby
-CommonMarker.render_doc("\"Hello,\" said the spider.", :SMART)
-# “Hello,” said the spider.
\n
-```
-
-To have multiple options applied, pass in an array of symbols:
-
-``` ruby
-CommonMarker.render_html("\"'Shelob' is my name.\"", [:HARDBREAKS, :SOURCEPOS])
-```
-
-For more information on these options, see [the CMark documentation](https://git.io/v7nh1).
-
-## Extensions
-
-Both `render_html` and `render_doc` take an optional third argument defining the extensions you want enabled as your CommonMark document is being processed. The documentation for these extensions are [defined in this spec](https://github.github.com/gfm/), and the rationale is provided [in this blog post](https://githubengineering.com/a-formal-spec-for-github-markdown/).
-
-The available extensions are:
-
-* `:table` - This provides support for tables.
-* `:tasklist` - This provides support for task list items.
-* `:strikethrough` - This provides support for strikethroughs.
-* `:autolink` - This provides support for automatically converting URLs to anchor tags.
-* `:tagfilter` - This escapes [several "unsafe" HTML tags](https://github.github.com/gfm/#disallowed-raw-html-extension-), causing them to not have any effect.
-
-## Output formats
-
-Like CMark, CommonMarker can generate output in several formats: HTML, XML, plaintext, and commonmark are currently supported.
-
-### HTML
-
-The default output format, HTML, will be generated when calling `to_html` or using `--to=html` on the command line.
-
-```ruby
-doc = CommonMarker.render_doc('*Hello* world!', :DEFAULT)
-puts(doc.to_html)
-
-Hello world!
-```
-
-### XML
-
-XML will be generated when calling `to_xml` or using `--to=xml` on the command line.
-
-```ruby
-doc = CommonMarker.render_doc('*Hello* world!', :DEFAULT)
-puts(doc.to_xml)
-
-
-
-
-
-
- Hello
-
- world!
-
-
-```
-
-### Plaintext
-
-Plaintext will be generated when calling `to_plaintext` or using `--to=plaintext` on the command line.
-
-```ruby
-doc = CommonMarker.render_doc('*Hello* world!', :DEFAULT)
-puts(doc.to_plaintext)
-
-Hello world!
-```
-
-### Commonmark
-
-Commonmark will be generated when calling `to_commonmark` or using `--to=commonmark` on the command line.
-
-``` ruby
-text = <<-TEXT
-1. I am a numeric list.
-2. I continue the list.
-* Suddenly, an unordered list!
-* What fun!
-TEXT
-
-doc = CommonMarker.render_doc(text, :DEFAULT)
-puts(doc.to_commonmark)
-
-1. I am a numeric list.
-2. I continue the list.
-
-
-
- - Suddenly, an unordered list\!
- - What fun\!
-```
-
-## Developing locally
-
-After cloning the repo:
-
-```
-script/bootstrap
-bundle exec rake compile
-```
-
-If there were no errors, you're done! Otherwise, make sure to follow the CMark dependency instructions.
-
-## Benchmarks
-
-Some rough benchmarks:
-
-```
-$ bundle exec rake benchmark
+Please see [CommonMarker's Usage](https://github.com/gjtorikian/commonmarker#usage).
-input size = 11063727 bytes
+## License
-redcarpet
- 0.070000 0.020000 0.090000 ( 0.079641)
-github-markdown
- 0.070000 0.010000 0.080000 ( 0.083535)
-commonmarker with to_html
- 0.100000 0.010000 0.110000 ( 0.111947)
-commonmarker with ruby HtmlRenderer
- 1.830000 0.030000 1.860000 ( 1.866203)
-kramdown
- 4.610000 0.070000 4.680000 ( 4.678398)
-```
+Please see [LICENSE.txt](/LICENSE.txt).