forked from crystal-lang/crystal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Markdown to inside the compiler. (crystal-lang#8115)
The Markdown module is buggy and not feature complete. We shouldn't expose it in the standard library. For the compiler's purposes (`crystal doc`) it might be good but users should be encouraged to use a better library. Eventually the `crystal doc` tool should somehow use a different, better markdown library.
- Loading branch information
Showing
10 changed files
with
50 additions
and
42 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
spec/std/markdown/markdown_spec.cr → ...mpiler/crystal/tools/doc/markdown_spec.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
...rystal/tools/doc/markdown_doc_renderer.cr → ...rystal/tools/doc/markdown/doc_renderer.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/markdown/html_renderer.cr → ...ystal/tools/doc/markdown/html_renderer.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Basic implementation of Markdown for the `crystal doc` tool. | ||
# | ||
# It lacks many features and it has some bugs too. Eventually we should replace | ||
# it with something more feature-complete (like https://github.com/icyleaf/markd) | ||
# but that means the compiler will start depending on external shards. Otherwise | ||
# we should extract the doc as a separate tool/binary. | ||
# We don't expose this library in the standard library because it's probable | ||
# that we will never make it feature complete. | ||
# | ||
# Usage: | ||
# | ||
# ``` | ||
# require "compiler/crystal/tools/doc/markdown" | ||
# | ||
# text = "## This is title \n This is a [link](http://crystal-lang.org)" | ||
# | ||
# Crystal::Doc::Markdown.to_html(text) | ||
# # => <h2>This is title</h2> | ||
# # => <p>This is a <a href="http://crystal-lang.org">link</a></p> | ||
# ``` | ||
module Crystal::Doc::Markdown | ||
def self.parse(text, renderer) | ||
parser = Parser.new(text, renderer) | ||
parser.parse | ||
end | ||
|
||
def self.to_html(text) : String | ||
String.build do |io| | ||
parse text, Markdown::HTMLRenderer.new(io) | ||
end | ||
end | ||
end | ||
|
||
require "./parser" | ||
require "./renderer" | ||
require "./html_renderer" |
2 changes: 1 addition & 1 deletion
2
src/markdown/parser.cr → ...iler/crystal/tools/doc/markdown/parser.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/markdown/renderer.cr → ...er/crystal/tools/doc/markdown/renderer.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.